public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: make use add_setshow_prefix_cmd in gnu-nat.c
@ 2022-01-06 13:04 Andrew Burgess
  2022-01-06 15:33 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Burgess @ 2022-01-06 13:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

In gnu-nat.c we currently implement some set/show prefix commands
"manually", that is, we call add_prefix_cmd, and assign a set and show
function to each prefix command.

These set/show functions print an error indicating that the user
didn't type a complete command.

If we instead switch to using add_setshow_prefix_cmd then we can
delete the set/show functions, GDB provides some default functions,
which give a nice help style summary that lists all of the available
sub-commands, along with a one line summary of what each does.

Though this clearly changes the existing behaviour, I think this
change is acceptable as the new behaviour is more inline with other
set/show prefix commands, and the new behaviour is more informative.

This change will conflict with Tom's change here:

  https://sourceware.org/pipermail/gdb-patches/2022-January/184724.html

Where Tom changes the set/show functions that I delete.  My suggestion
is that the set/show functions still be deleted even after Tom's
patch (or instead of Tom's patch).

For testing I've build GDB on GNU/Hurd, and manually tested these
functions.  I did a grep over the testsuite, and don't believe the
existing error messages are being checked for in any tests.
---
 gdb/gnu-nat.c | 59 ++++++++++++---------------------------------------
 1 file changed, 13 insertions(+), 46 deletions(-)

diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index b7b486904e8..b39dfaf009c 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -2701,38 +2701,6 @@ struct cmd_list_element *show_thread_cmd_list = NULL;
 struct cmd_list_element *set_thread_default_cmd_list = NULL;
 struct cmd_list_element *show_thread_default_cmd_list = NULL;
 
-static void
-set_thread_cmd (const char *args, int from_tty)
-{
-  fprintf_filtered (gdb_stderr,
-		    "\"set thread\" must be followed by the "
-		    "name of a thread property, or \"default\".\n");
-}
-
-static void
-show_thread_cmd (const char *args, int from_tty)
-{
-  fprintf_unfiltered (gdb_stderr,
-		      "\"show thread\" must be followed by the "
-		      "name of a thread property, or \"default\".\n");
-}
-
-static void
-set_thread_default_cmd (const char *args, int from_tty)
-{
-  fprintf_unfiltered (gdb_stderr,
-		      "\"set thread default\" must be followed "
-		      "by the name of a thread property.\n");
-}
-
-static void
-show_thread_default_cmd (const char *args, int from_tty)
-{
-  fprintf_unfiltered (gdb_stderr,
-		      "\"show thread default\" must be followed "
-		      "by the name of a thread property.\n");
-}
-
 static int
 parse_int_arg (const char *args, const char *cmd_prefix)
 {
@@ -3417,20 +3385,19 @@ thread_takeover_sc_cmd (const char *args, int from_tty)
 static void
 add_thread_commands (void)
 {
-  add_prefix_cmd ("thread", no_class, set_thread_cmd,
-		  _("Command prefix for setting thread properties."),
-		  &set_thread_cmd_list, 0, &setlist);
-  add_prefix_cmd ("default", no_class, show_thread_cmd,
-		  _("Command prefix for setting default thread properties."),
-		  &set_thread_default_cmd_list, 0,
-		  &set_thread_cmd_list);
-  add_prefix_cmd ("thread", no_class, set_thread_default_cmd,
-		  _("Command prefix for showing thread properties."),
-		  &show_thread_cmd_list, 0, &showlist);
-  add_prefix_cmd ("default", no_class, show_thread_default_cmd,
-		  _("Command prefix for showing default thread properties."),
-		  &show_thread_default_cmd_list, 0,
-		  &show_thread_cmd_list);
+  add_setshow_prefix_cmd ("thread", no_class,
+			  _("Command prefix for setting thread properties."),
+			  _("Command prefix for showing thread properties."),
+			  &set_thread_cmd_list,
+			  &show_thread_cmd_list,
+			  &setlist, &showlist);
+
+  add_setshow_prefix_cmd ("default", no_class,
+			  _("Command prefix for setting default thread properties."),
+			  _("Command prefix for showing default thread properties."),
+			  &set_thread_default_cmd_list,
+			  &show_thread_default_cmd_list,
+			  &set_thread_cmd_list, &show_thread_cmd_list);
 
   add_cmd ("pause", class_run, set_thread_pause_cmd, _("\
 Set whether the current thread is suspended while gdb has control.\n\
-- 
2.25.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb: make use add_setshow_prefix_cmd in gnu-nat.c
  2022-01-06 13:04 [PATCH] gdb: make use add_setshow_prefix_cmd in gnu-nat.c Andrew Burgess
@ 2022-01-06 15:33 ` Tom Tromey
  2022-01-06 15:45   ` Andrew Burgess
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2022-01-06 15:33 UTC (permalink / raw)
  To: Andrew Burgess via Gdb-patches; +Cc: Andrew Burgess

>>>>> "Andrew" == Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> writes:

Andrew> Though this clearly changes the existing behaviour, I think this
Andrew> change is acceptable as the new behaviour is more inline with other
Andrew> set/show prefix commands, and the new behaviour is more informative.

This looks good to me.  Thanks for doing this.

Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb: make use add_setshow_prefix_cmd in gnu-nat.c
  2022-01-06 15:33 ` Tom Tromey
@ 2022-01-06 15:45   ` Andrew Burgess
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Burgess @ 2022-01-06 15:45 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Andrew Burgess via Gdb-patches

* Tom Tromey <tom@tromey.com> [2022-01-06 08:33:36 -0700]:

> >>>>> "Andrew" == Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Andrew> Though this clearly changes the existing behaviour, I think this
> Andrew> change is acceptable as the new behaviour is more inline with other
> Andrew> set/show prefix commands, and the new behaviour is more informative.
> 
> This looks good to me.  Thanks for doing this.

Thanks, I pushed this.

Andrew


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-06 15:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-06 13:04 [PATCH] gdb: make use add_setshow_prefix_cmd in gnu-nat.c Andrew Burgess
2022-01-06 15:33 ` Tom Tromey
2022-01-06 15:45   ` Andrew Burgess

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