From patchwork Wed Jul 8 08:09:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 7578 Received: (qmail 43266 invoked by alias); 8 Jul 2015 08:10:01 -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 43249 invoked by uid 89); 8 Jul 2015 08:10:00 -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-f45.google.com Received: from mail-pa0-f45.google.com (HELO mail-pa0-f45.google.com) (209.85.220.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 08 Jul 2015 08:09:59 +0000 Received: by pacws9 with SMTP id ws9so129103717pac.0 for ; Wed, 08 Jul 2015 01:09:57 -0700 (PDT) X-Received: by 10.68.186.35 with SMTP id fh3mr18034451pbc.62.1436342997317; Wed, 08 Jul 2015 01:09:57 -0700 (PDT) Received: from E107787-LIN (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id kk6sm1515944pdb.94.2015.07.08.01.09.54 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 08 Jul 2015 01:09:56 -0700 (PDT) From: Yao Qi To: Joel Brobecker Cc: Yao Qi , gdb-patches@sourceware.org Subject: Re: [PATCH] Return zero in aarch64_linux_can_use_hw_breakpoint if target doesn't support HW watchpoint/breakpoint References: <1436286618-23963-1-git-send-email-yao.qi@linaro.org> <20150707163636.GA4802@adacore.com> Date: Wed, 08 Jul 2015 09:09:52 +0100 In-Reply-To: <20150707163636.GA4802@adacore.com> (Joel Brobecker's message of "Tue, 7 Jul 2015 09:36:36 -0700") Message-ID: <867fqbnk8f.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes Joel Brobecker writes: >> + else >> + gdb_assert (FALSE); > > Use gdb_assert_not_reached instead? Good point. Patch is updated to fix this. diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index cafd824..d5d0038 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_not_reached ("unexpected breakpoint type"); + + /* 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; }