From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 9UlNNoND0WCJTAAAWB0awg (envelope-from ) for ; Mon, 21 Jun 2021 21:57:23 -0400 Received: by simark.ca (Postfix, from userid 112) id CD5B81F1F2; Mon, 21 Jun 2021 21:57:23 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 14C931EE14 for ; Mon, 21 Jun 2021 21:57:23 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 84A293848417 for ; Tue, 22 Jun 2021 01:57:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 84A293848417 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1624327042; bh=FjD6sci2yeME5NKIZFYostxzAIDrBAX9xG/EgXFOe7w=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=bFwgtv3WBQt7Krt9EmAvnWrd6wcnMj7/7A8KG8PNVavFeNngV1CZi7QR/2tzp+ylY jJJo1LYFy+qLS8gBRPtQtIrbl19LaiVW0pq2MFvbUVVQo9UECremEqmLe/Lc/VyVPQ VeibFoOd9TdT5eLOfoE316/A1v4KReXiRn5yQu3E= Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by sourceware.org (Postfix) with ESMTPS id 0B5B53854815 for ; Tue, 22 Jun 2021 01:57:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0B5B53854815 Received: by mail-qt1-x82f.google.com with SMTP id z4so14999930qts.4 for ; Mon, 21 Jun 2021 18:57:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=FjD6sci2yeME5NKIZFYostxzAIDrBAX9xG/EgXFOe7w=; b=Bg1oa0OVNnLkC/dbWWOVo8DVkGBNvoY2SE6DQWHbnmmTV9ZrpmEWtfLd5PnD5gna6l otiGtJ6/WowJ28BDcyqSjic6zkCfAuUpEqXkqLfiz0OZWyT22xUGKHFJCqTwfUOVMGsc TqNNVRdw7Bz0Z9V2pFP6i3KgWhVRLflf/xmWJhL0GeYg5gwIIuYPCzstVzZjbkM5yquf ba2ct5AxgcdxJ6SkkmWrSbZUZbZxJfcreHnjSSzejYTV5mmoX1VyBdQnL0HCiiv943U7 oGixtq3cwDRtiAojetTEuYZNIHNx9pXi395gKHDw/Vlhqya/sx3R7Me5HGCArMMuO0Rq 5Q3A== X-Gm-Message-State: AOAM530k5QamIa6I60IYV27N21aPaj5X4vsB3FKxeJoiHAAxGAARUn6S QHro9AwO9uVTLHVggqn37leyyksdIwne3A== X-Google-Smtp-Source: ABdhPJxql2iCFgVV7OJ1HFBVTIPQjDqMxI0IIctQ7ydna2oaq8PvvY5vqDAuRmLprq7/8VpJHUvLOg== X-Received: by 2002:ac8:488e:: with SMTP id i14mr1467505qtq.102.1624327021663; Mon, 21 Jun 2021 18:57:01 -0700 (PDT) Received: from ?IPv6:2804:7f0:4841:a0:6572:2efe:ea53:14e9? ([2804:7f0:4841:a0:6572:2efe:ea53:14e9]) by smtp.gmail.com with ESMTPSA id bj39sm11133835qkb.78.2021.06.21.18.57.00 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 21 Jun 2021 18:57:01 -0700 (PDT) Subject: [PING] [PATCH] Fix displaced stepping watchpoint check order To: gdb-patches@sourceware.org References: <20210608154230.354202-1-luis.machado@linaro.org> Message-ID: <24a03051-6f2b-60de-19cd-e86aaba8a309@linaro.org> Date: Mon, 21 Jun 2021 22:56:57 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210608154230.354202-1-luis.machado@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Luis Machado via Gdb-patches Reply-To: Luis Machado Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 6/8/21 12:42 PM, Luis Machado wrote: > When checking the stopped data address, I noticed, under some circumstances, > that the instruction at PC wasn't the expected one. This happens because the > displaced stepping machinery restores the buffer before checking if the > instruction executed successfully, which in turn calls the watchpoint check. > > I guess this was never noticed because stopped data address checks usually > don't need to fetch the instruction at PC, but AArch64 needs to do it from > now on. > > We should check if the instruction executed successfully before we restore the > scratchpad contents. > > Regression tested on aarch64-linux/Ubuntu 20.04. > > gdb/ChangeLog: > > YYYY-MM-DD Luis Machado > > * displaced-stepping.c (displaced_step_buffers::finish): Move check > upwards. > --- > gdb/displaced-stepping.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/gdb/displaced-stepping.c b/gdb/displaced-stepping.c > index 59b78c22f6a..06324d523d8 100644 > --- a/gdb/displaced-stepping.c > +++ b/gdb/displaced-stepping.c > @@ -227,6 +227,11 @@ displaced_step_buffers::finish (gdbarch *arch, thread_info *thread, > > ULONGEST len = gdbarch_max_insn_length (arch); > > + /* Check if the execution was successful before restoring the buffer > + contents. */ > + bool instruction_executed_successfully > + = displaced_step_instruction_executed_successfully (arch, sig); > + > /* Restore memory of the buffer. */ > write_memory_ptid (thread->ptid, buffer->addr, > buffer->saved_copy.data (), len); > @@ -237,9 +242,6 @@ displaced_step_buffers::finish (gdbarch *arch, thread_info *thread, > > regcache *rc = get_thread_regcache (thread); > > - bool instruction_executed_successfully > - = displaced_step_instruction_executed_successfully (arch, sig); > - > if (instruction_executed_successfully) > { > gdbarch_displaced_step_fixup (arch, copy_insn_closure.get (), >