Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 2/3] use zuinteger_unlimited for some remote commands
Date: Wed, 01 Aug 2012 13:56:00 -0000	[thread overview]
Message-ID: <1343829334-3151-3-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1343829334-3151-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.

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


  parent reply	other threads:[~2012-08-01 13:56 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-18 12:52 [PATCH] Handle var_uinteger/var_zuinteger and case var_integer/var_zinteger together Yao Qi
2012-07-24 12:51 ` [committed]: " Yao Qi
2012-07-27 17:40 ` Khoo Yit Phang
2012-07-29 14:25   ` Yao Qi
2012-08-01 13:56   ` [RFC 0/3] New var_types var_zuinteger_unlimited Yao Qi
2012-08-01 13:56     ` [PATCH 3/3] use zuinteger_unlimited for heuristic-fence-post Yao Qi
2012-08-01 13:56     ` Yao Qi [this message]
2012-08-01 13:56     ` [PATCH 1/3] var_zuinteger_unlimited and 'set listsize' Yao Qi
2012-08-01 16:14       ` Eli Zaretskii
2012-08-02  8:34       ` Doug Evans
2012-08-02 12:53         ` Yao Qi
2012-08-13 15:28   ` [RFC 0/3] Get rid of var_integer in CLI Yao Qi
2012-08-13 15:28     ` [PATCH 1/3] var_integer -> var_uinteger Yao Qi
2012-08-23 18:20       ` dje
2012-08-24  6:56         ` Yao Qi
2012-08-24 17:06           ` dje
2012-08-27 10:10             ` Yao Qi
2012-08-27 22:14               ` dje
2012-08-28 14:09                 ` [committed]: " Yao Qi
2013-03-25 22:55                   ` Change "set history size" back to signed (Re: [committed]: [PATCH 1/3] var_integer -> var_uinteger) Pedro Alves
2013-03-26 16:48                     ` Yao Qi
2013-03-26 17:48                       ` Pedro Alves
2013-03-27  8:54                         ` Yao Qi
2013-03-27 17:34                           ` Pedro Alves
2012-08-13 15:28     ` [PATCH 2/3] var_integer -> var_zuinteger_unlimited Yao Qi
2012-08-13 17:54       ` Eli Zaretskii
2012-09-14 18:12       ` Tom Tromey
2012-09-17  8:43         ` [committed]: " Yao Qi
2012-08-13 15:28     ` [PATCH 3/3] comments update Yao Qi
2012-09-14 18:13       ` Tom Tromey
2012-08-22 14:30     ` [ping] : [RFC 0/3] Get rid of var_integer in CLI 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=1343829334-3151-3-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