Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Sergio Durigan Junior <sergiodj@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 13/24] Make "print" and "compile print" support -OPT options
Date: Sat, 25 May 2019 10:10:00 -0000	[thread overview]
Message-ID: <8564ae6d-7e46-7317-8636-eefe97db7814@redhat.com> (raw)
In-Reply-To: <87pno7ocpk.fsf@redhat.com>

On 5/24/19 8:48 PM, Sergio Durigan Junior wrote:
> On Wednesday, May 22 2019, Pedro Alves wrote:
> 
>> This patch adds support for "print -option optval --", etc.
>> Likewise for "compile print".
>>
>> We'll get:
>>
>> ~~~~~~
>> (gdb) help print
>> Print value of expression EXP.
>> Usage: print [[OPTION]... --] [/FMT] [EXP]
>>
>> Options:
>>   -address [on|off]
>>     Set printing of addresses.
>>
>>   -array [on|off]
>>     Set pretty formatting of arrays.
>>
>>   -array-indexes [on|off]
>>     Set printing of array indexes.
>>
>>   -elements NUMBER|unlimited
>>     Set limit on string chars or array elements to print.
>>     "unlimited" causes there to be no limit.
>>
>>   -max-depth NUMBER|unlimited
>>     Set maximum print depth for nested structures, unions and arrays.
>>     When structures, unions, or arrays are nested beyond this depth then they
>>     will be replaced with either '{...}' or '(...)' depending on the language.
>>     Use "unlimited" to print the complete structure.
>>
>> -null-stop [on|off]
>>     Set printing of char arrays to stop at first null char.
>>
>>   -object [on|off]
>>     Set printing of C++ virtual function tables.
>>
>>   -pretty [on|off]
>>     Set pretty formatting of structures.
>>
>>   -repeats NUMBER|unlimited
>>     Set threshold for repeated print elements.
>>     "unlimited" causes all elements to be individually printed.
>>
>>   -static-members [on|off]
>>     Set printing of C++ static members.
>>
>>   -symbol [on|off]
>>     Set printing of symbol names when printing pointers.
>>
>>   -union [on|off]
>>     Set printing of unions interior to structures.
>>
>>   -vtbl [on|off]
>>     Set printing of C++ virtual function tables.
>>
>> Note: because this command accepts arbitrary expressions, if you
>> specify any command option, you must use a double dash ("--")
>> to mark the end of option processing.  E.g.: "print -o -- myobj".
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> I want to highlight the comment above about "--".
> 
> Thanks for the patch.  I read it, and it seems like a very good
> improvement.  I just have a small point to make.  Since:
> 
> 1) There was a visible change of behaviour (i.e., we will now require
> the user to specify "--" when she wants to end the option processing).

Right.  Though I wouldn't call that a change of behavior, because before
there was no options support at all.

> 
> 2) The comment above explains this change very well.
> 
> 3) It has been replicated over all of the commands that have this
> requirement,

Right.  It's only "print" and "compile print" so far, though.

> 
> then why don't you make the build_help routine always print it if we're
> dealing with gdb::option::PROCESS_OPTIONS_REQUIRE_DELIMITER command
> types?  I think it is a nice addition to the help text.

I had thought of that but didn't do it because I thought that each command
would want to spell it out a little bit differently.  E.g., for "print"
and "compile print" the difference is in the example:

Note: because this command accepts arbitrary expressions, if you
specify any command option, you must use a double dash ("--")
to mark the end of option processing.  E.g.: "print -o -- myobj".

Note: because this command accepts arbitrary expressions, if you
specify any command option, you must use a double dash ("--")
to mark the end of option processing.  E.g.: "compile print -o -- myobj".

... and I don't know whether "arbitrary expressions" will be the
reason for using PROCESS_OPTIONS_REQUIRE_DELIMITER with other
commands.

Since there's only two cases, I didn't think it'd be worth it to
try to come up with an abstraction until we have more uses?

BTW, one command that currently accepts "-" options _and_ works with
arbitrary expressions is the watch command:

 (gdb) help watch 
 Set a watchpoint for an expression.
 Usage: watch [-l|-location] EXPRESSION

Note how it's impossible to watch an expression named "-l".
We could solve that by supporting "--" in the watch command, so
you'd type:

 (gdb) watch -- -l

So it could be argued that "watch" should be a PROCESS_OPTIONS_REQUIRE_DELIMITER
just like "print", since it has the exact same issues.  It happens to only
support one option today, and probably watching "-FOO" is rare, so nobody ever
noticed this...

I _think_ that the risk of not requiring "--" for "print" is higher
than for other commands.  But that's my opinion, maybe others would be OK
with requiring users to type:

 (gdb) print -- -r

where they typed today:

 (gdb) print -r

I'm stressing this issue because we're likely going to be stuck with whatever
we decide, practically forever.  :-)

