This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 1/2] Check the range


This patch is to check the range of various command input, and also
fixes one regression on 'set remote XXX-limit -1'.

  (gdb) set remote hardware-watchpoint-limit -1
  integer 4294967295 out of range

The new added tests expose existing regression on unpatched GDB,

FAIL: gdb.base/setshow.exp: set remote hardware-watchpoint-limit -1
FAIL: gdb.base/setshow.exp: show remote hardware-watchpoint-limit -1 (2)
FAIL: gdb.base/setshow.exp: set remote hardware-watchpoint-length-limit -1
FAIL: gdb.base/setshow.exp: show remote hardware-watchpoint-length-limit -1 (2)
FAIL: gdb.base/setshow.exp: set remote hardware-breakpoint-limit -1
FAIL: gdb.base/setshow.exp: show remote hardware-breakpoint-limit -1 (2)

This patch fixes these fails, but causes another regression,

  -PASS: gdb.base/list.exp: show listsize unlimited #7
  +FAIL: gdb.base/list.exp: show listsize unlimited #7

The next patch is to fix this regression on 'set listsize'.

gdb:

2012-09-09  Yao Qi  <yao@codesourcery.com>
	    Mark Kettenis  <kettenis@gnu.org>

	* cli/cli-setshow.c (do_set_command): Check the range of value
	for var_uinteger, var_zuinteger, var_zinteger and var_integer.

gdb/testsuite:

2012-09-09  Yao Qi  <yao@codesourcery.com>

	* gdb.base/setshow.exp: Test for setting ahd showing
	hardware-watchpoint-limit, hardware-watchpoint-length-limit and
	hardware-breakpoint-limit.
---
 gdb/cli/cli-setshow.c              |   12 ++++++++----
 gdb/testsuite/gdb.base/setshow.exp |   17 +++++++++++++++++
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index 9d8cb2e..7140479 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -275,7 +275,10 @@ do_set_command (char *arg, int from_tty, struct cmd_list_element *c)
       if (arg == NULL)
 	error_no_arg (_("integer to set it to."));
       {
-	unsigned int val = parse_and_eval_long (arg);
+	LONGEST val = parse_and_eval_long (arg);
+
+	if (val < 0 || val > UINT_MAX)
+	  error (_("integer %s out of range"), plongest (val));
 
 	if (c->var_type == var_uinteger && val == 0)
 	  val = UINT_MAX;
@@ -291,15 +294,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_MIN || val >= INT_MAX)
+	  error (_("integer %s out of range"), plongest (val));
 
 	if (*(int *) c->var != val)
 	  {
diff --git a/gdb/testsuite/gdb.base/setshow.exp b/gdb/testsuite/gdb.base/setshow.exp
index d33e185..3a3e58f 100644
--- a/gdb/testsuite/gdb.base/setshow.exp
+++ b/gdb/testsuite/gdb.base/setshow.exp
@@ -259,3 +259,20 @@ gdb_test "show verbose" "Verbose printing of informational messages is on..*" "s
 gdb_test_no_output "set verbose off" "set verbose off" 
 #test show verbose off
 gdb_test "show verbose" "Verbosity is off..*" "show verbose (off)" 
+
+foreach remote_bpkt_option {
+    "hardware-watchpoint-limit"
+    "hardware-watchpoint-length-limit"
+    "hardware-breakpoint-limit"
+} {
+    gdb_test "show remote ${remote_bpkt_option}" \
+	"The maximum .* is -1.*" \
+	"show remote ${remote_bpkt_option} -1 (1)"
+    gdb_test_no_output "set remote ${remote_bpkt_option} 1"
+
+    gdb_test_no_output "set remote ${remote_bpkt_option} -1"
+    gdb_test "show remote ${remote_bpkt_option}" \
+	"The maximum .* is -1.*" \
+	"show remote ${remote_bpkt_option} -1 (2)"
+}
+
-- 
1.7.7.6


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]