aboutsummaryrefslogtreecommitdiff
path: root/gdb/valprint.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2008-12-29 02:18:48 +0000
committerPedro Alves <palves@redhat.com>2008-12-29 02:18:48 +0000
commit09e6485fa9d137478b21711ab590b98c9135ed96 (patch)
treebea132c51eea18fb4b38b281593385d2f4b9550c /gdb/valprint.c
parentb828adc616ce19f60b552742361ebb5da3a6c220 (diff)
downloadgdb-09e6485fa9d137478b21711ab590b98c9135ed96.zip
gdb-09e6485fa9d137478b21711ab590b98c9135ed96.tar.gz
gdb-09e6485fa9d137478b21711ab590b98c9135ed96.tar.bz2
2008-12-29 Pedro Alves <pedro@codesourcery.com>
PR gdb/7536: * valprint.c (input_radix_1): New static global. (set_input_radix): Use it instead of "input_radix". (set_input_radix_1): Always leave input_radix_1 set to input_radix. (output_radix_1): New static global. (set_output_radix): Use it instead of "output_radix". (set_output_radix_1): Always leave output_radix_1 set to output_radix. (_initialize_valprint): Use "input_radix_1" instead of "input_radix" with the "input-radix" command. Use "output_radix_1" instead of "output_radix" with the "output-radix" command. 2008-12-29 Pedro Alves <pedro@codesourcery.com> PR gdb/7536: * gdb.base/radix.exp: Add tests to ensure invalid input radices and unsupported output radices are really rejected.
Diffstat (limited to 'gdb/valprint.c')
-rw-r--r--gdb/valprint.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 6bcb2f8..d1f2fdb 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1359,6 +1359,12 @@ val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream,
}
+/* The 'set input-radix' command writes to this auxiliary variable.
+ If the requested radix is valid, INPUT_RADIX is updated; otherwise,
+ it is left unchanged. */
+
+static unsigned input_radix_1 = 10;
+
/* Validate an input or output radix setting, and make sure the user
knows what they really did here. Radix setting is confusing, e.g.
setting the input radix to "10" never changes it! */
@@ -1366,7 +1372,7 @@ val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream,
static void
set_input_radix (char *args, int from_tty, struct cmd_list_element *c)
{
- set_input_radix_1 (from_tty, input_radix);
+ set_input_radix_1 (from_tty, input_radix_1);
}
static void
@@ -1381,12 +1387,11 @@ set_input_radix_1 (int from_tty, unsigned radix)
if (radix < 2)
{
- /* FIXME: cagney/2002-03-17: This needs to revert the bad radix
- value. */
+ input_radix_1 = input_radix;
error (_("Nonsense input radix ``decimal %u''; input radix unchanged."),
radix);
}
- input_radix = radix;
+ input_radix_1 = input_radix = radix;
if (from_tty)
{
printf_filtered (_("Input radix now set to decimal %u, hex %x, octal %o.\n"),
@@ -1394,10 +1399,16 @@ set_input_radix_1 (int from_tty, unsigned radix)
}
}
+/* The 'set output-radix' command writes to this auxiliary variable.
+ If the requested radix is valid, OUTPUT_RADIX is updated,
+ otherwise, it is left unchanged. */
+
+static unsigned output_radix_1 = 10;
+
static void
set_output_radix (char *args, int from_tty, struct cmd_list_element *c)
{
- set_output_radix_1 (from_tty, output_radix);
+ set_output_radix_1 (from_tty, output_radix_1);
}
static void
@@ -1417,12 +1428,11 @@ set_output_radix_1 (int from_tty, unsigned radix)
user_print_options.output_format = 'o'; /* octal */
break;
default:
- /* FIXME: cagney/2002-03-17: This needs to revert the bad radix
- value. */
+ output_radix_1 = output_radix;
error (_("Unsupported output radix ``decimal %u''; output radix unchanged."),
radix);
}
- output_radix = radix;
+ output_radix_1 = output_radix = radix;
if (from_tty)
{
printf_filtered (_("Output radix now set to decimal %u, hex %x, octal %o.\n"),
@@ -1566,14 +1576,16 @@ Show printing of addresses."), NULL,
show_addressprint,
&setprintlist, &showprintlist);
- add_setshow_uinteger_cmd ("input-radix", class_support, &input_radix, _("\
+ add_setshow_uinteger_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);
- add_setshow_uinteger_cmd ("output-radix", class_support, &output_radix, _("\
+ add_setshow_uinteger_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,