aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>2020-05-10 21:36:14 +0200
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>2020-05-15 22:17:46 +0200
commit57b4f16e494d8abdeb0748c69e72f911b3525b44 (patch)
treedfc66c3910d9bce236f778816771264549e74372 /gdb
parent7c05caf72d31d7382819f1113fdcf13c45729a8d (diff)
downloadgdb-57b4f16e494d8abdeb0748c69e72f911b3525b44.zip
gdb-57b4f16e494d8abdeb0748c69e72f911b3525b44.tar.gz
gdb-57b4f16e494d8abdeb0748c69e72f911b3525b44.tar.bz2
Ensure class_alias is only used for user-defined aliases.
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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog14
-rw-r--r--gdb/breakpoint.c12
-rw-r--r--gdb/cli/cli-decode.c5
-rw-r--r--gdb/command.h47
-rw-r--r--gdb/infcmd.c6
-rw-r--r--gdb/reverse.c10
-rw-r--r--gdb/stack.c2
-rw-r--r--gdb/symfile.c4
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.base/alias.exp3
-rw-r--r--gdb/tracepoint.c4
11 files changed, 81 insertions, 32 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f685add..8823d23 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,19 @@
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
when their aliased command is traversed.
(help_cmd): Add fput_command_names_styled call to
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 480f095..15d76d4 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -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\
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 2b24e57..a4ef93c 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -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,
diff --git a/gdb/command.h b/gdb/command.h
index 0a1706c..04a380c 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -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
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 8b01f45..32905a7 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -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\
diff --git a/gdb/reverse.c b/gdb/reverse.c
index 1ccb9d2..583e0d0 100644
--- a/gdb/reverse.c
+++ b/gdb/reverse.c
@@ -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."));
diff --git a/gdb/stack.c b/gdb/stack.c
index f67a151..d7e2120 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -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);
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 7c862d5..946443f 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -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);
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index bf2b938..c57ddf5 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,9 @@
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
having aliases. Fixed comments not starting with an
upper-case letter or not finishing with a dot.
@@ -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.
diff --git a/gdb/testsuite/gdb.base/alias.exp b/gdb/testsuite/gdb.base/alias.exp
index 69cfde6..6993d42 100644
--- a/gdb/testsuite/gdb.base/alias.exp
+++ b/gdb/testsuite/gdb.base/alias.exp
@@ -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 --.*"
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 2e0f0df..f4a208f 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -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\