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>

	* gdb.base/radix.exp: Add tests to ensure that that set
	input-radix 0 and set output-radix 0 are really rejected.
This commit is contained in:
Pedro Alves 2009-01-23 18:47:46 +00:00
parent 278df34e12
commit 1e8fb9762b
7 changed files with 81 additions and 12 deletions

View 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:

View 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

View 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;

View 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 *);

View 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

View 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\\." \

View 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