[PATCH 2/3] use zuinteger_unlimited for some remote commands

Yao Qi
2012-08-01T13:56:54Z

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.

gdb:

2012-08-01 Yao Qi <yao@codesourcery.com>

* remote.c: Add 'static' and 'unsigned' to remote_hw_watchpoint_limit,
remote_hw_watchpoint_length_limit and remote_hw_breakpoint_limit.
(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:

2012-08-01 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/remote.c | 53 ++++++++++++++++++-----------------
gdb/testsuite/gdb.base/setshow.exp | 20 +++++++++++++
2 files changed, 47 insertions(+), 26 deletions(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index 6780212..53a1e72 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -8109,17 +8109,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
@@ -8133,8 +8131,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;
}
@@ -8142,7 +8138,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;
@@ -11432,33 +11428,38 @@ 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, _("\
+ 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 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, _("\
+ 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);
+ NULL, NULL, /* FIXME: i18n: The maximum
+ number of target hardware
+ breakpoints is %s. */
+ &remote_set_cmdlist,
+ &remote_show_cmdlist);

add_setshow_integer_cmd ("remoteaddresssize", class_obscure,
&remote_address_size, _("\
diff --git a/gdb/testsuite/gdb.base/setshow.exp b/gdb/testsuite/gdb.base/setshow.exp
index 9af5c30..7821024 100644
--- a/gdb/testsuite/gdb.base/setshow.exp
+++ b/gdb/testsuite/gdb.base/setshow.exp
@@ -256,3 +256,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