From 19c659f164b9dc672580ec459c9cfef84dd0f879 Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Thu, 10 Dec 2020 16:03:31 +0000 Subject: gdb: improve the warning given for deprecated aliases with a prefix Consider this GDB session: (gdb) define set xxx_yyy Type commands for definition of "set xxx_yyy". End with a line saying just "end". >echo in set xxx_yyy command\n >end (gdb) alias set qqq_aaa=set xxx_yyy (gdb) maintenance deprecate set qqq_aaa (gdb) set qqq_aaa Warning: 'qqq_aaa', an alias for the command 'xxx_yyy' is deprecated. No alternative known. in set xxx_yyy command (gdb) Notice the warning mentions 'qqq_aaa' and 'xxx_yyy', I consider this to be wrong. I think the proper warning should read: (gdb) set qqq_aaa Warning: 'set qqq_aaa', an alias for the command 'set xxx_yyy', is deprecated. No alternative known. With the 'set' prefixes added and a comma before the final 'is deprecated'. That is what this patch does. The expected results are updated as needed. gdb/ChangeLog: * cli/cli-decode.c (deprecated_cmd_warning): Ignore the prefix result from lookup_cmd_composition_1, use the prefixes from both the command and the alias instead. (lookup_cmd_composition_1): Initial prefix command is the based on the search list being passed in. Simplify the logic for tracking the prefix command. Replace a use of alloca with a local std::string. gdb/testsuite/ChangeLog: * gdb.base/commands.exp: Update expected results. --- gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.base/commands.exp | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'gdb/testsuite') diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 0eb3ce6..5796e61 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2020-12-11 Andrew Burgess + * gdb.base/commands.exp: Update expected results. + +2020-12-11 Andrew Burgess + PR cli/15104 * gdb.base/commands.exp: Add additional tests. * gdb.base/completion.exp: Add additional tests. diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp index 19f712c..f621815 100644 --- a/gdb/testsuite/gdb.base/commands.exp +++ b/gdb/testsuite/gdb.base/commands.exp @@ -663,7 +663,7 @@ proc_with_prefix deprecated_command_test {} { gdb_test_no_output "maintenance deprecate p \"new_p\"" "maintenance deprecate p \"new_p\" /1/" gdb_test "p 5" \ - "Warning: 'p', an alias for the command 'print' is deprecated.*Use 'new_p'.*" \ + "Warning: 'p', an alias for the command 'print', is deprecated.*Use 'new_p'.*" \ "p deprecated warning, with replacement" gdb_test "p 5" ".\[0-9\]* = 5.*" "deprecated warning goes away /1/" @@ -704,7 +704,7 @@ maintenance deprecate set qqq_aaa" gdb_test_no_output "source $file1" \ "source file containing xxx_yyy command and its alias" gdb_test "set qqq_aaa" \ - "Warning: 'qqq_aaa', an alias for the command 'xxx_yyy' is deprecated\\.\r\n.*No alternative known\\..*" \ + "Warning: 'set qqq_aaa', an alias for the command 'set xxx_yyy', is deprecated\\.\r\n.*No alternative known\\..*" \ "deprecated alias with prefix give a warning" file delete $file1 -- cgit v1.1