Re: [PATCH 2/2] gdb: Allow parenthesis to group arguments to user-defined commands

Philippe Waroquiers
2018-09-01T15:36:38Z

On Sat, 2018-09-01 at 08:20 -0600, Tom Tromey wrote:
> > > > > > "Philippe" == Philippe Waroquiers <philippe.waroquiers@skynet.be> writes:
>
> Philippe> What about the alternative solution to allow a user defined
> Philippe> command to use $argu0, $argu1, $argu2, ... to do unquoted
> Philippe> expansion when needed ?
>
> I think the problem is that people want to write user-defined commands
> that act like other gdb commands, and in particular writing a
> user-defined that takes an expression is, by far, the most common case.
>
> But, this proposal would mean that "print" would have one style of
> quoting, while "user-print" would have another, drastically less nice,
> style.
Then maybe the conclusion is that we really need 2 different styles
of quoting:

* a quote mechanism to quote expressions, which then must have
a
'balanced' nr of open/close parenthesis.
* a quote mechanism (based on '
quoting) for
non expressions args.
Single quotes are already used by
several native gdb
commands (all gdb_argv based, and some others),
but
is (currently) poorly supported for user defined
commands, which must be
able to unquote an arg to pass
it to native commands that do not expect
quoted args.
Â
The $argu approach then should allow to write
user defined
commands that have the same behaviour
as the native commands.
E.g. I believe the
example 'info var for a bunch of REGEXP'
is not implementable today, would still
not be doable
with parenthesis quoting, but is I believe implementable
with the
$argu approach.

>
> Personally I think people should just write Python, since it is a much
> better way. But the CLI is more convenient, so here we are.

>
> Philippe> As far as I can see, gdb_argv is escaping single and double quotes, e.g.
> Philippe> (gdb) handle 10 'ignore this \'bidule'
> Philippe> Unrecognized or ambiguous flag word: "ignore this 'bidule".
> Philippe> (gdb)Â
>
> Yeah, I misremembered that. Thanks.
Well, before you pointed me at gdb_argv, I even did not know
it was existing :). So thanks to Andrew and you for this discussion,
I learned a lot about gdb from it.

Philippe