diff options
author | Pierre-Marie de Rodat <derodat@adacore.com> | 2015-08-31 16:04:07 +0200 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2015-09-01 14:54:19 +0200 |
commit | dc5c874652de144c5ab05d11e85013b568678039 (patch) | |
tree | 909e35303e8559e990182956fdeb5e888900d209 /gdb/ada-lang.c | |
parent | 04ebc307f9601168c165fb63aa39a676e45454b7 (diff) | |
download | binutils-gdb-dc5c874652de144c5ab05d11e85013b568678039.tar.gz |
[Ada] Fix completion for multiple function matches
Before this change, trying to complete an expression ending with an
ambiguous function name (i.e. for which there are multiple matches)
would display a menu with a prompt for the user to pick one. For
instance:
(gdb) p func<tab>Multiple matches for func
[0] cancel
[1] pack2.func at pack2.adb:5
[2] pack.func at pack.adb:5
>
This is not user friendly and actually triggered a segmentation fault
after the user did pick one. It is not clear whether the segmentation
fault needs a separate fix, but this is the only known case which
exhibits it at the moment, and this case must be fixed itself.
The problem lies in ada-lang.c (ada_resolve_function): when we got
multiple matches, we should not display the menu if we are in completion
mode. This patch adjusts the corresponding condition accordingly.
gdb/ChangeLog:
* ada-lang.c (ada_resolve_function): Do not ask the user what
match to use when in completion mode.
gdb/testsuite/ChangeLog:
* gdb.ada/complete.exp: Add "pck.ambiguous_func" to the relevant
expected outputs. Add two testcases for completing ambiguous
functions.
* gdb.ada/complete/aux_pck.adb: New file.
* gdb.ada/complete/aux_pck.ads: New file.
* gdb.ada/complete/foo.adb: Pull Aux_Pck and call the two
Ambiguous_Func functions.
* gdb.ada/complete/pck.ads: Add an Ambiguous_Func function.
* gdb.ada/complete/pck.adb: Likewise.
Tested on x86_64-linux, no regression.
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r-- | gdb/ada-lang.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 7e6b6dcaeb0..a7809ffc2c0 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -3655,9 +3655,13 @@ ada_resolve_function (struct block_symbol syms[], } } + /* If we got multiple matches, ask the user which one to use. Don't do this + interactive thing during completion, though, as the purpose of the + completion is providing a list of all possible matches. Prompting the + user to filter it down would be completely unexpected in this case. */ if (m == 0) return -1; - else if (m > 1) + else if (m > 1 && !parse_completion) { printf_filtered (_("Multiple matches for %s\n"), name); user_select_syms (syms, m, 1); |