Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2005-06

How to manually control debug information

15 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Nico Aragón

Hello,

I'm writting a custom preprocessor and I would like that the line number information maps to the original file. An example (not real, only an example):

  ...original.pas...
  21 procedure AddFive(var a, b: Integer);
  22 begin
  23   a := ++b;
  24 end;

After preprocessor:

  ...processed.pas...
  25 procedure AddFive(var a, b: Integer);
  26 begin
  27   Inc(b);
  28   a := b;
  29 end;

I would like that stepping in the debugger through AddFive showed original.pas in lines 21 to 24, not processed.pas in lines 25 to 29.

How could I do that?

saludos, Nico Aragón

Reply by email

Peter Vreman
to Nico Aragón
you wrote 26 lines
Hello, I'm writting a custom preprocessor and I would like that the line number information maps to the original file. An example (not real, only an example): ...original.pas... 21 procedure AddFive(var a, b: Integer); 22 begin 23 a := ++b; 24 end; After preprocessor: ...processed.pas... 25 procedure AddFive(var a, b: Integer); 26 begin 27 Inc(b); 28 a := b; 29 end; I would like that stepping in the debugger through AddFive showed original.pas in lines 21 to 24, not processed.pas in lines 25 to 29. How could I do that?

That is not possible with fpc

Peter

Reply by email

Florian Klaempfl
to Peter Vreman
Peter Vreman wrote 31 lines
At 19:36 2-6-2005, you wrote: > Hello, > > I'm writting a custom preprocessor and I would like that the line number > information maps to the original file. An example (not real, only an > example): > > ...original.pas... > 21 procedure AddFive(var a, b: Integer); > 22 begin > 23 a := ++b; > 24 end; > > After preprocessor: > > ...processed.pas... > 25 procedure AddFive(var a, b: Integer); > 26 begin > 27 Inc(b); > 28 a := b; > 29 end; > > I would like that stepping in the debugger through AddFive showed > original.pas > in lines 21 to 24, not processed.pas in lines 25 to 29. > > How could I do that? That is not possible with fpc

Since preprocessed code isn't read by human, why don't change it into

procedure AddFive(var a, b: Integer);
begin
  Inc(b); a := b;
end;

The compiler don't care and you get correct line numbers.

Reply by email

Marco van de Voort
to Nico Aragón: I'm writting a custom preprocessor and I would like that the line number information maps…
Show quoted text 23 lines
I'm writting a custom preprocessor and I would like that the line number information maps to the original file. An example (not real, only an example): ...original.pas... 21 procedure AddFive(var a, b: Integer); 22 begin 23 a := ++b; 24 end; After preprocessor: ...processed.pas... 25 procedure AddFive(var a, b: Integer); 26 begin 27 Inc(b); 28 a := b; 29 end; I would like that stepping in the debugger through AddFive showed original.pas in lines 21 to 24, not processed.pas in lines 25 to 29. How could I do that?

If you have a preprocessor, you will also need a binary postprocessor to edit the linenumbers.

IOW the preprocessor should keep track that original.pas:21 becomes processed.pas:25, and your binary postprocessor should parse all stabs and patch these occurances.

Maybe you need a few dummy units with the same names as the included ones to create entries for these units.

However a binary postprocessor is a bit complicated.

Reply by email

Marco van de Voort
to Nico Aragón
Show quoted text 5 lines
El Viernes, 3 de Junio de 2005 09:56, Marco van de Voort escribi?: > If you have a preprocessor, you will also need a binary postprocessor to > edit the linenumbers. In the executable? Isn't there any previous step to "hook into"?

Yes. The generated assembler.

Anyway, where could I find information about the structures that should be edited?

gcc docs mainly (stabs)

Reply by email

Florian Klaempfl
to Nico Aragón: Clever! But won't the compiler care if a line gets too long? I should still change the…
Nico Aragón wrote 13 lines
El Viernes, 3 de Junio de 2005 09:12, Florian Klaempfl escribió: >Since preprocessed code isn't read by human, why don't change it into > >procedure AddFive(var a, b: Integer); >begin > Inc(b); a := b; >end; > >The compiler don't care and you get correct line numbers. Clever! But won't the compiler care if a line gets too long?

No. The compiler itself doesn't care about line length.

I should still change the file name.

Reply by email

Nico Aragón
to Marco van de Voort: Yes. The generated assembler. gcc docs mainly (stabs)
Marco van de Voort wrote 12 lines
> El Viernes, 3 de Junio de 2005 09:56, Marco van de Voort escribi?: > > If you have a preprocessor, you will also need a binary postprocessor > > to edit the linenumbers. > > In the executable? Isn't there any previous step to "hook into"? Yes. The generated assembler. > Anyway, where could I find information about the structures that should > be edited? gcc docs mainly (stabs)

Thank you, also Florian and Peter, of course. It seems that I have more than enough options :-)

saludos, Nico Aragón

Reply by email

Peter Vreman
to Nico Aragón
Show quoted text 5 lines
> gcc docs mainly (stabs) Thank you, also Florian and Peter, of course. It seems that I have more than enough options :-)

For an simple stabs parser see rtl/inc/lineinfo.pp

Reply by email

Peter Vreman
to Florian Klaempfl: No. The compiler itself doesn't care about line length.
Show quoted text 13 lines
>>Since preprocessed code isn't read by human, why don't change it into >> >>procedure AddFive(var a, b: Integer); >>begin >> Inc(b); a := b; >>end; >> >>The compiler don't care and you get correct line numbers. > > > Clever! But won't the compiler care if a line gets too long? No. The compiler itself doesn't care about line length.

Only you'll get wrong values for the column if the line is longer than 65535 chars.

Reply by email

Peter Vreman
to Pavel V. Ozerski
Show quoted text 6 lines
Hello Florian and all FPC team, I finished patchs in pexports.pas and pmodules.pas fixing win32 dlls smartlink. These patchs are based on latest 1.9 sources which differs from current 2.0 and 2.1 only by bigger logs, therefore they should be applicable for both branchs.

Applied to 2.1. Can be merged to 2.0.x if it works fine.

Reply by email

L505
to Pavel V. Ozerski: Hello Florian and all FPC team, I finished patchs in pexports.pas and pmodules.pas fixing…

| Hello Florian and all FPC team,
|
| I finished patchs in pexports.pas and pmodules.pas fixing win32 dlls | smartlink. These patchs are based on latest 1.9 sources which differs | from current 2.0 and 2.1 only by bigger logs, therefore they should be | applicable for both branchs.
|
| Sincerely, Pavel V. Ozerski

Was that why when I created a DLL it only worked with smartlinking off?

Reply by email