[RFC] Register commands using add_setshow_zuinteger_cmd

Yao Qi yao@codesourcery.com
Mon Jul 30 13:58:00 GMT 2012


Hi,
I am examing the usage of zuinteger_cmd and zinteger_cmd today, and I find
that a lot of zinteger_cmd commands should be registered as zuinteger_cmd.
For example, all the debug commands, such as 'set debug infrun 1' should
be registered as 'zuinteger_cmd', because we never do 'set debug FOO -2'.

This patch is not indented to commit anything to CVS, but describe what I
try to do.  If it is the right way to go, I'll convert other zinteger_cmd
to zuinteger_cmd if appropriate.  What do you think?

gdb:

2012-07-30  Yao Qi  <yao@codesourcery.com>

	* serial.c (global_serial_debug_p): Add 'unsigned'.
	(_initialize_serial): Call add_setshow_zuinteger_cmd instead of
	add_setshow_zinteger_cmd.
	* target.c (targetdebug): Add 'unsigned'.
	(initialize_targets): Call add_setshow_zuinteger_cmd instead of
	add_setshow_zinteger_cmd.
---
 gdb/serial.c |   12 ++++++------
 gdb/target.c |   10 +++++-----
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/gdb/serial.c b/gdb/serial.c
index df18b2f..62d7fa9 100644
--- a/gdb/serial.c
+++ b/gdb/serial.c
@@ -27,7 +27,7 @@ extern void _initialize_serial (void);
 
 /* Is serial being debugged?  */
 
-static int global_serial_debug_p;
+static unsigned int global_serial_debug_p;
 
 /* Linked list of serial I/O handlers.  */
 
@@ -671,12 +671,12 @@ Show numerical base for remote session logging"), NULL,
 			NULL, /* FIXME: i18n: */
 			&setlist, &showlist);
 
-  add_setshow_zinteger_cmd ("serial", class_maintenance,
-			    &global_serial_debug_p, _("\
+  add_setshow_zuinteger_cmd ("serial", class_maintenance,
+			     &global_serial_debug_p, _("\
 Set serial debugging."), _("\
 Show serial debugging."), _("\
 When non-zero, serial port debugging is enabled."),
-			    NULL,
-			    NULL, /* FIXME: i18n: */
-			    &setdebuglist, &showdebuglist);
+			     NULL,
+			     NULL, /* FIXME: i18n: */
+			     &setdebuglist, &showdebuglist);
 }
diff --git a/gdb/target.c b/gdb/target.c
index ae31415..1fc8802 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -205,7 +205,7 @@ int may_stop = 1;
 
 /* Non-zero if we want to see trace of target level stuff.  */
 
-static int targetdebug = 0;
+static unsigned int targetdebug = 0;
 static void
 show_targetdebug (struct ui_file *file, int from_tty,
 		  struct cmd_list_element *c, const char *value)
@@ -4774,15 +4774,15 @@ initialize_targets (void)
   add_info ("target", target_info, targ_desc);
   add_info ("files", target_info, targ_desc);
 
-  add_setshow_zinteger_cmd ("target", class_maintenance, &targetdebug, _("\
+  add_setshow_zuinteger_cmd ("target", class_maintenance, &targetdebug, _("\
 Set target debugging."), _("\
 Show target debugging."), _("\
 When non-zero, target debugging is enabled.  Higher numbers are more\n\
 verbose.  Changes do not take effect until the next \"run\" or \"target\"\n\
 command."),
-			    NULL,
-			    show_targetdebug,
-			    &setdebuglist, &showdebuglist);
+			     NULL,
+			     show_targetdebug,
+			     &setdebuglist, &showdebuglist);
 
   add_setshow_boolean_cmd ("trust-readonly-sections", class_support,
 			   &trust_readonly, _("\
-- 
1.7.7.6



More information about the Gdb-patches mailing list