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

Philippe Waroquiers philippe.waroquiers@skynet.be
Sun Jun 21 11:48:45 GMT 2020


On Sat, 2020-06-20 at 15:24 -0400, Simon Marchi wrote:
> On 2020-06-14 12:39 p.m., Philippe Waroquiers via Gdb-patches wrote:
> > Allow the user to define default args for user-defined aliases.
> > 
> > This is version 7 of the patch series.
> > Compared to version 6, it implements the prevention of
> > defining an alias of an alias having default args, as suggested
> > by Simon.
> 
> Huh, I just realized it's still possible to get into that situation
> because of the "set default-args" command:
> 
> (gdb) alias aaa = backtrace
> (gdb) alias bbb = aaa -past-main
> (gdb) set default-args aaa -full
> 
> With the current implementation where default args are resolved at define
> time, `bbb` will only have `-past-main` as its default args.  But if we
> later implement the feature where default args are resolved at use time,
> that behavior will change.
Effectively, the above means a future backward incompatibility if
aliases would be changed to be handled dynamically, rather than
at definition time.

> 
> I kind of feel like the bad guy because I keep suggesting to reduce the
> scope of the feature 
"La perfection est atteinte, non pas lorsqu'il n'y a plus rien à ajouter,
mais lorsqu'il n'y a plus rien à retirer." (Antoine de Saint-Exupéry)"

I am not sure that this patch will reach perfection but the main
use case of 'set default-args' was for GDB commands, very little
remains when default-args are used only for aliases:

The only (small) remaining usage is to allow a user to build an
alias definition by checking its behavior and modifying the
default args till it behaves as desired.
But that can be achieved without too much problems e.g. by doing
  alias try1 = backtrace -something
  try1
  alias try2 = backtrace -somethingelse -somethingmore
  try2
  => when ok, the user can add the alias in .gdbinit

So, I agree with you, better to make all that even simpler for
this release.

I will do a new patch, removing 'set/show default-args'

Thanks

Philippe


> but... is there a good use case at the moment for
> "set default-args", compared to passing default args when defining the
> alias?  A use case where you wouldn't know the default args before
> defining the alias?  If not, removing "set default-args" would avoid it,
> without loss of functionality.  Then we'd have to see if
> "show default-args" makes sense without "set default-args".  It's still
> possible to see the default args with "help <alias>".
> 
> That would make me feel comfortable enough about the feature to merge
> it in time for GDB 10.  It is restricted enough that there's not much
> risk of introducing a behavior we'll regret later, while still adding
> something that has value, being able to add default args to aliases.
> 
> Once we have evaluation of default args at runtime, I think it would
> be fine to have "set default-args", if you think it's useful.  Using it
> on a command X would implicitly affect all the aliases based on X, which
> is what I would expect as a user.
> 
> Simon



More information about the Gdb-patches mailing list