From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8447 invoked by alias); 12 Feb 2011 01:30:39 -0000 Received: (qmail 8438 invoked by uid 22791); 12 Feb 2011 01:30:37 -0000 X-SWARE-Spam-Status: No, hits=-4.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,TW_XD,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-outbound-1.vmware.com (HELO smtp-outbound-1.vmware.com) (65.115.85.69) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 12 Feb 2011 01:30:33 +0000 Received: from mailhost2.vmware.com (mailhost2.vmware.com [10.16.67.167]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id B47F840007; Fri, 11 Feb 2011 17:30:31 -0800 (PST) Received: from msnyder-server.eng.vmware.com (promd-2s-dhcp138.eng.vmware.com [10.20.124.138]) by mailhost2.vmware.com (Postfix) with ESMTP id 9F4238ECFF; Fri, 11 Feb 2011 17:30:31 -0800 (PST) Message-ID: <4D55E2B7.9010607@vmware.com> Date: Sat, 12 Feb 2011 01:30:00 -0000 From: Michael Snyder User-Agent: Thunderbird 2.0.0.24 (X11/20101201) MIME-Version: 1.0 To: Pedro Alves CC: Tom Tromey , "gdb-patches@sourceware.org" Subject: Re: [rfa] clean up output of "info set" command. References: <4D5599E8.6030408@vmware.com> <4D55A1A4.5020208@vmware.com> <201102112333.05763.pedro@codesourcery.com> In-Reply-To: <201102112333.05763.pedro@codesourcery.com> Content-Type: multipart/mixed; boundary="------------070405000406010607090901" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-02/txt/msg00233.txt.bz2 This is a multi-part message in MIME format. --------------070405000406010607090901 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1297 Pedro Alves wrote: > On Friday 11 February 2011 21:17:08, Tom Tromey wrote: >>>>>>> "Michael" == Michael Snyder 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? --------------070405000406010607090901 Content-Type: text/plain; name="no_set.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="no_set.txt" Content-length: 4918 2011-02-10 Michael Snyder * 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. */ --------------070405000406010607090901--