[PATCH] Fix displaced stepping watchpoint check order

Simon Marchi simon.marchi@polymtl.ca
Thu Jul 29 19:36:12 GMT 2021


I think this is ok, but in all honestly I don't completely understand
how the interaction between watchpoints and displaced stepping is
expected to work.

Just some nits:

On 2021-06-08 11:42 a.m., Luis Machado via Gdb-patches 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.

Can you clarify what you mean by "from now on"?  Can you indicate what
change you are referring to?

> 
> 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);

Maybe extend the comment to say "why".  Right now I think it just states
what is in plain sight when looking at the code, I think it would be
more useful if it said why it's important to do that.

Simon


More information about the Gdb-patches mailing list