[RFA 0/3] Allow the user to define default leading args for commands and aliases

Philippe Waroquiers philippe.waroquiers@skynet.be
Mon Jun 24 23:11:00 GMT 2019


Allow the user to define default leading args for commands and aliases.

This patch series implements, tests and documents the following commands:

  set leading-args COMMAND [= LEADING-ARGS...]
  show leading-args [COMMAND]
  set enable-leading-args [on|off]
  show enable-leading-args


It also changes the alias command to be:
  alias [-a] [--] ALIAS = COMMAND [= LEADING-ARGS...]


Using the above leading-args commands and arguments, you can
define default arguments for commands or 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.

Leading args can usefully be combined with the (soon to be pushed I hope)
'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'.


Note 1: a preliminary version of this idea (using a command called
'add-args' was discussed in
https://sourceware.org/ml/gdb-patches/2019-06/msg00395.html
where Tom suggested to make it more GDB like, using 'set' command.

Note 2: I have made the '=' character mandatory in the 'set leading-args'
command to be sure to unambiguously separate the COMMAND from the
specified leading args.

Also, an '=' character must be specified in the alias command before
the LEADING-ARGS for consistency with set leading-args.
This also ensures that the user cannot type a wrong command name
that would be interpreted as leading args and/or cause 'mismatch'
of length between ALIAS and COMMAND
(see https://sourceware.org/ml/gdb-patches/2019-06/msg00459.html
[RFA] Fix alias command not detecting non matching prefix & sometimes asserting.).




More information about the Gdb-patches mailing list