[RFAv6 1/3] default-args: allow to define default arguments for aliases

Philippe Waroquiers philippe.waroquiers@skynet.be
Tue Jun 9 19:49:00 GMT 2020


Hello Simon,

On Mon, 2020-06-08 at 17:28 -0400, Simon Marchi wrote:
> I don't remember if we talked about this earlier... but is this
> the expected behavior when using an alias to define another alias?

This point was not discussed but is the consequence of GDB
resolving an alias to point at the (end/final) command it is
aliasing, and e.g. not mplementing an alias as a kind of textual
replacement.
When asking the list of aliases, it similarly shows the 'final'
command it is aliasing, and not the alias that was used 
in the definition.

(gdb) alias aaa = echo bonjour
(gdb) alias bbb = aaa coucou
(gdb) help aliases
User-defined aliases of other commands.

List of commands:

aaa -- Print a constant string.  Give string as argument.
  alias aaa = echo bonjour
bbb -- Print a constant string.  Give string as argument.
  alias bbb = echo coucou

We might explicit this behaviour in the user manual.
(it might be possible to re-implement aliases as textual
replacement but that is a major rework, e.g. the
chain of aliases of a command has to be replaced
by something else, the aliased_command pointer is to point
at another chain of aliases, that must be evaluated "dynamically"
when executing the command, rather than resolved at definition time.


Note that GDB and a shell are already very different beasts
on many aspects e.g. :
  (gdb) set $xxx = "coucou"
  (gdb) echo $xxx
  $xxx(gdb) p $xxx
  $1 = "coucou"
  (gdb) 



> > +  if (*text == nullptr || skip_spaces (*text) == nullptr)
> > +    error (_("COMMAND missing."));
> 
> This should say ALIAS, since it says ALIAS in "help set default-args".
That is a left over of the version that allowed default args for
commands.  I will fix this.

Thanks for the comments

Philippe





More information about the Gdb-patches mailing list