From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 1/2] use zuinteger_unlimited for some remote commands
Date: Fri, 15 Feb 2013 13:29:00 -0000 [thread overview]
Message-ID: <1360934868-5807-2-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1360934868-5807-1-git-send-email-yao@codesourcery.com>
Hi,
These 'set remot XXX-limit' commands have the similar requirements to
'set listsize', so I convert them from zinteger_cmd to
zuinteger_unlimited_cmd. New tests are added to check these commands
work correctly.
Previously, without this patch, negative means unlimited, but after
this patch applied, only -1 means unlimited. Other negative numbers
are invalid. However, the doc says -1 is treated as unlimited, as
below,
set remote hardware-watchpoint-limit limit
set remote hardware-breakpoint-limit limit
Restrict gdb to using limit remote hardware breakpoint or watchpoints.
A limit of -1, the default, is treated as unlimited.
set remote hardware-watchpoint-length-limit limit
Restrict gdb to using limit bytes for the maximum length of a remote
hardware watchpoint. A limit of -1, the default, is treated as
unlimited.
So patched GDB is still compatible with old GDB on documented
behavior, so we don't have to update doc and mention this change in
NEWS.
gdb:
2013-02-15 Yao Qi <yao@codesourcery.com>
* remote.c (remote_hw_watchpoint_limit): Make it 'static' and
change it to 'unsigned'.
(remote_hw_watchpoint_length_limit): Likewise.
(remote_hw_breakpoint_limit): Likewise.
(remote_region_ok_for_hw_watchpoint): Don't check the case 'limit' is less
than 0.
(remote_check_watch_resources): Likewise.
(_initialize_remote): Call add_setshow_zuinteger_unlimited_cmd instead of
add_setshow_zinteger_cmd.
gdb/testsuite:
2013-02-15 Yao Qi <yao@codesourcery.com>
* gdb.base/setshow.exp: Test for setting and showing
hardware-watchpoint-limit, hardware-watchpoint-length-limit and
hardware-breakpoint-limit.
---
gdb/remote.c | 73 ++++++++++++++++++++---------------
gdb/testsuite/gdb.base/setshow.exp | 20 ++++++++++
2 files changed, 62 insertions(+), 31 deletions(-)
diff --git a/gdb/remote.c b/gdb/remote.c
index 18fe61d..b30ba37 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -8226,17 +8226,15 @@ remote_remove_watchpoint (CORE_ADDR addr, int len, int type,
}
-int remote_hw_watchpoint_limit = -1;
-int remote_hw_watchpoint_length_limit = -1;
-int remote_hw_breakpoint_limit = -1;
+static unsigned int remote_hw_watchpoint_limit = UINT_MAX;
+static unsigned int remote_hw_watchpoint_length_limit = UINT_MAX;
+static unsigned int remote_hw_breakpoint_limit = UINT_MAX;
static int
remote_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
{
if (remote_hw_watchpoint_length_limit == 0)
return 0;
- else if (remote_hw_watchpoint_length_limit < 0)
- return 1;
else if (len <= remote_hw_watchpoint_length_limit)
return 1;
else
@@ -8250,8 +8248,6 @@ remote_check_watch_resources (int type, int cnt, int ot)
{
if (remote_hw_breakpoint_limit == 0)
return 0;
- else if (remote_hw_breakpoint_limit < 0)
- return 1;
else if (cnt <= remote_hw_breakpoint_limit)
return 1;
}
@@ -8259,7 +8255,7 @@ remote_check_watch_resources (int type, int cnt, int ot)
{
if (remote_hw_watchpoint_limit == 0)
return 0;
- else if (remote_hw_watchpoint_limit < 0)
+ else if (remote_hw_watchpoint_limit == UINT_MAX)
return 1;
else if (ot)
return -1;
@@ -11551,33 +11547,48 @@ further restriction and ``limit'' to enable that restriction."),
_("Show the maximum number of bytes per memory-read packet."),
&remote_show_cmdlist);
- add_setshow_zinteger_cmd ("hardware-watchpoint-limit", no_class,
- &remote_hw_watchpoint_limit, _("\
+ add_setshow_zuinteger_unlimited_cmd ("hardware-watchpoint-limit",
+ no_class,
+ &remote_hw_watchpoint_limit,
+ _("\
Set the maximum number of target hardware watchpoints."), _("\
Show the maximum number of target hardware watchpoints."), _("\
-Specify a negative limit for unlimited."),
- NULL, NULL, /* FIXME: i18n: The maximum
- number of target hardware
- watchpoints is %s. */
- &remote_set_cmdlist, &remote_show_cmdlist);
- add_setshow_zinteger_cmd ("hardware-watchpoint-length-limit", no_class,
- &remote_hw_watchpoint_length_limit, _("\
-Set the maximum length (in bytes) of a target hardware watchpoint."), _("\
-Show the maximum length (in bytes) of a target hardware watchpoint."), _("\
-Specify a negative limit for unlimited."),
- NULL, NULL, /* FIXME: i18n: The maximum
- length (in bytes) of a target
- hardware watchpoint is %s. */
- &remote_set_cmdlist, &remote_show_cmdlist);
- add_setshow_zinteger_cmd ("hardware-breakpoint-limit", no_class,
- &remote_hw_breakpoint_limit, _("\
+Specify -1 for unlimited."),
+ NULL,
+ NULL, /* FIXME: i18n: The maximum
+ number of target hardware
+ watchpoints is %s. */
+ &remote_set_cmdlist,
+ &remote_show_cmdlist);
+ add_setshow_zuinteger_unlimited_cmd ("hardware-watchpoint-length-limit",
+ no_class,
+ &remote_hw_watchpoint_length_limit,
+ _("\
+Set the maximum length (in bytes) of a target hardware watchpoint."),
+ _("\
+Show the maximum length (in bytes) of a target hardware watchpoint."),
+ _("\
+Specify -1 for unlimited."),
+ NULL,
+ NULL, /* FIXME: i18n: The maximum
+ length (in bytes) of a
+ target hardware watchpoint
+ is %s. */
+ &remote_set_cmdlist,
+ &remote_show_cmdlist);
+ add_setshow_zuinteger_unlimited_cmd ("hardware-breakpoint-limit",
+ no_class,
+ &remote_hw_breakpoint_limit,
+ _("\
Set the maximum number of target hardware breakpoints."), _("\
Show the maximum number of target hardware breakpoints."), _("\
-Specify a negative limit for unlimited."),
- NULL, NULL, /* FIXME: i18n: The maximum
- number of target hardware
- breakpoints is %s. */
- &remote_set_cmdlist, &remote_show_cmdlist);
+Specify -1 for unlimited."),
+ NULL,
+ NULL, /* FIXME: i18n: The maximum
+ number of target hardware
+ breakpoints is %s. */
+ &remote_set_cmdlist,
+ &remote_show_cmdlist);
add_setshow_uinteger_cmd ("remoteaddresssize", class_obscure,
&remote_address_size, _("\
diff --git a/gdb/testsuite/gdb.base/setshow.exp b/gdb/testsuite/gdb.base/setshow.exp
index eadd1f5..ed35dc9 100644
--- a/gdb/testsuite/gdb.base/setshow.exp
+++ b/gdb/testsuite/gdb.base/setshow.exp
@@ -258,3 +258,23 @@ 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 unlimited.*" \
+ "show remote ${remote_bpkt_option} unlimited 1"
+ gdb_test_no_output "set remote ${remote_bpkt_option} 1"
+
+ gdb_test "set remote ${remote_bpkt_option} -2" \
+ "only -1 is allowed to set as unlimited.*"
+
+ gdb_test_no_output "set remote ${remote_bpkt_option} -1"
+ gdb_test "show remote ${remote_bpkt_option}" \
+ "The maximum .* is unlimited.*" \
+ "show remote ${remote_bpkt_option} unlimited 2"
+}
+
--
1.7.7.6
next prev parent reply other threads:[~2013-02-15 13:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-15 13:29 [PATCH 0/2] Use zuinteger_unlimited Yao Qi
2013-02-15 13:29 ` Yao Qi [this message]
2013-03-04 13:19 ` [PATCH 1/2] use zuinteger_unlimited for some remote commands Pedro Alves
2013-03-04 14:38 ` Yao Qi
2013-03-04 16:21 ` Pedro Alves
2013-03-05 7:45 ` Yao Qi
2013-03-05 12:59 ` Pedro Alves
2013-03-05 17:33 ` Doug Evans
2013-03-05 18:07 ` Pedro Alves
2013-03-06 0:30 ` Doug Evans
2013-02-15 13:29 ` [PATCH 2/2] use zuinteger_unlimited for heuristic-fence-post Yao Qi
2013-02-25 3:15 ` ping : [PATCH 0/2] Use zuinteger_unlimited Yao Qi
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=1360934868-5807-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