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

Joel Brobecker
2008-10-01T16:40:29Z

> > 2008-09-30 Joel Brobecker <brobecker@adacore.com>
> >
> > * dwarf2read.c (dwarf2_handle_nested_subprograms_p): New
> > function.
> > (add_partial_subprogram): Replace check of Ada language by call
> > to dwarf2_handle_nested_subprograms_p.
> > (dwarf2_get_subprogram_pc_bounds, load_partial_dies): Likewise.
>
> This looks fine for me!

OK, I can commit this patch in a week or so to give people some time
to object. We can deal with the other issues with a separate patch.

> I know even less about GNU pascal compiler, but as this compiler is
> base on the GNU multi-language compiler, I would except it to behave
> closer to GNU C++ or GNU Ada.

Seems reasonable.

> I must confess that I don't even know if the full specification
> would work for pascal in case the same name is used globally and as
> a nested procedure (I do know that you are allowed
> to reuse a name defined globally as a local procedure, function or variable
> inside a function, but I don't know if the
> (gdb) break GlobalFuntion.LocalFunction would work)

I think we need to answer that question first before we go and start
spending the CPU time to scan for nested subprograms. Homonyms can
happen in the case you suggested, or in the case when two nested
subprograms have the same name. Right now, when there is an ambiguity,
I understand that the debugger chooses one at random. Until we fix that,
adding nested subprograms whose name might overshadow library-level
subprograms is a bad idea in my opinion.

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