From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 1/2] Check the range
Date: Sun, 09 Sep 2012 03:23:00 -0000 [thread overview]
Message-ID: <1347160965-24089-2-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1347160965-24089-1-git-send-email-yao@codesourcery.com>
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
next prev parent reply other threads:[~2012-09-09 3:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-09 3:23 [2nd try, RFC 0/2] Fix 'set remote XXX-limit -1' and 'set listisize' Yao Qi
2012-09-09 3:23 ` Yao Qi [this message]
2012-09-09 3:24 ` [PATCH 2/2] Update doc and test of 'set listsize' Yao Qi
2012-09-09 17:27 ` Eli Zaretskii
2012-09-14 18:55 ` [2nd try, RFC 0/2] Fix 'set remote XXX-limit -1' and 'set listisize' Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1347160965-24089-2-git-send-email-yao@codesourcery.com \
--to=yao@codesourcery.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox