From patchwork Fri Apr 17 09:40:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 6278 Received: (qmail 90771 invoked by alias); 17 Apr 2015 09:40:14 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 90754 invoked by uid 89); 17 Apr 2015 09:40:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f181.google.com Received: from mail-pd0-f181.google.com (HELO mail-pd0-f181.google.com) (209.85.192.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 17 Apr 2015 09:40:12 +0000 Received: by pdbqa5 with SMTP id qa5so122835143pdb.1 for ; Fri, 17 Apr 2015 02:40:10 -0700 (PDT) X-Received: by 10.66.66.41 with SMTP id c9mr3891678pat.128.1429263610854; Fri, 17 Apr 2015 02:40:10 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by mx.google.com with ESMTPSA id t9sm9623041pas.3.2015.04.17.02.40.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Apr 2015 02:40:10 -0700 (PDT) From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH] return zero in arm_linux_can_use_hw_breakpoint if HW point isn't supported Date: Fri, 17 Apr 2015 10:40:00 +0100 Message-Id: <1429263600-4098-1-git-send-email-qiyaoltc@gmail.com> X-IsSubscribed: yes From: Yao Qi This patch is to cherry-pick part of Pedro's patch here https://sourceware.org/ml/gdb-patches/2015-04/msg00527.html in which zero is returned if the HW point isn't supported. In arm-linux native gdb testing on a board doesn't support HW breakpoint, without this patch, the output in gdb.base/breakpoint-in-ro-region.exp is like: (gdb) hbreak *0x83bc^M Hardware breakpoints used exceeds limit.^M (gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: probe hbreak support (support) with this patch, the output becomes: (gdb) hbreak *0x83bc^M No hardware breakpoint support in the target.^M (gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: probe hbreak support (no support) As a result, the following fails are fixed. -FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw on: step in ro region (cannot insert hw break) -FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw on: thread advanced -FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw on: step in ro region (cannot insert hw break) -FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw on: thread advanced gdb: 2015-04-17 Pedro Alves * arm-linux-nat.c (arm_linux_can_use_hw_breakpoint): Return zero if HW point of TYPE isn't supported. --- gdb/arm-linux-nat.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c index bb8358c..afc5817 100644 --- a/gdb/arm-linux-nat.c +++ b/gdb/arm-linux-nat.c @@ -771,12 +771,20 @@ arm_linux_can_use_hw_breakpoint (struct target_ops *self, if (type == bp_hardware_watchpoint || type == bp_read_watchpoint || type == bp_access_watchpoint || type == bp_watchpoint) { - if (cnt + ot > arm_linux_get_hw_watchpoint_count ()) + int count = arm_linux_get_hw_watchpoint_count (); + + if (count == 0) + return 0; + else if (cnt + ot > count) return -1; } else if (type == bp_hardware_breakpoint) { - if (cnt > arm_linux_get_hw_breakpoint_count ()) + int count = arm_linux_get_hw_breakpoint_count (); + + if (count == 0) + return 0; + else if (cnt > count) return -1; } else