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]

[RFA/dwarf] save nested Ada subprograms as global symbol


Hello,

This is part of what I hope will be a string of patches that should
bring the GDB close to the AdaCore version of GDB in terms of Ada support.
My hope is to find the time this year to reach that level, which
would then make it easier for us to keep Ada support between our tree
and the FSF tree synchronized.

The Ada language provides support for nested subprograms. Consider
the following simple program:

        procedure Hello is
        
           procedure First is
           begin
              null;
           end First;
        
           procedure Second is
           begin
              First;
           end Second;
        
           procedure Third is
           begin
              Second;
           end Third;
        
        begin
           Third;
        end Hello;

This is a trivial program, where the main procedure (Hello) contains
three nested procedures (Third, Second, and First). To compile it,
do the following:

        % gnatmake -g hello

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.

This is what the attached patch does:

2007-12-27  Joel Brobecker  <brobecker@adacore.com>

        * dwarf2read.c (add_partial_symbol): Always store all Ada subprograms
        in the global scope.
        (new_symbol): Likewise.

Tested on x86-linux, no regression.  OK to commit?

I am also attaching a testcase that fails without this patch:

2007-12-27  Joel Brobecker  <brobecker@adacore.com>

        * gdb.ada/nested/hello.adb: New file.
        * gdb.ada/nested.exp: New testcase.
        * gdb.ada/Makefile.in (EXECUTABLES): Update list.

Tested on x86-linux as well.

Thanks,
-- 
Joel

Attachment: TAG_subprogram.diff
Description: Text document

Attachment: hello.adb
Description: Text document

Attachment: nested.exp
Description: Text document

Attachment: gdb.ada-makefile.in.diff
Description: Text document


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