From 1536146f30900b77c8381930669532f4073df196 Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Tue, 8 Dec 2020 17:32:34 +0000 Subject: gdb: don't warn about deprecated aliases during tab completion Consider this gdb session, where on line #3 tab completion is used: (gdb) alias xxx_yyy_zzz=break (gdb) maint deprecate xxx_yyy_zzz (gdb) xxx_yyy_ The third line then updates to look like this: (gdb) xxx_yyy_Warning: 'xxx_yyy_zzz', an alias for the command 'break' is deprecated. No alternative known. zzz What's happened is during tab completion the alias has been resolved to the actual command being aliased, and at this stage the warning is issued. Clearly this is not what we want during tab completion. In this commit I add a new parameter to the lookup function, a boolean that indicates if the lookup is being done as part of completion. This flag is used to suppress the warning. Now we get the expected behaviour, the alias completes without any warning, but the warning is still given once the user executes the alias. gdb/ChangeLog: * cli/cli-decode.c (lookup_cmd_1): Move header comment into command.h, add extra parameter, and use this to guard giving a warning. * command.h (lookup_cmd_1): Add comment from cli/cli-decode.c, include argument names in declaration, add new argument. * completer.c (complete_line_internal_1): Remove unneeded brackets, pass extra argument to lookup_cmd_1. gdb/testsuite/ChangeLog: * gdb.base/completion.exp: Add additional tests. --- gdb/completer.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'gdb/completer.c') diff --git a/gdb/completer.c b/gdb/completer.c index 7f63ced..4c1ad25 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -1388,9 +1388,8 @@ complete_line_internal_1 (completion_tracker &tracker, result_list = 0; } else - { - c = lookup_cmd_1 (&p, cmdlist, &result_list, NULL, ignore_help_classes); - } + c = lookup_cmd_1 (&p, cmdlist, &result_list, NULL, ignore_help_classes, + true); /* Move p up to the next interesting thing. */ while (*p == ' ' || *p == '\t') -- cgit v1.1