Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Michael Snyder <msnyder@vmware.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: Tom Tromey <tromey@redhat.com>,
	 "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [rfa] clean up output of "info set" command.
Date: Sat, 12 Feb 2011 01:30:00 -0000	[thread overview]
Message-ID: <4D55E2B7.9010607@vmware.com> (raw)
In-Reply-To: <201102112333.05763.pedro@codesourcery.com>

[-- Attachment #1: Type: text/plain, Size: 1297 bytes --]

Pedro Alves wrote:
> On Friday 11 February 2011 21:17:08, Tom Tromey wrote:
>>>>>>> "Michael" == Michael Snyder <msnyder@vmware.com> writes:
>> Pedro> Isn't there a property of the command we could check
>> Pedro> instead of hardcoding specific command names?
>>
>> Michael> I'm open to suggestions.  The only property I can think of is that
>> Michael> there is no corresponding entry in "setlist".  I could search
>> Michael> setlist every time...
>>
>> You could stick a new flag on the command object.
> 
> Yeah.  You may even be able to set the flag from within
> the add_setshow_... functions and friends.  The flag could
> mean "this show command shows something that is settable
> in some way" (or the reverse).
> 
>> Or there is cmd_cfunc_eq, which is used for a similar purpose in some
>> places.  I don't think this is super, but OTOH it isn't any worse than
>> existing code.
> 
> I think we shouldn't allow ourselves to broadcast bad design
> when it's easy not to.  The function Michael touched is within
> gdb/cli/cli-setshow.c.  I'd prefer to keep this and the other
> core command files clean of specific knowledge of 
> any specific commands their clients register.

OK, here's a new implementation in which I use the "class" field
to flag the offending show commands.

Better?


[-- Attachment #2: no_set.txt --]
[-- Type: text/plain, Size: 4918 bytes --]

2011-02-10  Michael Snyder  <msnyder@msnyder-server.eng.vmware.com>

	* command.h (enum command_class): New class 'no_set_class', for
	"show" commands without a corresponding "set" command.
	* value.c (_initialize_values): Use 'no_set_class' for "show values".
	* copying.c (_initialize_copying): Ditto for "show copying" and
	"show warranty".
	* cli/cli-cmds.c (init_cli_cmds): Ditto for "show commands" and
	"show version".
	* cli/cli-setshow.c (cmd_show_list): Skip "show" commands for
	which there is no corresponding "set" command (eg. "show copying").

Index: command.h
===================================================================
RCS file: /cvs/src/src/gdb/command.h,v
retrieving revision 1.73
diff -u -p -u -p -r1.73 command.h
--- command.h	31 Jan 2011 16:52:34 -0000	1.73
+++ command.h	12 Feb 2011 01:22:59 -0000
@@ -34,7 +34,7 @@ enum command_class
   no_class = -1, class_run = 0, class_vars, class_stack, class_files,
   class_support, class_info, class_breakpoint, class_trace,
   class_alias, class_bookmark, class_obscure, class_maintenance,
-  class_pseudo, class_tui, class_user, class_xdb
+  class_pseudo, class_tui, class_user, class_xdb, no_set_class
 };
 
 /* FIXME: cagney/2002-03-17: Once cmd_type() has been removed, ``enum
Index: value.c
===================================================================
RCS file: /cvs/src/src/gdb/value.c,v
retrieving revision 1.125
diff -u -p -u -p -r1.125 value.c
--- value.c	25 Jan 2011 15:18:35 -0000	1.125
+++ value.c	12 Feb 2011 01:22:59 -0000
@@ -2533,7 +2533,7 @@ A few convenience variables are given va
 \"$__\" holds the contents of the last address examined with \"x\"."),
 	   &showlist);
 
-  add_cmd ("values", no_class, show_values, _("\
+  add_cmd ("values", no_set_class, show_values, _("\
 Elements of value history around item number IDX (or last ten)."),
 	   &showlist);
 
Index: copying.c
===================================================================
RCS file: /cvs/src/src/gdb/copying.c,v
retrieving revision 1.6
diff -u -p -u -p -r1.6 copying.c
--- copying.c	23 Aug 2007 20:33:48 -0000	1.6
+++ copying.c	12 Feb 2011 01:22:59 -0000
@@ -649,10 +649,10 @@ show_warranty_command (char *ignore, int
 void
 _initialize_copying (void)
 {
-  add_cmd ("copying", no_class, show_copying_command,
+  add_cmd ("copying", no_set_class, show_copying_command,
 	   _("Conditions for redistributing copies of GDB."),
 	   &showlist);
-  add_cmd ("warranty", no_class, show_warranty_command,
+  add_cmd ("warranty", no_set_class, show_warranty_command,
 	   _("Various kinds of warranty you do not have."),
 	   &showlist);
 
Index: cli/cli-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v
retrieving revision 1.110
diff -u -p -u -p -r1.110 cli-cmds.c
--- cli/cli-cmds.c	17 Jan 2011 16:50:42 -0000	1.110
+++ cli/cli-cmds.c	12 Feb 2011 01:22:59 -0000
@@ -1533,13 +1533,13 @@ Generic command for showing things about
   /* Another way to get at the same thing.  */
   add_info ("set", show_command, _("Show all GDB settings."));
 
-  add_cmd ("commands", no_class, show_commands, _("\
+  add_cmd ("commands", no_set_class, show_commands, _("\
 Show the history of commands you typed.\n\
 You can supply a command number to start with, or a `+' to start after\n\
 the previous command number shown."),
 	   &showlist);
 
-  add_cmd ("version", no_class, show_version,
+  add_cmd ("version", no_set_class, show_version,
 	   _("Show what version of GDB this is."), &showlist);
 
   add_com ("while", class_support, while_command, _("\
Index: cli/cli-setshow.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-setshow.c,v
retrieving revision 1.43
diff -u -p -u -p -r1.43 cli-setshow.c
--- cli/cli-setshow.c	6 Jan 2011 00:57:02 -0000	1.43
+++ cli/cli-setshow.c	12 Feb 2011 01:22:59 -0000
@@ -434,18 +434,21 @@ cmd_show_list (struct cmd_list_element *
 	}
       else
 	{
-	  struct cleanup *option_chain
-	    = make_cleanup_ui_out_tuple_begin_end (uiout, "option");
+	  if (list->class != no_set_class)
+	    {
+	      struct cleanup *option_chain
+		= make_cleanup_ui_out_tuple_begin_end (uiout, "option");
 
-	  ui_out_text (uiout, prefix);
-	  ui_out_field_string (uiout, "name", list->name);
-	  ui_out_text (uiout, ":  ");
-	  if (list->type == show_cmd)
-	    do_setshow_command ((char *) NULL, from_tty, list);
-	  else
-	    cmd_func (list, NULL, from_tty);
-          /* Close the tuple.  */
-	  do_cleanups (option_chain);
+	      ui_out_text (uiout, prefix);
+	      ui_out_field_string (uiout, "name", list->name);
+	      ui_out_text (uiout, ":  ");
+	      if (list->type == show_cmd)
+		do_setshow_command ((char *) NULL, from_tty, list);
+	      else
+		cmd_func (list, NULL, from_tty);
+	      /* Close the tuple.  */
+	      do_cleanups (option_chain);
+	    }
 	}
     }
   /* Close the tuple.  */

  parent reply	other threads:[~2011-02-12  1:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-11 20:20 Michael Snyder
2011-02-11 20:42 ` Pedro Alves
2011-02-11 20:53   ` Michael Snyder
2011-02-11 21:17     ` Tom Tromey
2011-02-11 23:33       ` Pedro Alves
2011-02-12  0:01         ` Michael Snyder
2011-02-12  0:08           ` Michael Snyder
2011-02-12  1:30         ` Michael Snyder [this message]
2011-02-12  7:55           ` Eli Zaretskii
2011-02-15  2:03             ` Michael Snyder

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=4D55E2B7.9010607@vmware.com \
    --to=msnyder@vmware.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.com \
    --cc=tromey@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