public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Luis Machado <luis.machado@linaro.org>
To: gdb-patches@sourceware.org
Subject: [PING][PATCH] Fix displaced stepping watchpoint check order
Date: Thu, 1 Jul 2021 10:53:54 -0300	[thread overview]
Message-ID: <0805224e-dbb1-b5b4-f686-1efb85d135ed@linaro.org> (raw)
In-Reply-To: <20210608154230.354202-1-luis.machado@linaro.org>

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  <luis.machado@linaro.org>
> 
> 	* 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 (),
> 

  parent reply	other threads:[~2021-07-01 13:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-08 15:42 [PATCH] " Luis Machado
2021-06-15 14:09 ` [Ping][PATCH] " Luis Machado
2021-06-22  1:56 ` [PING] [PATCH] " Luis Machado
2021-07-01 13:53 ` Luis Machado [this message]
2021-07-23 13:25 ` [PING][PATCH] " Luis Machado
2021-07-29 19:36 ` [PATCH] " Simon Marchi
2021-07-29 20:17   ` Luis Machado
2021-07-30  0:59     ` Simon Marchi
2021-07-30  1:32       ` Luis Machado
2021-08-19  1:31         ` Simon Marchi
2021-08-19 16:13           ` Luis Machado
2021-08-19 18:23             ` Simon Marchi
2021-08-19 18:48               ` Luis Machado

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0805224e-dbb1-b5b4-f686-1efb85d135ed@linaro.org \
    --to=luis.machado@linaro.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).