From: Andrew Burgess <andrew.burgess@embecosm.com>
To: Philippe Waroquiers <philippe.waroquiers@skynet.be>
Cc: gdb-patches@sourceware.org, Tom Tromey <tom@tromey.com>
Subject: Re: [PATCHv2] gdb: Rewrite argument handling for user-defined commands
Date: Sat, 08 Sep 2018 14:33:00 -0000 [thread overview]
Message-ID: <20180908143350.GI22193@embecosm.com> (raw)
In-Reply-To: <1536384914.1459.11.camel@skynet.be>
* Philippe Waroquiers <philippe.waroquiers@skynet.be> [2018-09-08 07:35:14 +0200]:
> On Fri, 2018-09-07 at 00:29 +0100, Andrew Burgess wrote:
> > Here's a new version of the quoting patch which now uses single and
> > double quotes for quoting arguments.
> >
> > I look forward to any feedback.
> >
> > Eli - I suspect that the documentation changes would need some work,
> > but you should probably wait to review, as I suspect this patch will
> > change again before it can be merged.
> >
> > Thanks,
> > Andrew
> >
> > ---
> >
> > This commit rewrites argument passing for user-defined commands. The
> > rewrite was inspired after this mailing list thread:
> >
> > https://sourceware.org/ml/gdb-patches/2018-08/msg00391.html
> >
> > The summary is that it was felt that in order to pass arguments that
> > include whitespace, then single or double quotes should be used for
> > quoting the argument.
> Tom felt that we need to support your initial suggestion (parenthesis
> quoting) for 'balanced expressions', as parenthesis are used in
> some other commands that are evaluating expressions.
> I can understand his point of view, see
> https://sourceware.org/ml/gdb-patches/2018-09/msg00007.html
>
> >
> > The problem is that currently, the quotes are included in the argument
> > that is passed into the user-defined command, so passing the argument
> > "1 + 1" will currently litterally pass "1 + 1" (including the quotes)
> > to GDB, which is no good if what you want to do is to pass an
> > expression.
> For this problem, an alternative solution is to have a new
> way to expand an argument :
> $argX expands the argument X with the quotes
> $arguX expands the argument X with the quotes.
>
> That allows to pass a quoted argument containing spaces,
> and use it in the user defined command without quotes where needed,
> and with quotes where needed : if the user defined command has to call
> another command (user defined or a native) that itself needs quoting,
> then use $argX, else use $arguX.
> In other words, how to handle a quoted arg is decided by the
> user command 'developer' (similarly to some native GDB commands).
>
> So, adder command would become
> print $argu1 + $argu2 + $argu3
>
> See https://sourceware.org/ml/gdb-patches/2018-09/msg00005.html
> for a patch (only very limited manual testing done) implementing
> the arguX approach :
Great. OK, lets go with this approach then. Tom, do you feel that we
need more is required above and beyond adding argX / arguX as Philippe
has suggested?
Thanks,
Andrew
>
> (gdb) define adder
> Type commands for definition of "adder".
> End with a line saying just "end".
> > print $arg0 + $arg1 + $arg2
> > end
> (gdb) adder '1 + 5' 2 3
> No symbol table is loaded. Use the "file" command.
> (gdb)
>
> (gdb) define adder
> Redefine command "adder"? (y or n) y
> Type commands for definition of "adder".
> End with a line saying just "end".
> >print $argu0 + $argu1 + $argu2
> >end
> (gdb) adder '1 + 5' 2 3
> $4 = 11
> (gdb)
>
>
> >
> > This commit changes how quoting works so that the quotes are NOT now
> > included in the argument passed. If the user wants to include quotes,
> > they would now need to use nested quotes, so "\"abc\"" will pass the
> > argument "abc".
> >
> > It is also possible to use single quotes, so '"abc"' will also pass
> > the argument "abc".
> >
> > As currently there's no documentation for how quoting works in
> > user-defined commands this commit adds documentation for the new
> > behaviour.
> >
> > The big risk with this commit is that this does change how arguments
> > are passed to user-defined commands, and this might causes issues for
> > existing users.
> Yes, that has the potential to create a lot of backward incompatibility,
> which is not the case for the $arguX and/or the parenthesis approach
> you suggested initially.
>
> Philippe
>
>
prev parent reply other threads:[~2018-09-08 14:33 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-15 14:39 [PATCH 0/2] gdb: Allow parenthesis to group arguments to " Andrew Burgess
2018-08-15 14:39 ` [PATCH 1/2] gdb: Make testnames unique in gdb.base/commands.exp Andrew Burgess
2018-08-30 15:26 ` Tom Tromey
2018-08-15 14:39 ` [PATCH 2/2] gdb: Allow parenthesis to group arguments to user-defined commands Andrew Burgess
2018-08-15 18:24 ` Eli Zaretskii
2018-08-25 19:32 ` Philippe Waroquiers
2018-08-25 20:53 ` Philippe Waroquiers
2018-08-25 22:43 ` Andrew Burgess
2018-08-28 15:54 ` Tom Tromey
2018-08-28 18:43 ` Andrew Burgess
2018-08-28 20:29 ` Philippe Waroquiers
2018-08-28 23:29 ` Andrew Burgess
2018-08-30 2:19 ` Tom Tromey
2018-08-30 21:19 ` Philippe Waroquiers
2018-08-31 20:59 ` Tom Tromey
2018-09-01 11:10 ` Philippe Waroquiers
2018-09-01 14:20 ` Tom Tromey
2018-09-01 15:36 ` Philippe Waroquiers
2018-08-30 2:26 ` Tom Tromey
2018-09-06 23:29 ` [PATCHv2] gdb: Rewrite argument handling for " Andrew Burgess
2018-09-07 6:31 ` Eli Zaretskii
2018-09-07 20:36 ` Tom Tromey
2018-09-07 22:47 ` Andrew Burgess
2018-09-08 6:27 ` Eli Zaretskii
2018-09-08 5:35 ` Philippe Waroquiers
2018-09-08 14:33 ` Andrew Burgess [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180908143350.GI22193@embecosm.com \
--to=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
--cc=philippe.waroquiers@skynet.be \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).