From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id o2fWKAvJ3WDnaQAAWB0awg (envelope-from ) for ; Thu, 01 Jul 2021 09:54:19 -0400 Received: by simark.ca (Postfix, from userid 112) id 999C41F1F2; Thu, 1 Jul 2021 09:54:19 -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 D46D61EE14 for ; Thu, 1 Jul 2021 09:54:18 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 444363885C3D for ; Thu, 1 Jul 2021 13:54:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 444363885C3D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1625147658; bh=RPJ9Qn+a447BjvOPrmFLzpvYv4g0LZZth9l4Wz/caZ0=; 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=fgjHIlMQoHeBXNaxTL/bWNb7hwYptR0F3+utJcjVm9W4Solj/Seyr8zZhHv2zaQVP mW8ijbWPyB/J2/zBFeSTk+oHPYeerQRO5sp+vjD1WmVNea5najHOyW7FqTf9qvDD52 ITlTfXljU2kCUTx5CBaJov0/YRXJ+ukkuZNgGoxc= Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by sourceware.org (Postfix) with ESMTPS id 270943855028 for ; Thu, 1 Jul 2021 13:53:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 270943855028 Received: by mail-pj1-x102d.google.com with SMTP id mn20-20020a17090b1894b02901707fc074e8so5926996pjb.0 for ; Thu, 01 Jul 2021 06:53:58 -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=RPJ9Qn+a447BjvOPrmFLzpvYv4g0LZZth9l4Wz/caZ0=; b=eo+Ziyi/Ph2WdEf2Xxpq6Qau1ueJ765x2J541jhsI4I0x3J+CQQF8bvPlCbipsZyqI 5HUAaj8AR5Di31Xu0u/gLUSVpkpKypVN91lh9cbezuitrHAb71FdDB1uZ+MZo/8C4Uej yisrmOiUvfRhL4fYl63ziMFyS6LRkA0903tgDuI+M+qMCtyQJx6iO6JWIQqJ0Q+QN0VU ZHkupJKKgItLOKETg0rWemBCjieN1XWtJV55nxyJKsl9hSSCbXSgYJzNYdhOVRN7n8N/ A0QXNfeKy9w5pxNKL3fjB3X+O4QGvMvp/f1fneCRzZZybKN8TaZcsIzhyqQeIAHT3Bpb cXyw== X-Gm-Message-State: AOAM530KQHiJvi0Fo7DcuRoWVC+EpN1rXK1SlTgqlyJlPkKO96kmwqzp yt33PJT6lqzFsDNYqGCOjfkD2ujRQy94aQ== X-Google-Smtp-Source: ABdhPJzqOs0RPFV8MXXT449QceDVWapjuAxEzNptCYslDQP/YqsYNpYrlJJw13ZwfdaVgs7Mb8K9kA== X-Received: by 2002:a17:90b:1b46:: with SMTP id nv6mr43775364pjb.46.1625147637258; Thu, 01 Jul 2021 06:53:57 -0700 (PDT) Received: from ?IPv6:2804:7f0:4841:1e6a:d86b:249c:eb1d:ab69? ([2804:7f0:4841:1e6a:d86b:249c:eb1d:ab69]) by smtp.gmail.com with ESMTPSA id f17sm96536pfe.181.2021.07.01.06.53.55 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Jul 2021 06:53:56 -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: <0805224e-dbb1-b5b4-f686-1efb85d135ed@linaro.org> Date: Thu, 1 Jul 2021 10:53:54 -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 (), >