2009-01-23 Pedro Alves <pedro@codesourcery.com>
authorPedro Alves <palves@redhat.com>
Fri, 23 Jan 2009 18:47:46 +0000 (18:47 +0000)
committerPedro Alves <palves@redhat.com>
Fri, 23 Jan 2009 18:47:46 +0000 (18:47 +0000)
* cli/cli-decode.c (add_setshow_zuinteger_cmd): New.
* cli/cli-setshow.c (do_setshow_command): Handle it.
* command.h (enum var_types): Add var_zuinteger.
(add_setshow_zuinteger_cmd): Declare.

* valprint.c (_initialize_valprint): Change the set input-radix
and set output-radix commands to zuinteger type.

2009-01-23  Pedro Alves  <pedro@codesourcery.com>

* gdb.base/radix.exp: Add tests to ensure that that set
input-radix 0 and set output-radix 0 are really rejected.

gdb/ChangeLog
gdb/cli/cli-decode.c
gdb/cli/cli-setshow.c
gdb/command.h
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/radix.exp
gdb/valprint.c

index d6b611ed4861fb678e20defdb5f8f797ec3eabff..e85963d6db257b7d7c60d81b91ae5c25c9553903 100644 (file)
@@ -1,3 +1,13 @@
+2009-01-23  Pedro Alves  <pedro@codesourcery.com>
+
+       * cli/cli-decode.c (add_setshow_zuinteger_cmd): New.
+       * cli/cli-setshow.c (do_setshow_command): Handle it.
+       * command.h (enum var_types): Add var_zuinteger.
+       (add_setshow_zuinteger_cmd): Declare.
+
+       * valprint.c (_initialize_valprint): Change the set input-radix
+       and set output-radix commands to zuinteger type.
+
 2009-01-23  Pedro Alves  <pedro@codesourcery.com>
 
        PR gdb/9664:
index d71d516975dc159db24b300a510e1d6b7075d2dd..556c0278a843855fde27edfb2892c5bfd7a31477 100644 (file)
@@ -639,6 +639,27 @@ add_setshow_zinteger_cmd (char *name, enum command_class class,
                        NULL, NULL);
 }
 
+/* Add element named NAME to both the set and show command LISTs (the
+   list for set/show or some sublist thereof).  CLASS is as in
+   add_cmd.  VAR is address of the variable which will contain the
+   value.  SET_DOC and SHOW_DOC are the documentation strings.  */
+void
+add_setshow_zuinteger_cmd (char *name, enum command_class class,
+                          unsigned int *var,
+                          const char *set_doc, const char *show_doc,
+                          const char *help_doc,
+                          cmd_sfunc_ftype *set_func,
+                          show_value_ftype *show_func,
+                          struct cmd_list_element **set_list,
+                          struct cmd_list_element **show_list)
+{
+  add_setshow_cmd_full (name, class, var_zuinteger, var,
+                       set_doc, show_doc, help_doc,
+                       set_func, show_func,
+                       set_list, show_list,
+                       NULL, NULL);
+}
+
 /* Remove the command named NAME from the command list.  Return the
    list commands which were aliased to the deleted command.  If the
    command had no aliases, return NULL.  The various *HOOKs are set to
index be0581de85fca9f794c3e48c524bee6ec6e9c527..206a55d8f0b4dbd68d038f885085dd4f7f58b957 100644 (file)
@@ -232,6 +232,11 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
            error_no_arg (_("integer to set it to."));
          *(int *) c->var = parse_and_eval_long (arg);
          break;
+       case var_zuinteger:
+         if (arg == NULL)
+           error_no_arg (_("integer to set it to."));
+         *(unsigned int *) c->var = parse_and_eval_long (arg);
+         break;
        case var_enum:
          {
            int i;
@@ -351,6 +356,7 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
              break;
            }
          /* else fall through */
+       case var_zuinteger:
        case var_zinteger:
          fprintf_filtered (stb->stream, "%u", *(unsigned int *) c->var);
          break;
index 1aeca6bbb301480c31fdb6f66eb0c6e32ad7b6c4..b3f7013077fc52dd2ee13a5c6989941ad1f4ddbd 100644 (file)
@@ -87,6 +87,9 @@ typedef enum var_types
     /* ZeroableInteger.  *VAR is an int.  Like Unsigned Integer except
        that zero really means zero.  */
     var_zinteger,
+    /* ZeroableUnsignedInteger.  *VAR is an unsigned int.  Zero really
+       means zero.  */
+    var_zuinteger,
     /* Enumerated type.  Can only have one of the specified values.  *VAR is a
        char pointer to the name of the element that we find.  */
     var_enum
