commit 0eec4d84f57d5a214e00f3186f38d3af07584d86
Author: Jerome Guitton <guitton@adacore.com>
Date: Tue Jan 10 15:10:08 2017 +0100
[RFA] candidates for ambiguous command in upper case
If you type an ambiguous command in lower case, gdb tells the command
is ambiguous and tells you which one could match. If you type the same
but in upper case, gdb also says it is ambiguous, but shows an empty
list of commands:
(gdb) ex
Ambiguous command "ex": exec-file, expression.
(gdb) EX
Ambiguous command "EX": .
The same issue with completion.
(gdb) inf<tab><tab>
shows "inferior info", but
(gdb) INF<tab><tab>
shows nothing.
Simple fix in attachment, with an additional test.
Tested on x86-linux. OK to apply?
gdb/ChangeLog:
* cli-decode.c (lookup_cmd): case insensitive match when looking
up candidates for ambiguous command.
(complete_on_cmdlist): Ditto.
gdb/testsuite/ChangeLog:
* gdb.base/completion.exp: Add tests for completion of upper case
commands.
@@ -1550,7 +1550,7 @@ lookup_cmd (const char **line, struct cmd_list_element *list, char *cmdtype,
ambbuf[0] = 0;
for (c = local_list; c; c = c->next)
- if (!strncmp (*line, c->name, amb_len))
+ if (!strncasecmp (*line, c->name, amb_len))
{
if (strlen (ambbuf) + strlen (c->name) + 6
< (int) sizeof ambbuf)
@@ -1800,7 +1800,7 @@ complete_on_cmdlist (struct cmd_list_element *list,
for (pass = 0; matchlist == 0 && pass < 2; ++pass)
{
for (ptr = list; ptr; ptr = ptr->next)
- if (!strncmp (ptr->name, text, textlen)
+ if (!strncasecmp (ptr->name, text, textlen)
&& !ptr->abbrev_flag
&& (!ignore_help_classes || ptr->func
|| ptr->prefixlist))
@@ -30,6 +30,8 @@
# "info t foo" no completions
# "info t " no completions
# "info t" ambiguous ("info target", "info terminal", etc.)
+# "info T" ambiguous ("info target", "info terminal", etc.)
+# "info TERMINA" unambiguous (completes to "info terminal")
# "info ajksdlfk" no completions
# "info ajksdlfk " no completions
# "info" " "
@@ -265,6 +267,32 @@ gdb_test_multiple "" "$test" {
}
}
+set test "complete 'info T '"
+send_gdb "info T \t"
+gdb_test_multiple "" "$test" {
+ -re "^info T \\\x07$" {
+ send_gdb "\n"
+ gdb_test_multiple "" "$test" {
+ -re "Ambiguous info command \"T \": target, tasks, terminal, threads, tp, tracepoints, tvariables, (type-printers, )?types\\..*$gdb_prompt $" {
+ pass "$test"
+ }
+ }
+ }
+}
+
+set test "complete 'info TERMINA'"
+send_gdb "info TERMINA\t"
+gdb_test_multiple "" "$test" {
+ -re "^info TERMINAterminal $" {
+ send_gdb "\n"
+ gdb_test_multiple "" "$test" {
+ -re "Inferior's terminal status.*$gdb_prompt $" {
+ pass "$test"
+ }
+ }
+ }
+}
+
set test "complete 'info t '"
send_gdb "info t \t"
gdb_test_multiple "" "$test" {