This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Core] [RFA/DWARF2] Handle nested subprograms in CU pc bound calculation




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
Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]