This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.

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.
What is however a lot more likely is
   some_user_defined_command 'a'
and this command expects to receive a character value.
So, yes, single quotes has more potential to create incompatibilities.

On the downside, quoting with parenthesis is something very peculiar
(is there some other tool/shell/... using this convention ?).

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 :).

Philippe


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]