This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

eliminate deprecated_add_set_cmd


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 <tab>' 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
---
 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 <variable> <value>") 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
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]