@@ -332,6 +335,17 @@ extern void add_setshow_zinteger_cmd (char *name,
                                      struct cmd_list_element **set_list,
                                      struct cmd_list_element **show_list);
 
+extern void add_setshow_zuinteger_cmd (char *name,
+                                      enum command_class class,
+                                      unsigned int *var,
+                                      const char *set_doc,
+                                      const char *show_doc,
+                                      const char *help_doc,
+                                      cmd_sfunc_ftype *set_func,
+                                      show_value_ftype *show_func,
+                                      struct cmd_list_element **set_list,
+                                      struct cmd_list_element **show_list);
+
 /* Do a "show" command for each thing on a command list.  */
 
 extern void cmd_show_list (struct cmd_list_element *, int, char *);
index 49390752ac9b81d85a93e3d00079bac542080924..4e60fa045494ecca2d4ac2b0c1e6dc7c27528f89 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-23  Pedro Alves  <pedro@codesourcery.com>
+
+       * gdb.base/radix.exp: Add tests to ensure that that set
+       input-radix 0 and set output-radix 0 are really rejected.
+
 2009-01-23  Pedro Alves  <pedro@codesourcery.com>
 
        * gdb.base/hook-stop-frame.c, gdb.base/hook-stop-frame.exp: Update
index 172e40f151897c9d73911125ddb57a449f503734..750fd234a3949628e3723cbc43218f080a754588 100644 (file)
@@ -162,19 +162,32 @@ gdb_test "set radix" \
     "Input and output radices now set to decimal 10, hex a, octal 12\." \
     "Reset radices"
 
+gdb_test "set input-radix 0" \
+    "Nonsense input radix ``decimal 0''; input radix unchanged\\." \
+    "Reject input-radix 0"
+gdb_test "show input-radix" \
+    "Default input radix for entering numbers is 10\\." \
+    "Input radix unchanged after rejecting 0"
+
 gdb_test "set input-radix 1" \
     "Nonsense input radix ``decimal 1''; input radix unchanged\\." \
     "Reject input-radix 1"
 gdb_test "show input-radix" \
     "Default input radix for entering numbers is 10\\." \
-    "Input radix unchanged after rejection"
+    "Input radix unchanged after rejecting 1"
 
+gdb_test "set output-radix 0" \
+    "Unsupported output radix ``decimal 0''; output radix unchanged\\." \
+    "Reject output-radix 0"
+gdb_test "show output-radix" \
+    "Default output radix for printing of values is 10\\." \
+    "Output radix unchanged after rejecting 0"
 gdb_test "set output-radix 1" \
     "Unsupported output radix ``decimal 1''; output radix unchanged\\." \
     "Reject output-radix 1"
 gdb_test "show output-radix" \
     "Default output radix for printing of values is 10\\." \
-    "Output radix unchanged after rejection"
+    "Output radix unchanged after rejecting 1"
 
 gdb_test "set radix 7" \
     "Unsupported output radix ``decimal 7''; output radix unchanged\\." \
index 73d9a99b0d8ca874af2d0b652bc98b28e8ab1c0e..b61da54c38aadae5846de621a964395cb72497f2 100644 (file)
@@ -1576,21 +1576,21 @@ Show printing of addresses."), NULL,
                           show_addressprint,
                           &setprintlist, &showprintlist);
 
-  add_setshow_uinteger_cmd ("input-radix", class_support, &input_radix_1,
-                           _("\
+  add_setshow_zuinteger_cmd ("input-radix", class_support, &input_radix_1,
+                            _("\
 Set default input radix for entering numbers."), _("\
 Show default input radix for entering numbers."), NULL,
-                           set_input_radix,
-                           show_input_radix,
-                           &setlist, &showlist);
+                            set_input_radix,
+                            show_input_radix,
+                            &setlist, &showlist);
 
-  add_setshow_uinteger_cmd ("output-radix", class_support, &output_radix_1,
-                           _("\
+  add_setshow_zuinteger_cmd ("output-radix", class_support, &output_radix_1,
+                            _("\
 Set default output radix for printing of values."), _("\
 Show default output radix for printing of values."), NULL,
-                           set_output_radix,
-                           show_output_radix,
-                           &setlist, &showlist);
+                            set_output_radix,
+                            show_output_radix,
+                            &setlist, &showlist);
 
   /* The "set radix" and "show radix" commands are special in that
      they are like normal set and show commands but allow two normally
This page took 0.042123 seconds and 4 git commands to generate.