Thanks,
Pedro Alves


  reply	other threads:[~2019-05-25 10:10 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22 20:53 [PATCH 00/24] gdb::option framework, "print -OPT", other cmd options Pedro Alves
2019-05-22 20:53 ` [PATCH 19/24] Introduce complete_command Pedro Alves
2019-05-22 20:53 ` [PATCH 15/24] Introduce rename_cmd Pedro Alves
2019-05-25 19:58   ` Philippe Waroquiers
2019-05-29 16:03     ` Pedro Alves
2019-05-29 18:30       ` Pedro Alves
2019-05-30 10:22         ` Philippe Waroquiers
2019-05-30 20:01           ` Pedro Alves
2019-05-22 20:53 ` [PATCH 08/24] gdb.base/settings.exp: Fix comment typo Pedro Alves
2019-05-24 11:40   ` Pedro Alves
2019-05-22 20:53 ` [PATCH 03/24] Fix TID parser bug Pedro Alves
2019-05-22 20:53 ` [PATCH 07/24] Remove "show" command completers Pedro Alves
2019-05-23 19:28   ` Sergio Durigan Junior
2019-05-24 11:25     ` Pedro Alves
2019-05-24 14:21       ` Sergio Durigan Junior
2019-05-22 20:53 ` [PATCH 11/24] number_or_range_parser::get_number, don't treat "1 -" as a range Pedro Alves
2019-05-22 20:53 ` [PATCH 04/24] Make check_for_argument skip whitespace after arg itself Pedro Alves
2019-05-22 20:53 ` [PATCH 18/24] lib/completion-support.exp: Add test_gdb_completion_offers_commands Pedro Alves
2019-05-22 20:54 ` [PATCH 09/24] New set/show testing framework (gdb.base/settings.exp) Pedro Alves
2019-05-23  4:15   ` Eli Zaretskii
2019-05-22 20:54 ` [PATCH 12/24] Introduce generic command options framework Pedro Alves
2019-05-25  7:43   ` Philippe Waroquiers
2019-05-25 10:31     ` Pedro Alves
2019-05-22 20:54 ` [PATCH 21/24] "thread apply 1 -- -" vs "frame apply level 0 -- -" Pedro Alves
2019-05-22 20:54 ` [PATCH 06/24] Fix "set enum-command value garbage" Pedro Alves
2019-05-23 19:13   ` Sergio Durigan Junior
2019-05-24 11:39     ` Pedro Alves
2019-05-22 20:54 ` [PATCH 05/24] Allow "unlimited" abbreviations Pedro Alves
2019-05-22 20:54 ` [PATCH 20/24] Make "frame apply" support -OPT options Pedro Alves
2019-05-25 20:12   ` Philippe Waroquiers
2019-05-29 15:13     ` Pedro Alves
2019-05-29 15:25       ` Pedro Alves
2019-05-22 20:54 ` [PATCH 14/24] Migrate rest of compile commands to new options framework Pedro Alves
2019-05-22 20:54 ` [PATCH 01/24] Fix latent bug in custom word point completion handling Pedro Alves
2019-05-22 20:54 ` [PATCH 22/24] Make "thread apply" use the gdb::option framework Pedro Alves
2019-05-25 20:24   ` Philippe Waroquiers
2019-05-29 15:38     ` Pedro Alves
2019-05-22 20:54 ` [PATCH 10/24] boolean/auto-boolean commands, make "o" ambiguous Pedro Alves
2019-05-22 20:54 ` [PATCH 02/24] Fix latent bug with custom word point completers Pedro Alves
2019-05-22 20:58 ` [PATCH 16/24] Make "backtrace" support -OPT options Pedro Alves
2019-05-22 20:58 ` [PATCH 13/24] Make "print" and "compile print" " Pedro Alves
2019-05-24 19:49   ` Sergio Durigan Junior
2019-05-25 10:10     ` Pedro Alves [this message]
2019-05-25 10:37       ` Andreas Schwab
2019-05-22 21:00 ` [PATCH 24/24] NEWS and manual changes for command options changes Pedro Alves
2019-05-23  4:31   ` Eli Zaretskii
2019-05-23 15:01     ` Pedro Alves
2019-05-23 15:07       ` Eli Zaretskii
2019-05-23 15:31         ` Pedro Alves
2019-05-25 20:40   ` Philippe Waroquiers
2019-05-29 16:03     ` Pedro Alves
2019-05-22 21:00 ` [PATCH 17/24] "backtrace full/no-filters/hide" completer Pedro Alves
2019-05-22 21:03 ` [PATCH 23/24] Delete parse_flags/parse_flags_qcs Pedro Alves
2019-05-22 21:46 ` [PATCH 00/24] gdb::option framework, "print -OPT", other cmd options Pedro Alves
2019-05-24 19:58 ` Sergio Durigan Junior

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=8564ae6d-7e46-7317-8636-eefe97db7814@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sergiodj@redhat.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