This is the mail archive of the 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]

[RFC/RFA] handle function homonyms in breakpoint expressions


The problem I am trying to fix is the following. Imagine we have
the following two functions defined:

    procedure Next (I : in out Integer);
    procedure Next (F : in out Float);

If the user tries to break on "Next", then the expression is ambiguous
and GDB should present a multiple-choice menu and ask the user to choose:

    (gdb) b next
    [0] cancel
    [1] all
    [2] at pck.adb:5
    [3] at pck.adb:10

This is a part of the Ada support that we haven't contributed yet.
The way we've done it is still perfectible, hence the RFC, which
I hope will turn into a RFA ;-). Right now, the debugger simply
breaks on one function chosen at random.

Paul Hilfinger is actually the engineers who knows this code best,
but it seems to me that the breakpoint expression parsing for Ada
needs to do a lot of specific things. We have some issues related
to homonyms, which is the object of this patch, but also with
runtime functions, internally-generated routines (by the expander),
etc. As a result, I think that the chances of merging the Ada-specific
part inside the general linespec.c code are pretty slim.

So, my conclusion when I looked at the code is that this patch looks
like a good starting point to introduce the feature above. The idea
is to short-circuit the end of decode_line_1 and call the Ada-specific
part instead, like so:

   else if (current_language->la_language == language_ada)
       return ada_finish_decode_line_1 (argptr, file_symtab, funfirstline,
                                        canonical, not_found_ptr);

The only part that I am questioning a bit is when the user selects
"all", because it results in the insertion of several breakpoints.
We do not end up with one logical breakpoint with several physical
locations, but instead with several logical breakpoints. This is because
we have been doing it this way in the AdaCore debugger. We will change
it eventually to better match the general model, but I think this is a
minor detail that can wait while we quickly bring the Ada support up to
par with AdaCore's debugger. At least the users now have access to the

So, if the idea is approved, I can apply the attached patch, and
work on making a testcase for it.

2008-01-01  Joel Brobecker  <>

        * ada-lang.c (get_selections): Set prompt explicitly when calling
        command_line_input, or it will print the GDB prompt.
        (can_use_symbol_on_breakpoint, discard_non_breakpoint_matches)
        (ada_finish_decode_line_1, find_sal_from_funcs_and_line)
        (find_line_in_linetable, nearest_line_number_in_linetable)
        (find_next_line_in_linetable, is_plausible_func_for_line)
        (read_all_symtabs, ada_sals_for_line, extended_canonical_line_spec)
        (adjust_pc_past_prologue): New functions.
        * ada-lang.h (ada_finish_decode_line_1): Update profile.
        * linespec.c: #include ada-lang.h.
        (decode_line_1): Add call to ada_finish_decode_line_1.
        * (linespec.o): Update dependencies.

Tested on x86-linux. No regression.


Attachment: homonym.diff
Description: Text document

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