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: [RFA/dwarf] save nested Ada subprograms as global symbol


On Wed, Dec 26, 2007 at 11:39:38PM -0800, Joel Brobecker wrote:
> The problem is trying to break on First:
> 
>         % gdb hello
>         (gdb) break first
>         Function "first" not defined.
>         Make breakpoint pending on future shared library load? (y or [n]) n
> 
> What we'd like to be able to do is:
> 
>         (gdb) b first
>         Breakpoint 1 at 0x804954a: file hello.adb, line 6.
>         (gdb) run
>         Starting program: /home/no-backup/brobecke/ada-fsf/nested/hello 
>         
>         Breakpoint 1, hello.first () at hello.adb:6
>         6          end First;
> 
> To achieve this, we modified dwarf2read to store all Ada subprograms
> in the global scope, even the ones that are not "external". Another
> approach that was considered was to modify the Ada lookup routines
> to extend the search to non-global/static scopes, but I'm concerned
> about performance.
> 
> In practice, even though these routines are indeed local to our
> procedure in the Ada program, we want to be flexible with the user
> in the debugger, and treat these procedures as global, so that the
> user can break inside them without specifying the scope or having
> to be in the scope where the function is defined.

Sorry, I really don't like this idea.  What if you have a hello.first
and a goodbye.first?  They're not related, so a breakpoint on "first"
landing in both spots would be strange.

A related example in C++ would be:

namespace A {
  void first () { }

  void second () { first (); }
}

int main()
{
  A::second ();
}

GDB will not honor "break first" when stopped in main.  But in second,
when the listed source line says "first ();", "break first" will work.
David Carlton did a lot of work to make this happen; the hook it uses
is cp_lookup_symbol_nonlocal.  In practice, it seems to be the
behavior users expect.

-- 
Daniel Jacobowitz
CodeSourcery


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]