]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Ensure class_alias is only used for user-defined aliases.
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 10 May 2020 19:36:14 +0000 (21:36 +0200)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Fri, 15 May 2020 20:17:46 +0000 (22:17 +0200)
This commit finally does the (small) change that started this patch
series.

It ensures that the class_alias is only used for user-defined aliases.
So, the few GDB pre-defined aliases that were using the 'class_alias'
class are now using a real help class, typically the class of
the aliased command.

gdb/ChangeLog

2020-05-15  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* command.h (enum command_class): Improve comments, document
that class_alias is for user-defined aliases, give the class
name for each class, remove unused class_xdb.
* cli/cli-decode.c (add_com_alias): Document THECLASS intended usage.
* breakpoint.c (_initialize_breakpoint): Replace class_alias
by a precise class.
* infcmd.c (_initialize_infcmd): Likewise.
* reverse.c (_initialize_reverse): Likewise.
* stack.c (_initialize_stack): Likewise.
* symfile.c (_initialize_symfile): Likewise.
* tracepoint.c (_initialize_tracepoint): Likewise.

gdb/testsuite/ChangeLog

2020-05-15  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* gdb.base/alias.exp: Verify 'help aliases' shows user defined aliases.

gdb/ChangeLog
gdb/breakpoint.c
gdb/cli/cli-decode.c
gdb/command.h
gdb/infcmd.c
gdb/reverse.c
gdb/stack.c
gdb/symfile.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/alias.exp
gdb/tracepoint.c

index f685addecd1c55e4073f25a2bac45f9f04f81894..8823d23e8032a30d333ead7defe61a1a861a18de 100644 (file)
@@ -1,3 +1,17 @@
+2020-05-15  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
+
+       * command.h (enum command_class): Improve comments, document
+       that class_alias is for user-defined aliases, give the class
+       name for each class, remove unused class_xdb.
+       * cli/cli-decode.c (add_com_alias): Document THECLASS intended usage.
+       * breakpoint.c (_initialize_breakpoint): Replace class_alias
+       by a precise class.
+       * infcmd.c (_initialize_infcmd): Likewise.
+       * reverse.c (_initialize_reverse): Likewise.
+       * stack.c (_initialize_stack): Likewise.
+       * symfile.c (_initialize_symfile): Likewise.
+       * tracepoint.c (_initialize_tracepoint): Likewise.
+
 2020-05-15  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
 
        * cli/cli-decode.c (apropos_cmd): Produce output for aliases
index 480f095876985b4f680a149dc8c7f7df3fcb4d1c..15d76d4a9c15545ab1ac8cb040764a634621eca4 100644 (file)
@@ -15478,7 +15478,7 @@ A disabled breakpoint is not forgotten, but has no effect until re-enabled."),
   add_com_alias ("dis", "disable", class_breakpoint, 1);
   add_com_alias ("disa", "disable", class_breakpoint, 1);
 
