This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [Core] [RFA/DWARF2] Handle nested subprograms in CU pc bound calculation
- From: Daniël Mantione <daniel dot mantione at freepascal dot org>
- To: FPC Core Developer List <core at freepascal dot org>
- Cc: Pierre Muller <muller at ics dot u-strasbg dot fr>, gpc at gnu dot de, gdb-patches at sourceware dot org
- Date: Thu, 2 Oct 2008 08:43:06 +0200 (CEST)
- Subject: Re: [Core] [RFA/DWARF2] Handle nested subprograms in CU pc bound calculation
- References: <20080930152757.GC23135@adacore.com> <002601c92313$27d06790$777136b0$@u-strasbg.fr> <20080930170648.GI3811@adacore.com> <20080930173837.GA959@caradoc.them.org> <20081001011534.GA3665@adacore.com> <003201c92399$3207f300$9617d900$@u-strasbg.fr> <20081001163945.GI3665@adacore.com>
Op Wed, 1 Oct 2008, schreef Joel Brobecker:
The answer to the question above lies in the Pascal parser. But when
there are homonyms, how do you specify in your program exactly which
one you mean? And does GDB provide the same method for distinguishing
these homonyms?
(need to relearn Pascal one of these days...)
Pascal has a stack based symbol resolving (we call it the symtablestack in
the compiler). For example take for example the following program:
program my_program;
uses unit_a,unit_b,unit_c;
var a:integer;
procedure main_procedure;
var a:integer;
procedure sub_procedure;
var a:integer;
begin
a:=1;
main_procedure.a:=1;
my_program.a:=1;
unit_a.a:=1;
unit_b.a:=1;
unit_c.a:=1;
end;
begin
end;
So each procedure context can redefine identifiers.
Inside sub_procedure, the symtablestack will look like:
unit_a
unit_b
unit_c
my_program
main_procedure
sub_procedure
When searching for a symbol, the compiler will search the symbol tables
bottom to top, starting at sub_procedure, ending at unit_a, the first
symbol found is used. GDB would need to implement the same behaviour in
it's Pascal mode.
Daniël