From patchwork Fri Dec 8 10:04:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 24813 Received: (qmail 25617 invoked by alias); 8 Dec 2017 10:04:43 -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 25510 invoked by uid 89); 8 Dec 2017 10:04:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=fired, H*r:sk:static., watch X-HELO: mail-wr0-f193.google.com Received: from mail-wr0-f193.google.com (HELO mail-wr0-f193.google.com) (209.85.128.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 08 Dec 2017 10:04:41 +0000 Received: by mail-wr0-f193.google.com with SMTP id l22so10269402wrc.11 for ; Fri, 08 Dec 2017 02:04:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=jkE+N3i6q9Qo0JDsq9Nv7macXzyBBN+avkbShvcmdnM=; b=OYXtHz8CPlZOT7BKC6MLtWNRvaz7cMCAQow18Qg/eO6vrr4kDaSoQ6Mhp8JctXR/8k 2heJC70VEKvRxE1/EHVag5617nI5VsxMFfv3cUxKtrUNVrotpvF9SZy5ewymCy1XPrNJ fCDeM1Yfcdb001QJNVkMHExUaM7OugPDLQ25gHAdPEuB6EaOsg3xJj8OcJx/STRQ1LeV HttHpmx6qAfBw245Mt1L9TdccpqXBv87oigNyDI2Sdl2oU+e08IIFHTLbkq6mPl7QUTw yMqw2ojIUyGD6YdZlVNH8DmIsyZae5RjGr08zqPGB+7ZVfc2dOondfuih3TJvcrRimZ3 y5WA== X-Gm-Message-State: AJaThX6ahvwmoon+9p6wH0Iy0jz5HhqPpBPjLtxtEy7CoMlApx7cgY1f TWVf/TB7Xhb1P+d07Lamcf6dOA== X-Google-Smtp-Source: AGs4zMZD3s2pXl7l6imqD35E/P/b9Tudh677EwNcxIb7pO3GH1otpHlhmksryjJEOg3+S95f1O9ZcQ== X-Received: by 10.223.156.146 with SMTP id d18mr26370388wre.161.1512727479044; Fri, 08 Dec 2017 02:04:39 -0800 (PST) Received: from E107787-LIN.cambridge.arm.com (static.42.136.251.148.clients.your-server.de. [148.251.136.42]) by smtp.gmail.com with ESMTPSA id a22sm1194394wme.46.2017.12.08.02.04.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Dec 2017 02:04:38 -0800 (PST) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 3/3] Clear non-significant bits of address in watchpoint Date: Fri, 8 Dec 2017 10:04:31 +0000 Message-Id: <1512727471-30745-4-git-send-email-yao.qi@linaro.org> In-Reply-To: <1512727471-30745-1-git-send-email-yao.qi@linaro.org> References: <1512727471-30745-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes Nowadays, GDB can't set watchpoint on tagged address on AArch64, (gdb) p p2 $1 = (int *) 0xf000fffffffff474 (gdb) watch *((int *) 0xf000fffffffff474) Hardware watchpoint 2: *((int *) 0xf000fffffffff474) (gdb) c Continuing. main () at binutils-gdb/gdb/testsuite/gdb.arch/aarch64-tagged-pointer.c:45 45 void (*func_ptr) (void) = foo; Unexpected error setting hardware debug registers This patch is about setting watchpoint on a tagged address. Unlike breakpoint, watchpoint record the expression rather than the address, and when a watchpoint is fired, GDB checks the expression value changed instead of matching address, so we can mask the watchpoint address by getting rid of non-significant bits of address. gdb: 2017-12-01 Yao Qi * breakpoint.c (update_watchpoint): Call significant_addr. gdb/testsuite: 2017-12-01 Yao Qi * gdb.arch/aarch64-tagged-pointer.c (main): Update. * gdb.arch/aarch64-tagged-pointer.exp: Add tests for watchpoint. --- gdb/breakpoint.c | 2 +- gdb/testsuite/gdb.arch/aarch64-tagged-pointer.c | 1 + gdb/testsuite/gdb.arch/aarch64-tagged-pointer.exp | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 22b3069..6570513 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -1867,7 +1867,7 @@ update_watchpoint (struct watchpoint *b, int reparse) loc->gdbarch = get_type_arch (value_type (v)); loc->pspace = frame_pspace; - loc->address = addr; + loc->address = address_significant (loc->gdbarch, addr); if (bitsize != 0) { diff --git a/gdb/testsuite/gdb.arch/aarch64-tagged-pointer.c b/gdb/testsuite/gdb.arch/aarch64-tagged-pointer.c index 9bfe41e..5754785 100644 --- a/gdb/testsuite/gdb.arch/aarch64-tagged-pointer.c +++ b/gdb/testsuite/gdb.arch/aarch64-tagged-pointer.c @@ -53,4 +53,5 @@ main (void) } sp1->i = 8765; + i = 1; } diff --git a/gdb/testsuite/gdb.arch/aarch64-tagged-pointer.exp b/gdb/testsuite/gdb.arch/aarch64-tagged-pointer.exp index fcab1b7..c08993e 100644 --- a/gdb/testsuite/gdb.arch/aarch64-tagged-pointer.exp +++ b/gdb/testsuite/gdb.arch/aarch64-tagged-pointer.exp @@ -89,3 +89,17 @@ foreach_with_prefix bptype {"hbreak" "break"} { gdb_test "up" "\\(\*func_ptr\\) \\(\\).*" "caller is *func_ptr" delete_breakpoints } + +gdb_test "down" +gdb_test "finish" +# Watch on tagged pointer. +gdb_test "watch *sp2" +gdb_test "continue" \ + "Continuing\\..*Hardware watchpoint \[0-9\]+.*" \ + "run until watchpoint on s1" +delete_breakpoints + +gdb_test "watch *p2" +gdb_test "continue" \ + "Continuing\\..*Hardware watchpoint \[0-9\]+.*" \ + "run until watchpoint on i"