diff options
author | Philippe Waroquiers <philippe.waroquiers@skynet.be> | 2020-05-10 18:31:03 +0200 |
---|---|---|
committer | Philippe Waroquiers <philippe.waroquiers@skynet.be> | 2020-05-15 22:17:45 +0200 |
commit | 3b3aaacba15292f185b6e8ba5faba1ed89c9f908 (patch) | |
tree | 3ec3b1d2428a008bfa70aea3f6dacdd30b269943 /gdb/testsuite | |
parent | 7aa1b46f4321eb2c2054c4d8985f2d8e3c18aa36 (diff) | |
download | gdb-3b3aaacba15292f185b6e8ba5faba1ed89c9f908.zip gdb-3b3aaacba15292f185b6e8ba5faba1ed89c9f908.tar.gz gdb-3b3aaacba15292f185b6e8ba5faba1ed89c9f908.tar.bz2 |
Fix/improve 'help CLASS' output
Currently, help CLASS possibly shows several times the same help,
as it shows it once for the command, and once for each alias.
The final objective of this patch series is to have class_alias used only
for user defined aliases, not anymore for aliases predefined by GDB.
The command 'help aliases' will then only show the user defined aliases.
So, the idea is that GDB predefined aliases will be shown together
with their aliased command.
This commit changes 'help CLASS' so that a command is shown once in the output,
with all its aliases.
This ensures:
* that the user has only to read once the same help text
* and sees the command and all its aliases in a glance, a.o. allowing
the user to choose the preferred way (e.g. the shortest one,
or the most mnemonic one) to type the command.
For example, the old output:
(gdb) help stack
...
List of commands:
backtrace -- Print backtrace of all stack frames, or innermost COUNT frames.
bt -- Print backtrace of all stack frames, or innermost COUNT frames.
...
(note that 'where' is not shown in this output)
becomes
(gdb) help stack
...
List of commands:
backtrace, where, bt -- Print backtrace of all stack frames, or innermost COUNT frames.
...
The output layout chosen is to have the command first, followed by all its
aliases separated by a comma. Note that the command and alias names are
title-styled. For sure, other layouts could be discussed, but this one is IMO
readable and compact.
The function 'help_cmd_list' can be simplified by removing the prefix argument,
as the prefixname of a command can now be retrieved in the GDB command tree
structure.
This also fixes the fact that 'help aliases' wrongly shows a long
list of (non-alias) when defining an alias for a prefix command.
For example, after:
(gdb) alias montre = show
then
(gdb) help aliases
shows hundreds of sub-commands starting with the non aliased command,
such as:
montre -- Generic command for showing things about the debugger.
show ada -- Generic command for showing Ada-specific settings.
show ada print-signatures -- Show whether the output of formal ...
....
'help_cmd_list' is also made static, as it is only used inside cli-decode.c.
Note that the 'help CLASS' is somewhat broken, in the sense that it
sometimes shows too many commands (commands not belonging to CLASS)
and sometimes shows not enough commands (not showing some commands
belonging to CLASS).
For example, 'help breakpoints' shows the command
'disable pretty-printer' and 'disable unwinder', not related to breakpoints.
On the other end, 'help stack' does not show 'disable unwinder'
while 'disable unwinder' is defined in unwinders.py as belonging to class_stack.
Fixing the missing commands is easy to do,
but fixing the excess commands is not straightforward, as many
subcommands have a class 'no_class' or 'all_class'.
Possibly, some of this might be improved/fixed in another patch series.
With this patch series, the 'abbrev flag' has as only remaining purpose
to avoid having the abbreviation alias appearing in the completion list,
so change 'help alias' accordingly.
gdb/ChangeLog
2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* cli/cli-decode.h (help_cmd_list): Remove declaration.
* cli/cli-decode.c (help_cmd_list): Declare as static,
remove prefix argument, use bool for recurse arg, rework to show the aliases of
a command together with the command.
(fput_command_name_styled, fput_command_names_styled): New functions.
(print_help_for_command): Remove prefix arg, use bool for recurse arg, use
fput_command_name_styled.
(help_list, help_all): Update callers to remove prefix arg and use bool recurse.
* cli/cli-cmds.c (_initialize_cli_cmds): Update alias_command doc.
gdb/testsuite/ChangeLog
2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.base/alias.exp: Update help output check.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/alias.exp | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index bff0ad0..36afa3d 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: Update help output check. + +c2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be> + * gdb.base/default.exp: Update output following fixes. 2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be> diff --git a/gdb/testsuite/gdb.base/alias.exp b/gdb/testsuite/gdb.base/alias.exp index 9a95576..69cfde6 100644 --- a/gdb/testsuite/gdb.base/alias.exp +++ b/gdb/testsuite/gdb.base/alias.exp @@ -65,7 +65,7 @@ gdb_test "show print elements" "Limit .* is 50\[.\]" "verify spe" gdb_test_no_output "alias set pr elms = set p elem" gdb_test_no_output "set pr elms 51" gdb_test "show print elements" "Limit .* is 51\[.\]" "verify set pr elms" -gdb_test "help set print" "set print elms .*" +gdb_test "help set print" "set print elements, set print elms, spe .*" # Verify alias command detects a non existing prefix. gdb_test "alias assigne imprime limite-elements = set print elements" \ |