[RFA,00/10] fix/improve cmd structure, class_alias, help, apropos

Message ID 20200510205530.21923-1-philippe.waroquiers@skynet.be
Headers show
  • fix/improve cmd structure, class_alias, help, apropos
Related show


Hannes Domani via Gdb-patches May 10, 2020, 8:55 p.m.
This patch series started with the objective to cleanup the 'class_alias'
usages, so as to have this class only used for user-defined aliases.

While doing the above change, various problems were then discovered in the
command list structure and command help.

So, this patch series fixes these problems, to end up with the
removal of the usage of 'class_alias' for the aliases predefined
by GDB.

Using 'class_alias' only for user-defined aliases was deemed the best approach
to handle the comment of Simon related to "default args for commands and
aliases" that pre-defined commands and aliases should not have their default
changeable via default args. Otherwise, the user would be confused by having
e.g. 'backtrace' and 'bt' behaving differently, while most users
will assume these are the same commands.
So, the patch series "default args for commands and aliases" must differentiate
predefined aliases from user defined aliases, and the idea is to reserve
class_alias for these user-defined aliases.

Note that the concept of command classes in GDB is only used for
the help system:  typing "help" without arguments gives a list of
command classes.  Typing "help <classname>" is (supposed to) list
the commands having that class.

"help aliases" is today giving a very strange functionality.
It only shows a very small subset of the GDB predefined aliases
(e.g. it shows none of the abbreviation aliases) and does
not show some other aliases (such as 'disable breakpoints').
Various other strange behaviour such as: when defining the alias:
   alias deactive = disable
then 'help aliases' shows this new alias (this is normal)
but also starts to show a whole bunch of 'disable' subcommands,
which is all pretty useless in the list of aliases:

  (gdb) help aliases
  Aliases of other commands.

  List of commands:

  deactive -- Disable all or some breakpoints.
  disable breakpoints -- Disable all or some breakpoints.
  disable display -- Disable some expressions to be displayed when program stops.
  disable frame-filter -- GDB command to disable the specified frame-filter.
So, a bunch of "disable" subcommands are appearing due to that.
It is interesting to try "help aliases" after having done:
  "alias is = info set"

So, the idea is to only show the user defined aliases in "help aliases",
and show the predefined aliases together with the help of the command
they are aliasing.
This is deemed to help the user to see how to use aliases to type faster
the commands they are asking some help for, compared to the current
very partial list of aliases shown by "help aliases".

Note that if deemed necessary, we could implement a (fake) class
  "help predefined-aliases"
that would show the GDB predefined aliases, if ever that would be
deemed needed.

Note also that only remaining usage of 'abbreviation alias' concept is
to avoid completion proposing an abbreviation alias.  The other usage
to not shown an alias in the GDB help system is not needed anymore,
as now aliases and abbreviations are shown as part of the aliased
command help.