[fpc-devel] How to manually control debug information

Marco van de Voort marcov at stack.nl
Fri Jun 3 09:56:13 CEST 2005

> 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.

More information about the fpc-devel mailing list