public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: make use add_setshow_prefix_cmd in gnu-nat.c
@ 2022-01-06 15:45 Andrew Burgess
  0 siblings, 0 replies; only message in thread
From: Andrew Burgess @ 2022-01-06 15:45 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=10a85f29c74ab562db622cfc4f58997e859c6ed6

commit 10a85f29c74ab562db622cfc4f58997e859c6ed6
Author: Andrew Burgess <aburgess@redhat.com>
Date:   Thu Jan 6 12:53:20 2022 +0000

    gdb: make use add_setshow_prefix_cmd in gnu-nat.c
    
    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.

Diff:
---
 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\


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-06 15:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-06 15:45 [binutils-gdb] gdb: make use add_setshow_prefix_cmd in gnu-nat.c 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).