From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13975 invoked by alias); 7 Jul 2015 16:30:26 -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 13937 invoked by uid 89); 7 Jul 2015 16:30:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f50.google.com Received: from mail-pa0-f50.google.com (HELO mail-pa0-f50.google.com) (209.85.220.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 07 Jul 2015 16:30:24 +0000 Received: by pactm7 with SMTP id tm7so115745263pac.2 for ; Tue, 07 Jul 2015 09:30:22 -0700 (PDT) X-Received: by 10.69.19.161 with SMTP id gv1mr10456585pbd.21.1436286622798; Tue, 07 Jul 2015 09:30:22 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by mx.google.com with ESMTPSA id nw8sm22460951pdb.30.2015.07.07.09.30.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Jul 2015 09:30:22 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH] Return zero in aarch64_linux_can_use_hw_breakpoint if target doesn't support HW watchpoint/breakpoint Date: Tue, 07 Jul 2015 16:30:00 -0000 Message-Id: <1436286618-23963-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg00182.txt.bz2 Nowadays aarch64_linux_can_use_hw_breakpoint always return one, but it can be smarter, say, if GDB knows target doesn't support HW watchpoint or breakpoint because HW watchpoint/breakpoint is disabled in linux kernel, for example, it can safely return zero. gdb: 2015-07-07 Yao Qi * aarch64-linux-nat.c (aarch64_linux_can_use_hw_breakpoint): If TYPE is watchpoint, return zero if aarch64_num_wp_regs is zero. If TYPE is breakpoint, return zero if arch64_num_bp_regs is zero. --- gdb/aarch64-linux-nat.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index cafd824..2cd20d1 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -1051,19 +1051,32 @@ aarch64_align_watchpoint (CORE_ADDR addr, int len, CORE_ADDR *aligned_addr_p, bp_read_watchpoint, bp_write_watchpoint, or bp_hardware_breakpoint. CNT is the number of such watchpoints used so far (including this one). OTHERTYPE is non-zero if other types of watchpoints are - currently enabled. - - We always return 1 here because we don't have enough information - about possible overlap of addresses that they want to watch. As an - extreme example, consider the case where all the watchpoints watch - the same address and the same region length: then we can handle a - virtually unlimited number of watchpoints, due to debug register - sharing implemented via reference counts. */ + currently enabled. */ static int aarch64_linux_can_use_hw_breakpoint (struct target_ops *self, int type, int cnt, int othertype) { + if (type == bp_hardware_watchpoint || type == bp_read_watchpoint + || type == bp_access_watchpoint || type == bp_watchpoint) + { + if (aarch64_num_wp_regs == 0) + return 0; + } + else if (type == bp_hardware_breakpoint) + { + if (aarch64_num_bp_regs == 0) + return 0; + } + else + gdb_assert (FALSE); + + /* We always return 1 here because we don't have enough information + about possible overlap of addresses that they want to watch. As an + extreme example, consider the case where all the watchpoints watch + the same address and the same region length: then we can handle a + virtually unlimited number of watchpoints, due to debug register + sharing implemented via reference counts. */ return 1; } -- 1.9.1