From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ONvAF2HD+mDWbgAAWB0awg (envelope-from ) for ; Fri, 23 Jul 2021 09:25:53 -0400 Received: by simark.ca (Postfix, from userid 112) id 5ECED1EDFB; Fri, 23 Jul 2021 09:25:53 -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,RCVD_IN_MSPIKE_H2,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 9B3AB1E813 for ; Fri, 23 Jul 2021 09:25:52 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 34D69388C00F for ; Fri, 23 Jul 2021 13:25:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 34D69388C00F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1627046752; 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=Ze92tzZ3sruAtMcpX/vQl/dZhJfSLUAwEGIB53ylZt1xWl9mE8hdlNyiEE16MGlGz I+1ZYogd79DgZzDQK8d9jio0wGf4tuL668gSjiQiVZs21v1W1Ze9SMC5AZ6icy56SR iBpMK5Kl/+3x6TNz7YGBJ+cBpWyjWbSNxIdjNdwE= Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by sourceware.org (Postfix) with ESMTPS id B89A0388A428 for ; Fri, 23 Jul 2021 13:25:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B89A0388A428 Received: by mail-pj1-x102e.google.com with SMTP id g23-20020a17090a5797b02901765d605e14so3654574pji.5 for ; Fri, 23 Jul 2021 06:25:32 -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=E/WoaMUgU0Zk5FZpS+gxWsJC6hGaWRbxinj67b/E+DFmEX0EGNp3JU2gOKv+Cqpon8 N3h/8L00gHbmnCLbgfQrEeGTcTXxU8L2uP3PcENnnHXSVuxKUS4XLEY1lJRfX5FE5BBU AyYEeSNIMcn9VmnG16JK4pVuuLHM2WvCGDaXJK4i/39QHiNv619+kq7AwauM/knJDtK5 QEMz3lIbvEePvt/tGaDdPRkhw9DQgp4sKbN/nIxdBMghratSKgSXDdGdCo4lFqxWJba1 nMBytgKAXX536U/1wJOX4uSM4jtttv95a/DmDWq41ZDEkzDh++NttAcbtphU8V44OwtE f3nw== X-Gm-Message-State: AOAM530mn+B/hplOyL/xl19xsMWuIhJtcsdN/cIntJiPuvTI3gAxyd/Q n3vqnl3ChEDGGRdB9hUA0IauyQL+1fwQXg== X-Google-Smtp-Source: ABdhPJzmnOwxQaijCZK8SRUSgy1vSpHWHAuZkvtEVDUtTSb3Ri0rne5Zca/E22m7y6/hN7e54y8w1A== X-Received: by 2002:a17:90b:945:: with SMTP id dw5mr4607667pjb.3.1627046731919; Fri, 23 Jul 2021 06:25:31 -0700 (PDT) Received: from ?IPv6:2804:7f0:4841:2b39:1cb3:6a58:a529:5f6e? ([2804:7f0:4841:2b39:1cb3:6a58:a529:5f6e]) by smtp.gmail.com with ESMTPSA id x40sm34765727pfu.176.2021.07.23.06.25.30 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 23 Jul 2021 06:25:31 -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: Date: Fri, 23 Jul 2021 10:25:29 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 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 (), >