[fpc-devel] A little something I've been working on...

mailinglists at geldenhuys.co.uk mailinglists at geldenhuys.co.uk
Sat Feb 21 17:11:55 CET 2026


On 2026-02-20 17:19, Martin Frb via fpc-devel wrote:
> 
> E.g. currently
> 
> procedure foo;
> var SeenByBar: byte;
>    procedure Bar;
>    begin {} end;
> var NOT_SeenByBar: byte;
> begin {} end;
> 
> FPC currently does not include the info that the 2nd var is not in
> scope for Bar. There would afaik be several ways. So not a Dwarf
> problem.


That was an interesting case - thanks for mentioning it. FPC has the
information needed, I just had to emit it into the debug info. It took
me about 5 minutes to include the declaration index in the debug
output and then read that info back in the debugger engine.

It took a bit longer to figure out the heuristics for my 'locals'
command, because the HighPC and LowPC for procedures are not nested
as I initially expected. FPC processed one method after another, even
though Bar() declaration is nested inside Foo().

But, got it all sorted out in the end, and I added this as an
official integration test.

------
(pdr) break test_19_nested_scope.pas:14
(pdr) break test_19_nested_scope.pas:24
(pdr) c
[PROG] running test
[INFO] Hit breakpoint at 0x0000000000401113
(pdr) locals
BarLocal = 2
SeenByBar = 1
(pdr) c
[PROG] inside bar
[INFO] Hit breakpoint at 0x00000000004010B3
(pdr) locals
SeenByBar = 1
NotSeenByBar = 99
(pdr) q
Exiting...
------

Complete example program is attached.


Regards,
   Graeme
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test_19_nested_scope.pas
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20260221/bffc839a/attachment.ksh>


More information about the fpc-devel mailing list