-  add_cmd ("breakpoints", class_alias, disable_command, _("\
+  add_cmd ("breakpoints", class_breakpoint, disable_command, _("\
 Disable all or some breakpoints.\n\
 Usage: disable breakpoints [BREAKPOINTNUM]...\n\
 Arguments are breakpoint numbers with spaces in between.\n\
@@ -15498,7 +15498,7 @@ Also a prefix command for deletion of other GDB objects."),
   add_com_alias ("d", "delete", class_breakpoint, 1);
   add_com_alias ("del", "delete", class_breakpoint, 1);
 
-  add_cmd ("breakpoints", class_alias, delete_command, _("\
+  add_cmd ("breakpoints", class_breakpoint, delete_command, _("\
 Delete all or some breakpoints or auto-display expressions.\n\
 Usage: delete breakpoints [BREAKPOINTNUM]...\n\
 Arguments are breakpoint numbers with spaces in between.\n\
@@ -15686,10 +15686,10 @@ BREAK_ARGS_HELP ("trace") "\n\
 Do \"help tracepoints\" for info on other tracepoint commands."));
   set_cmd_completer (c, location_completer);
 
-  add_com_alias ("tp", "trace", class_alias, 0);
-  add_com_alias ("tr", "trace", class_alias, 1);
-  add_com_alias ("tra", "trace", class_alias, 1);
-  add_com_alias ("trac", "trace", class_alias, 1);
+  add_com_alias ("tp", "trace", class_breakpoint, 0);
+  add_com_alias ("tr", "trace", class_breakpoint, 1);
+  add_com_alias ("tra", "trace", class_breakpoint, 1);
+  add_com_alias ("trac", "trace", class_breakpoint, 1);
 
   c = add_com ("ftrace", class_breakpoint, ftrace_command, _("\
 Set a fast tracepoint at specified location.\n\
index 2b24e57d4635206e182f9c706f4f16d2ccaf3475..a4ef93c62b056559c3f018ffca2d68cd126b06cc 100644 (file)
@@ -1006,7 +1006,10 @@ add_com (const char *name, enum command_class theclass,
   return add_cmd (name, theclass, fun, doc, &cmdlist);
 }
 
-/* Add an alias or abbreviation command to the list of commands.  */
+/* Add an alias or abbreviation command to the list of commands.
+   For aliases predefined by GDB (such as bt), THECLASS must be
+   different of class_alias, as class_alias is used to identify
+   user defined aliases.  */
 
 struct cmd_list_element *
 add_com_alias (const char *name, const char *oldname, enum command_class theclass,
index 0a1706c545eecc72631ae44ebc876c6a0bbd4033..04a380cba4aa65f7871069e84e7f30997d02d663 100644 (file)
@@ -29,21 +29,46 @@ struct completion_tracker;
 /* Command classes are top-level categories into which commands are
    broken down for "help" purposes.
 
-   Notes on classes: class_alias is for alias commands which are not
-   abbreviations of the original command.  class-pseudo is for
-   commands which are not really commands nor help topics ("stop").  */
+   The class_alias is used for the user-defined aliases, defined
+   using the "alias" command.
+
+   Aliases pre-defined by GDB (e.g. the alias "bt" of the "backtrace" command)
+   are not using the class_alias.
+   Different pre-defined aliases of the same command do not necessarily
+   have the same classes.  For example, class_stack is used for the
+   "backtrace" and its "bt" alias", while "info stack" (also an alias
+   of "backtrace" uses class_info.  */
 
 enum command_class
 {
-  /* Special args to help_list */
-  class_deprecated = -3, all_classes = -2, all_commands = -1,
+  /* Classes of commands followed by a comment giving the name
+     to use in "help <classname>".
+     Note that help accepts unambiguous abbreviated class names.  */
+
+  /* Special classes to help_list */
+  class_deprecated = -3,
+  all_classes = -2,  /* help without <classname> */
+  all_commands = -1, /* all */
+
   /* Classes of commands */
-  no_class = -1, class_run = 0, class_vars, class_stack, class_files,
-  class_support, class_info, class_breakpoint, class_trace,
-  class_alias, class_bookmark, class_obscure, class_maintenance,
-  class_tui, class_user, class_xdb,
-  no_set_class /* Used for "show" commands that have no corresponding
-                  "set" command.  */
+  no_class = -1,
+  class_run = 0,     /* running */
+  class_vars,        /* data */
+  class_stack,       /* stack */
+  class_files,       /* files */
+  class_support,     /* support */
+  class_info,        /* status */
+  class_breakpoint,  /* breakpoints */
+  class_trace,       /* tracepoints */
+  class_alias,       /* aliases */
+  class_bookmark,
+  class_obscure,     /* obscure */
+  class_maintenance, /* internals */
+  class_tui,
+  class_user,        /* user-defined */
+
+  /* Used for "show" commands that have no corresponding "set" command.  */
+  no_set_class
 };
 
 /* FIXME: cagney/2002-03-17: Once cmd_type() has been removed, ``enum
index 8b01f45828e8424b17e0fa9286e27985616d9204..32905a7b591e8d3d5b108d2e42a61e76d2433c0c 100644 (file)
@@ -3180,7 +3180,7 @@ is restored."),
   cmd_name = "inferior-tty";
   c = lookup_cmd (&cmd_name, setlist, "", -1, 1);
   gdb_assert (c != NULL);
-  add_alias_cmd ("tty", c, class_alias, 0, &cmdlist);
+  add_alias_cmd ("tty", c, class_run, 0, &cmdlist);
 
   cmd_name = "args";
   add_setshow_string_noescape_cmd (cmd_name, class_run,
@@ -3318,14 +3318,14 @@ Step one instruction exactly.\n\
 Usage: stepi [N]\n\
 Argument N means step N times (or till program stops for another \
 reason)."));
-  add_com_alias ("si", "stepi", class_alias, 0);
+  add_com_alias ("si", "stepi", class_run, 0);
 
   add_com ("nexti", class_run, nexti_command, _("\
 Step one instruction, but proceed through subroutine calls.\n\
 Usage: nexti [N]\n\
 Argument N means step N times (or till program stops for another \
 reason)."));
-  add_com_alias ("ni", "nexti", class_alias, 0);
+  add_com_alias ("ni", "nexti", class_run, 0);
 
   add_com ("finish", class_run, finish_command, _("\
 Execute until selected stack frame returns.\n\
index 1ccb9d27971928f55f62220909708a1c9ec0a4d7..583e0d02da2150dbc87aae5bb711af5b8960cc13 100644 (file)
@@ -330,7 +330,7 @@ _initialize_reverse ()
 Step program backward until it reaches the beginning of another source line.\n\
 Argument N means do this N times (or till program stops for another reason).")
           );
-  add_com_alias ("rs", "reverse-step", class_alias, 1);
+  add_com_alias ("rs", "reverse-step", class_run, 1);
 
   add_com ("reverse-next", class_run, reverse_next, _("\
 Step program backward, proceeding through subroutine calls.\n\
@@ -338,26 +338,26 @@ Like the \"reverse-step\" command as long as subroutine calls do not happen;\n\
 when they do, the call is treated as one instruction.\n\
 Argument N means do this N times (or till program stops for another reason).")
           );
-  add_com_alias ("rn", "reverse-next", class_alias, 1);
+  add_com_alias ("rn", "reverse-next", class_run, 1);
 
   add_com ("reverse-stepi", class_run, reverse_stepi, _("\
 Step backward exactly one instruction.\n\
 Argument N means do this N times (or till program stops for another reason).")
           );
-  add_com_alias ("rsi", "reverse-stepi", class_alias, 0);
+  add_com_alias ("rsi", "reverse-stepi", class_run, 0);
 
   add_com ("reverse-nexti", class_run, reverse_nexti, _("\
 Step backward one instruction, but proceed through called subroutines.\n\
 Argument N means do this N times (or till program stops for another reason).")
           );
-  add_com_alias ("rni", "reverse-nexti", class_alias, 0);
+  add_com_alias ("rni", "reverse-nexti", class_run, 0);
 
   add_com ("reverse-continue", class_run, reverse_continue, _("\
 Continue program being debugged but run it in reverse.\n\
 If proceeding from breakpoint, a number N may be used as an argument,\n\
 which means to set the ignore count of that breakpoint to N - 1 (so that\n\
 the breakpoint won't break until the Nth time it is reached)."));
-  add_com_alias ("rc", "reverse-continue", class_alias, 0);
+  add_com_alias ("rc", "reverse-continue", class_run, 0);
 
   add_com ("reverse-finish", class_run, reverse_finish, _("\
 Execute backward until just before selected stack frame is called."));
index f67a151aeee96f45bdebeae6f9e96c1def4d58c9..d7e21205411afe746708e8da77d7786890dd8b83 100644 (file)
@@ -3485,7 +3485,7 @@ With a negative COUNT, print outermost -COUNT frames."),
 
   add_com_alias ("bt", "backtrace", class_stack, 0);
 
-  add_com_alias ("where", "backtrace", class_alias, 0);
+  add_com_alias ("where", "backtrace", class_stack, 0);
   add_info ("stack", backtrace_command,
            _("Backtrace of the stack, or innermost COUNT frames."));
   add_info_alias ("s", "stack", 1);
index 7c862d5513a276365614751d3decd030ccabe04d..946443f07a89a911dc79ff67c19140553372a8ec 100644 (file)
@@ -3906,8 +3906,8 @@ on its own."), &cmdlist);
                        _("Commands for debugging overlays."), &overlaylist,
                        "overlay ", 0, &cmdlist);
 
-  add_com_alias ("ovly", "overlay", class_alias, 1);
-  add_com_alias ("ov", "overlay", class_alias, 1);
+  add_com_alias ("ovly", "overlay", class_support, 1);
+  add_com_alias ("ov", "overlay", class_support, 1);
 
   add_cmd ("map-overlay", class_support, map_overlay_command,
           _("Assert that an overlay section is mapped."), &overlaylist);
index bf2b9384d26cc9f0a105df56c78d9904d4c46376..c57ddf55cbfc7f986d751fc83d066395d95a9856 100644 (file)
@@ -1,3 +1,7 @@
+2020-05-15  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
+
+       * gdb.base/alias.exp: Verify 'help aliases' shows user defined aliases.
+
 2020-05-15  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
 
        * gdb.base/help.exp: Test apropos and help for commands
@@ -8,7 +12,7 @@
 
        * gdb.base/alias.exp: Update help output check.
 
-c2020-05-15  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
+2020-05-15  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
 
        * gdb.base/default.exp: Update output following fixes.
 
index 69cfde67c14ad57f19ecd3a9f1daee42d0ec4883..6993d426484a5166370e7c7eb2aa2cce8f1e3e64 100644 (file)
@@ -122,3 +122,6 @@ gdb_test_no_output "alias abcd  = backtrace"
 gdb_test_no_output "alias abcde = backtrace"
 gdb_test_no_output "alias fghij = backtrace"
 gdb_test_no_output "alias fghi  = backtrace"
+
+# Verify help aliases shows the user defined aliases
+gdb_test "help aliases" ".*abcd --.*.*abcde --.*"
index 2e0f0df9ff4cca2f5810113a9e989614987fa34a..f4a208f616926bb6728fb15442e8495e96f39787 100644 (file)
@@ -4098,8 +4098,8 @@ one or more \"collect\" commands, to specify what to collect\n\
 while single-stepping.\n\n\
 Note: this command can only be used in a tracepoint \"actions\" list."));
 
-  add_com_alias ("ws", "while-stepping", class_alias, 0);
-  add_com_alias ("stepping", "while-stepping", class_alias, 0);
+  add_com_alias ("ws", "while-stepping", class_trace, 0);
+  add_com_alias ("stepping", "while-stepping", class_trace, 0);
 
   add_com ("collect", class_trace, collect_pseudocommand, _("\
 Specify one or more data items to be collected at a tracepoint.\n\