[RFAv8 0/3] Allow the user to define default args for aliases

Philippe Waroquiers philippe.waroquiers@skynet.be
Sun Jun 21 18:31:27 GMT 2020


Allow the user to define default args for user-defined aliases.

This is version 8 of the patch series.
The documentation (NEWS and gdb.texinfo) should be re-reviewed,
as default-args are now only provided by the 'alias' command.

Compared to version 7 and 6:
It removes the commands 'set|show default-args' as these could introduce
a future backward incompatibility if alias expansion would be done
dynamically by GDB when executing the alias.
For the same reason, it implements the prevention of defining an alias
of an alias having default args, as suggested by Simon.
This prevention is implemented in cli-cmds.c validate_aliased_command
(which is valid_command_p renamed and modified).

The default-args.exp test was enhanced to test this prevention.
When relevant, the 'set/show default-args' have been converted to
use the 'alias' command or 'help aliases'.

The version 6 of the patch series did the following changes,
compared to the previous version:
  * it handles the comment of Simon that default args should only
    be available for user-defined aliases and not for GDB commands
    and GDB pre-defined aliases.
    As default args are now only for user-defined aliases,
    the 'show/set enable-default-args [on|off]' commands have been
    removed.
  * documentation changed accordingly.
  * help and apropos now shows the full definition of the aliases having
    default args.

Previous versions handled the comments of Christian/Eli/Pedro/Tom/Simon.

This patch series changes the alias command to be:
  alias [-a] [--] ALIAS = COMMAND [DEFAULT-ARGS...]


Using the above default-args, you can define powerful aliases.

For example:

  alias bt_ALL = backtrace -entry-values both -frame-arg all -past-main -past-entry -full

defines the alias bt_ALL that will give as much information as possible
in a backtrace.

Default args can usefully be combined with the 'with' command, such as:

Make "wLapPeu" an alias of 2 nested "with":
  alias wLapPeu = with language pascal -- with print elements unlimited --

or have an alias pp10 to pretty print an expression with a maximum of
10 elements:

  alias pp10 = with print pretty -- with print elem 10 -- print

This patch series also adds a completer for 'alias'.




More information about the Gdb-patches mailing list