diff --git a/gdb/ChangeLog b/gdb/ChangeLog index aee132ee83b..aaad736d9d1 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,22 @@ +2013-03-20 Pedro Alves + + PR gdb/15289 + + * cli/cli-setshow.c (do_set_command) + : Use LONGEST for variable holding + the result of parsing the command argument. Throw error if the + value is greater than UINT_MAX. Print the invalid value with + plongest. + : Use LONGEST for variable holding the + result of parsing the command argument. Throw error if the value + is greater than INT_MAX, not greater or equal. Also throw error + if the value is less than INT_MIN. Print the invalid value with + plongest. + : Throw error if the value is greater + than INT_MAX, not greater or equal. + (do_show_command) : Use %d for printing int, not %u. + 2013-03-20 Tom Tromey * ax-gdb.c (gen_var_ref): Unconditionally call via computed ops, diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c index 0a859c2721b..3a0e978cadf 100644 --- a/gdb/cli/cli-setshow.c +++ b/gdb/cli/cli-setshow.c @@ -272,13 +272,17 @@ do_set_command (char *arg, int from_tty, struct cmd_list_element *c) break; case var_uinteger: case var_zuinteger: - if (arg == NULL) - error_no_arg (_("integer to set it to.")); { - unsigned int val = parse_and_eval_long (arg); + LONGEST val; + + if (arg == NULL) + error_no_arg (_("integer to set it to.")); + val = parse_and_eval_long (arg); if (c->var_type == var_uinteger && val == 0) val = UINT_MAX; + else if (val > UINT_MAX) + error (_("integer %s out of range"), plongest (val)); if (*(unsigned int *) c->var != val) { @@ -291,15 +295,16 @@ do_set_command (char *arg, int from_tty, struct cmd_list_element *c) case var_integer: case var_zinteger: { - unsigned int val; + LONGEST val; if (arg == NULL) error_no_arg (_("integer to set it to.")); val = parse_and_eval_long (arg); + if (val == 0 && c->var_type == var_integer) val = INT_MAX; - else if (val >= INT_MAX) - error (_("integer %u out of range"), val); + else if (val > INT_MAX || val < INT_MIN) + error (_("integer %s out of range"), plongest (val)); if (*(int *) c->var != val) { @@ -387,7 +392,7 @@ do_set_command (char *arg, int from_tty, struct cmd_list_element *c) error_no_arg (_("integer to set it to.")); val = parse_and_eval_long (arg); - if (val >= INT_MAX) + if (val > INT_MAX) error (_("integer %s out of range"), plongest (val)); else if (val < -1) error (_("only -1 is allowed to set as unlimited")); @@ -588,7 +593,7 @@ do_show_command (char *arg, int from_tty, struct cmd_list_element *c) if (*(int *) c->var == -1) fputs_filtered ("unlimited", stb); else - fprintf_filtered (stb, "%u", *(int *) c->var); + fprintf_filtered (stb, "%d", *(int *) c->var); } break; default: diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index bb4977bfd84..b3a444d8623 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2013-03-20 Pedro Alves + + PR gdb/15289 + + * gdb.base/remote.exp: Test + "set remote hardware-watchpoint-limit -1", + "set remote hardware-breakpoint-limit -1", + "set remote hardware-watchpoint-limit 2147483647" and + "set remote hardware-breakpoint-limit 2147483647". + 2013-03-20 Pedro Alves Yao Qi diff --git a/gdb/testsuite/gdb.base/remote.exp b/gdb/testsuite/gdb.base/remote.exp index dea9bdcb0b5..dfaf646ef35 100644 --- a/gdb/testsuite/gdb.base/remote.exp +++ b/gdb/testsuite/gdb.base/remote.exp @@ -155,4 +155,14 @@ gdb_test "show remote memory-read-packet-size" \ gdb_test "x/17ub random_data" \ ":\[ \t\]+60\[ \t\]+74\[ \t\]+216\[ \t\]+38\[ \t\]+149\[ \t\]+49\[ \t\]+207\[ \t\]+44.*:\[ \t\]+124\[ \t\]+38\[ \t\]+93\[ \t\]+125\[ \t\]+232\[ \t\]+67\[ \t\]+228\[ \t\]+56.*:\[ \t\]+161" +# Regression test for gdb/15289. Make sure -1 is accepted and handled +# as "unlimited". +gdb_test_no_output "set remote hardware-watchpoint-limit -1" +gdb_test_no_output "set remote hardware-breakpoint-limit -1" + +# This is just being thorough. Assume (at least) a 32-bit host int, +# and make sure 32-bit INT_MAX is accepted by a zinteger command. +gdb_test_no_output "set remote hardware-watchpoint-limit 2147483647" +gdb_test_no_output "set remote hardware-breakpoint-limit 2147483647" + gdb_exit