From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6582 invoked by alias); 15 Feb 2013 13:29:10 -0000 Received: (qmail 6555 invoked by uid 22791); 15 Feb 2013 13:29:09 -0000 X-SWARE-Spam-Status: No, hits=-4.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,TW_BP X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 15 Feb 2013 13:28:58 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1U6LLW-0002t4-3P from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Fri, 15 Feb 2013 05:28:58 -0800 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 15 Feb 2013 05:28:58 -0800 Received: from qiyao.dyndns.org.dyndns.org (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.1.289.1; Fri, 15 Feb 2013 05:28:56 -0800 From: Yao Qi To: Subject: [PATCH 1/2] use zuinteger_unlimited for some remote commands Date: Fri, 15 Feb 2013 13:29:00 -0000 Message-ID: <1360934868-5807-2-git-send-email-yao@codesourcery.com> In-Reply-To: <1360934868-5807-1-git-send-email-yao@codesourcery.com> References: <1360934868-5807-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2013-02/txt/msg00390.txt.bz2 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 * 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 * 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