Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Philippe Waroquiers <philippe.waroquiers@skynet.be>,
	gdb-patches@sourceware.org
Subject: Re: [PATCH 15/24] Introduce rename_cmd
Date: Wed, 29 May 2019 16:03:00 -0000	[thread overview]
Message-ID: <3db59d5f-481b-64d0-5684-060b9585c3ac@redhat.com> (raw)
In-Reply-To: <1558814323.1454.22.camel@skynet.be>

On 5/25/19 8:58 PM, Philippe Waroquiers wrote:
> On Wed, 2019-05-22 at 21:53 +0100, Pedro Alves wrote:
> 
>> diff --git a/gdb/command.h b/gdb/command.h
>> index 35006cc339e..ed848114b85 100644
>> --- a/gdb/command.h
>> +++ b/gdb/command.h
>> @@ -439,6 +439,11 @@ extern void
>>  				       struct cmd_list_element **set_list,
>>  				       struct cmd_list_element **show_list);
>>  
>> +/* Move command OLD_NAME from OLD_LIST to NEW_LIST and rename it from
>> +   OLD_NAME to NEW_NAME.  */
>> +extern void rename_cmd (const char *old_name, cmd_list_element **old_list,
>> +			const char *new_name, cmd_list_element **new_list);
>> +
> I have some difficulties to understand the idea here.
> If the command is moved from one list to another, how is the renamed
> command still available via the 'normal' list ?

So the existing command is called 

 "set print raw frame-arguments"

I think "set print raw-frame-arguments" would have been
a better command name, but since that command already exists with
that spelling since gdb 7.7, and I didn't have a huge reason to
change it, in the end I opted to leave it as it was.

With that decision, the next problem is, how to implement both the
option and the set command without duplicating the help bits.
So what I did was, define the option like this:

 +  boolean_option_def {
 +    "raw-frame-arguments",
 +    [] (frame_print_options *opt) { return &opt->print_raw_frame_arguments; },
 +    NULL, /* show_cmd_cb */
 +    N_("Set whether to print frame arguments in raw form."),
 +    N_("Show whether to print frame arguments in raw form."),
 +    N_("If set, frame arguments are printed in raw form, bypassing any\n\
 +pretty-printers for that value.")
 +  },

and then let:

 +  gdb::option::add_setshow_cmds_for_options
 +    (class_stack, &user_frame_print_options,
 +     frame_print_option_defs, &setprintlist, &showprintlist);
 +

create the "set print raw-frame-arguments" command from the option definition
shown above.

And now that's where the renaming takes place, with:

+  /* The above installs a "set print raw-frame-arguments" command,
+     because there's an option called "print -raw-frame-arguments".
+     Rename the command to "set print raw frame-arguments" (space
+     instead of dash), to keep backward compatibility -- the "raw
+     frame-arguments" command already existed when print options were
+     first added.  */
+  rename_cmd ("raw-frame-arguments", &setprintlist,
+             "frame-arguments", &setprintrawlist);
+  rename_cmd ("raw-frame-arguments", &showprintlist,
+             "frame-arguments", &showprintrawlist);


There are other ways to implement this.  I could move the
"raw-frame-arguments" option_def out of the frame_print_option_defs
array, so that it doesn't get installed as a command, and leave the
"set print raw frame-arguments" add_setshow... call in place.
I guess it wouldn't be a big deal.

> 
> Effectively, it looks like set/show print raw-frame-arguments commands
> are not known.

Yes, that was the intention.

> 
> Why not just keep the old command untouched, and define a new
> command via the new framework.
> 

It didn't seem worth it to me.

> Below is just a patch (based on HEAD) that defines 2 different set/show
> changing the same variable:
> (gdb) apropos raw form
> set print raw frame-arguments -- Set whether to print frame arguments in raw form
> set print raw-frame-arguments -- Set whether to print frame arguments in raw form
> show print raw frame-arguments -- Show whether to print frame arguments in raw form
> show print raw-frame-arguments -- Show whether to print frame arguments in raw form
> (gdb) set print raw frame-arguments on
> (gdb) show print raw frame-arguments 
> Whether to print frame arguments in raw form is on.
> (gdb) show print raw-frame-arguments 
> Whether to print frame arguments in raw form is on.
> (gdb) set print raw-frame-arguments off
> (gdb) show print raw frame-arguments
> Whether to print frame arguments in raw form is off.
> (gdb) show print raw-frame-arguments 
> Whether to print frame arguments in raw form is off.
> (gdb) 
> 
> I guess this should still work if the same variable is changed via
> the new framework and/or via add_setshow_boolean_cmd.

TBC, the new framework does not change how the set
commands work at all.  The integration that exists is that
the new gdb::option::add_setshow_cmds_for_options function
goes over the option definitions and calls add_setshow_xxx_cmd
for each option.  The option_def structure has some fields that
only exists for this, such as the show_doc, and the show_cmd_cb.
That was all done as a way to conveniently describe the help
bits for both the options and the commands in a single place.

> The old commands might be marked as obsolete.

Yes, if we add a "raw-frame-arguments", we should deprecate
"raw frame-arguments" so that TAB completion doesn't
suggest the latter, which would get in the way
of "set print raw[TAB]".

I actually tried doing that, and I don't recall the details,
but it didn't seem that easy, because there's more
than one command involved -- "raw" is a command, and then
"frame-arguments" is a subcommand.  I think it was at that
point that I had decided to just leave it as it was.

With the info above, any preference on how to proceed?

Thanks,
Pedro Alves


  reply	other threads:[~2019-05-29 16:03 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 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: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 [this message]
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:54 ` [PATCH 14/24] Migrate rest of compile commands to new options framework 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 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: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:58 ` [PATCH 13/24] Make "print" and "compile print" support -OPT options Pedro Alves
2019-05-24 19:49   ` Sergio Durigan Junior
2019-05-25 10:10     ` Pedro Alves
2019-05-25 10:37       ` Andreas Schwab
2019-05-22 20:58 ` [PATCH 16/24] Make "backtrace" " Pedro Alves
2019-05-22 21:00 ` [PATCH 17/24] "backtrace full/no-filters/hide" completer Pedro Alves
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: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=3db59d5f-481b-64d0-5684-060b9585c3ac@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=philippe.waroquiers@skynet.be \
    /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