From: Andrew Burgess <andrew.burgess@embecosm.com>
To: Philippe Waroquiers <philippe.waroquiers@skynet.be>
Cc: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] gdb: Allow parenthesis to group arguments to user-defined commands
Date: Tue, 28 Aug 2018 23:29:00 -0000 [thread overview]
Message-ID: <20180828232948.GK32506@embecosm.com> (raw)
In-Reply-To: <1535488137.7778.4.camel@skynet.be>
* Philippe Waroquiers <philippe.waroquiers@skynet.be> [2018-08-28 22:28:57 +0200]:
> On Tue, 2018-08-28 at 19:43 +0100, Andrew Burgess wrote:
> > * Tom Tromey <tom@tromey.com> [2018-08-28 09:53:52 -0600]:
> >
> > > > > > > > "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:
> > >
> > > Andrew> So, my suggestion deliberately avoids using quotes or backslashes as
> > > Andrew> these are bogged down in the existing code. And using (...) is fairly
> > > Andrew> intuitive given GDBs C like expression handling, personally I'd rather
> > > Andrew> write:
> > > Andrew> my_command ({unsigned long long} &global_var)
> > > Andrew> than:
> > > Andrew> my_command {unsigned\ long\ long}\ &global_var
> > >
> > > FWIW I tend to agree with your logic here.
> > >
> > > User-defined argument parsing is broken (and I think there's at least
> > > one bug in bugzilla about this), but at the same time, making breaking
> > > changes seems unfriendly. Your approach doesn't seem to be breaking
> > > anything that is likely to be actually used.
>
> I do not think a \ followed by a space will create a lot of incompatibilities.
> i
> .e. that someone would type
> some_user_defined_command a\ b
> to give 2
> different args to the command.
No, and what they get at the moment is a single argument, which is:
a\ b
including the backslash and the space. Is this correct, or useful? I
suspect not, but my instinct in these cases is not to mess with things
without good reason, and I didn't have a good reason.
>
> For single quotes: it is unlikely that someone types something like
> some_user_defined_command 'abc def'
> and was expecting the user defined command to receive two args.
I agree, and what they get right now is:
'abc def'
including the quotes.
> What is however a lot more likely is
> some_user_defined_command 'a'
> and this command expects to receive a character value.
Which is more or less what you get:
'a'
> So, yes, single quotes has more potential to create
> incompatibilities.
I guess that depends on what you're proposing the argument should
evaluate too.
>
> On the downside, quoting with parenthesis is something very peculiar
> (is there some other tool/shell/... using this convention ?).
I guess I never saw it as quoting, just grouping an expression
together. I think I see GDB as mostly consuming C like expressions,
which is why using () seemed natural enough. Coincidentally the users
I'm working with initially tried () too (without prompting from me) so
my focus group of 2 all agreed with me ;-)
>
> And from a previous discussion with Pedro, he indicated that
> some commands in gdb already are using single quotes.
> The 'Not sure' below is a quote of Pedro :), replying to a suggestion
> I gave to let the user tell explicitly if an arg was quoted or not.
> > * have a way to (explicitely) quote an argument e.g.
> > info var -Qt 'long int' regexpofsomevars
> > where -Q indicates that the next "value argument" is
> > explicitely quoted.
>
> Not sure we need that -Q. We can support optional quotes, and
> tell users to add quotes if necessary? That's what we've done
> since forever in linespecs and expressions, for example.
>
> It is based on this that I used single quotes in the
> info var/func/arg/local -t TYPEREGEXP NAMEREGEXP
> patch.
>
> > Given that the argument passing for user-defined functions is pretty
> > self contained we could, conceivably, implement a whole new system and
> > have a switch to select between them... the existing code does seem
> > rather odd.
> >
> > But ideally, I'd like that to be a project for another day.
> And we also have the 'generalised arg parser' prototype that Pedro has
> in a corner.
>
> IMO, clearly, what to do is unclear :).
I agree, except I need to figure out some clarity in order to resolve
the real issue I have :)
I think that you're arguing in favour of reworking the argument
passing to user-defined commands. I'm not entirely sure exactly what
rules you're proposing we adopt though.
Maybe you could help me work through a few examples, in the following
table I've outlined a few examples, and have the following questions:
[1] What argument(s) would be passed under the new scheme?
[2] What argument(s) would be passed under the new scheme?
[3] How would I write {unsigned long} &var to pass this as a single
argument? If with quotes, how does this relate to 1 & 2?
| Input | Current Arguments(s) | Proposed Argument(s) |
|----------------------+----------------------+----------------------|
| a b | a | a |
| | b | b |
|----------------------+----------------------+----------------------|
| "a b" | "a b" | [1] |
|----------------------+----------------------+----------------------|
| 'a b' | 'a b' | [2] |
|----------------------+----------------------+----------------------|
| {unsigned long} &var | {unsigned | |
| | long} | N/A |
| | &var | |
|----------------------+----------------------+----------------------|
| [3] | | |
|----------------------+----------------------+----------------------|
In general I'm happy to rework this part of GDB, but ideally I'd like
some feedback from a global maintainer that such a change, which might
would break backward compatibility, would be acceptable...
Thanks,
Andrew
next prev parent reply other threads:[~2018-08-28 23:29 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-15 14:39 [PATCH 0/2] " 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
[not found] ` <eaa6d3a2975194a7ef3a2aa40e335c7986b205d8.1534343840.git.andrew.burgess@embecosm.com>
2018-08-15 18:24 ` [PATCH 2/2] gdb: Allow parenthesis to group arguments to user-defined commands 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 [this message]
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
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=20180828232948.GK32506@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