From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11978 invoked by alias); 31 Dec 2008 01:15:18 -0000 Received: (qmail 11969 invoked by uid 22791); 31 Dec 2008 01:15:17 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_23,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 31 Dec 2008 01:14:42 +0000 Received: (qmail 16822 invoked from network); 31 Dec 2008 01:14:40 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 31 Dec 2008 01:14:40 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: eliminate deprecated_add_set_cmd Date: Wed, 31 Dec 2008 01:15:00 -0000 User-Agent: KMail/1.9.10 Cc: Eli Zaretskii , ams@gnu.org, Thomas Schwinge MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_FesWJzdd4Xnuodh" Message-Id: <200812310114.45103.pedro@codesourcery.com> 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: 2008-12/txt/msg00465.txt.bz2 --Boundary-00=_FesWJzdd4Xnuodh Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 1872 Hi! I just noticed that we're close to being able to eliminate the old deprecated_add_set_cmd interface. The only two commands left using it are: "maint show-debug-regs" (gdb) help maint show-debug-regs Set whether to show variables that mirror the x86 debug registers. Use "on" to enable, "off" to disable. If enabled, the debug registers values are shown when GDB inserts or removes a hardware breakpoint or watchpoint, and when the inferior triggers a breakpoint or watchpoint. And, "maint gnu-debug" (gdb) help maint gnu-debug Set debugging output for the gnu backend. The attached patch converts them to use the add_setshow alternatives, in the least intrusive way. Well, it has one immediate benefit: 'maint show-debug-regs ' now autocompletes: (gdb) maint show-debug-regs o off on However, the new interfaces (add_setshow_*) were added mainly because every set command should be paired with a show command -- both these commands in their current state have no way to let the user know the status of the setting --- they're write-only. While I'm at it, this would be a good time to fix it up for these remaining commands. Hence, the million dollar question: Would you prefer the commands to stay as they are, or, to rename the commands to be able to add a "show" facility ? E.g., say, for the x86 debug registers debug output, maint show-debug-regs -> maint set show-debug-regs on|off maint show show-debug-regs Alternatively: maint show-debug-regs -> set debug debug-regs on|off maint show debug-regs ? And, for the gnu/hurd people debugging the debugger: maint gnu-debug -> maint set gnu-debug maint show gnu-debug Alternatively: maint gnu-debug -> set debug gnu (, gnu-nat, gnu-hurd, gnu-whatever, ...) show debug gnu ? -- Pedro Alves --Boundary-00=_FesWJzdd4Xnuodh Content-Type: text/x-diff; charset="iso 8859-15"; name="eliminate_deprecated_add_set_cmd.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="eliminate_deprecated_add_set_cmd.diff" Content-length: 4173 --- gdb/cli/cli-decode.c | 11 ----------- gdb/command.h | 10 ---------- gdb/gnu-nat.c | 13 +++++++++---- gdb/i386-nat.c | 14 ++++++++++---- 4 files changed, 19 insertions(+), 29 deletions(-) Index: src/gdb/cli/cli-decode.c =================================================================== --- src.orig/gdb/cli/cli-decode.c 2008-12-31 00:03:06.000000000 +0000 +++ src/gdb/cli/cli-decode.c 2008-12-31 00:45:14.000000000 +0000 @@ -407,17 +407,6 @@ add_setshow_cmd_full (char *name, *show_result = show; } -struct cmd_list_element * -deprecated_add_set_cmd (char *name, - enum command_class class, - var_types var_type, - void *var, - char *doc, - struct cmd_list_element **list) -{ - return add_set_or_show_cmd (name, set_cmd, class, var_type, var, doc, list); -} - /* Add element named NAME to command list LIST (the list for set or some sublist thereof). CLASS is as in add_cmd. ENUMLIST is a list of strings which may follow NAME. VAR is address of the variable Index: src/gdb/command.h =================================================================== --- src.orig/gdb/command.h 2008-12-31 00:03:02.000000000 +0000 +++ src/gdb/command.h 2008-12-31 00:44:58.000000000 +0000 @@ -201,16 +201,6 @@ extern void help_list (struct cmd_list_e extern void help_cmd_list (struct cmd_list_element *, enum command_class, char *, int, struct ui_file *); -/* NOTE: cagney/2005-02-21: Since every set command should be paired - with a corresponding show command (i.e., add_setshow_*) this call - should not be needed. Unfortunatly some are not (e.g., - "maintenance ") and those need to be fixed. */ -extern struct cmd_list_element *deprecated_add_set_cmd (char *name, enum - command_class class, - var_types var_type, void *var, - char *doc, - struct cmd_list_element **list); - /* Method for show a set/show variable's VALUE on FILE. If this method isn't supplied deprecated_show_value_hack() is called (which is not good). */ Index: src/gdb/gnu-nat.c =================================================================== --- src.orig/gdb/gnu-nat.c 2008-12-31 00:02:58.000000000 +0000 +++ src/gdb/gnu-nat.c 2008-12-31 00:27:56.000000000 +0000 @@ -3398,6 +3398,8 @@ to the thread's initial suspend-count wh void _initialize_gnu_nat (void) { + static struct cmd_list_element *dummy_showlist; + proc_server = getproc (); init_gnu_ops (); @@ -3405,10 +3407,13 @@ _initialize_gnu_nat (void) add_task_commands (); add_thread_commands (); - deprecated_add_set_cmd ("gnu-debug", class_maintenance, - var_boolean, (char *) &gnu_debug_flag, - "Set debugging output for the gnu backend.", - &maintenancelist); + add_setshow_boolean_cmd ("gnu-debug", class_maintenance, + &gnu_debug_flag, + _("Set debugging output for the gnu backend."), + NULL, + NULL, + &maintenancelist, + &dummy_showlist); } #ifdef FLUSH_INFERIOR_CACHE Index: src/gdb/i386-nat.c =================================================================== --- src.orig/gdb/i386-nat.c 2008-12-31 00:02:56.000000000 +0000 +++ src/gdb/i386-nat.c 2008-12-31 00:26:13.000000000 +0000 @@ -706,15 +706,21 @@ void _initialize_i386_nat (void) { #ifdef I386_USE_GENERIC_WATCHPOINTS + static struct cmd_list_element *dummy_showlist; + /* A maintenance command to enable printing the internal DRi mirror variables. */ - deprecated_add_set_cmd ("show-debug-regs", class_maintenance, - var_boolean, (char *) &maint_show_dr, _("\ -Set whether to show variables that mirror the x86 debug registers.\n\ + add_setshow_boolean_cmd ("show-debug-regs", class_maintenance, + &maint_show_dr, _("\ +Set whether to show variables that mirror the x86 debug registers."), +NULL, _("\ Use \"on\" to enable, \"off\" to disable.\n\ If enabled, the debug registers values are shown when GDB inserts\n\ or removes a hardware breakpoint or watchpoint, and when the inferior\n\ triggers a breakpoint or watchpoint."), - &maintenancelist); + NULL, + NULL, + &maintenancelist, + &dummy_showlist); #endif } --Boundary-00=_FesWJzdd4Xnuodh--