From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19597 invoked by alias); 7 Nov 2013 11:43:54 -0000 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 Received: (qmail 19588 invoked by uid 89); 7 Nov 2013 11:43:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=3.1 required=5.0 tests=AWL,BAYES_50,FAKE_REPLY_C,RDNS_NONE,SPAM_SUBJECT,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: aserp1040.oracle.com Received: from Unknown (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 07 Nov 2013 11:43:27 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id rA7BhId6023385 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 7 Nov 2013 11:43:19 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rA7BhHJQ020577 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 7 Nov 2013 11:43:18 GMT Received: from abhmt107.oracle.com (abhmt107.oracle.com [141.146.116.59]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rA7BhHlB009267 for ; Thu, 7 Nov 2013 11:43:17 GMT Received: from termi.oracle.com (/10.175.51.157) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 07 Nov 2013 03:43:16 -0800 From: jose.marchesi@oracle.com (Jose E. Marchesi) To: gdb-patches@sourceware.org Subject: Re: [PATCH] hardware watchpoints turned off, inferior not yet started Date: Thu, 07 Nov 2013 12:21:00 -0000 Message-ID: <87fvr8xwo8.fsf@oracle.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2013-11/txt/msg00169.txt.bz2 [Following https://sourceware.org/ml/gdb-patches/2013-10/msg00563.html] Hi. The patch posted above introduced a regression in sparc64-*-linux-gnu, and possibly in other targets not supporting hardware watchpoints at all. Today I was surprised to find this in a sparc64-*-linux-gnu target: $ gdb foo ... intro text ... (gdb) watch global_var Hardware watchpoint 1: global_var The cause for this regression is this code in update_watchpoint (breakpoint.c): + if (!target_has_execution) { /* Without execution, memory can't change. No use to try and set watchpoint locations. The watchpoint will be reset when the target gains execution, through breakpoint_re_set. */ + if (!can_use_hw_watchpoints) + { + if (b->base.ops->works_in_software_mode (&b->base)) + b->base.type = bp_watchpoint; + else + error (_("Software read/access watchpoints not supported.")); + } The watchpoint must be downgraded to a software watchpoint if the target does not support hw watchpoints, even if can_use_hw_watchpoints is 1. The following patch fixes this and also adds an additional test to testsuite/watchpoints.exp to catch this problem. 2013-11-07 Jose E. Marchesi * breakpoint.c (update_watchpoint): Downgrade hw watchpoints to sw watchpoints in targets not supporting them, when the inferior is not running. 2013-11-07 Jose E. Marchesi * gdb.base/watchpoints.exp: Add a test to ensure that a watchpoint is not created as a hw watchpoint in targets not supporting them, even if can-use-hw-watchpoints is 1 when the inferior is not running. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index ffe73fd..597e6f9 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -1800,7 +1800,10 @@ update_watchpoint (struct watchpoint *b, int reparse) /* Without execution, memory can't change. No use to try and set watchpoint locations. The watchpoint will be reset when the target gains execution, through breakpoint_re_set. */ - if (!can_use_hw_watchpoints) + int i = hw_breakpoint_used_count (); + int target_supports_hw_watchpoints = + target_can_use_hardware_watchpoint (bp_hardware_watchpoint, i + 1, 0); + if (!target_supports_hw_watchpoints || !can_use_hw_watchpoints) { if (b->base.ops->works_in_software_mode (&b->base)) b->base.type = bp_watchpoint; --- a/gdb/testsuite/gdb.base/watchpoints.exp +++ b/gdb/testsuite/gdb.base/watchpoints.exp @@ -30,6 +30,15 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} { } with_test_prefix "before inferior start" { + if [target_info exists gdb,no_hardware_watchpoints] { + # Ensure that a watchpoint is not created as a hw watchpoint + # even if can-use-hw-watchpoints is 1 when the inferior is not + # running. + gdb_test_no_output "set can-use-hw-watchpoints 1" + gdb_test "watch ival1" "Watchpoint \[0-9\]+: ival1" \ + "create sw watchpoint" + } + # Ensure that if we turn off hardware watchpoints and set a watch point # before starting the inferior the watchpoint created will not be a # hardware watchpoint.