Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Fix displaced stepping watchpoint check order
@ 2021-06-08 15:42 Luis Machado via Gdb-patches
  2021-06-15 14:09 ` [Ping][PATCH] " Luis Machado via Gdb-patches
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Luis Machado via Gdb-patches @ 2021-06-08 15:42 UTC (permalink / raw)
  To: gdb-patches

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 (),
-- 
2.25.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-08-19 18:49 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08 15:42 [PATCH] Fix displaced stepping watchpoint check order Luis Machado via Gdb-patches
2021-06-15 14:09 ` [Ping][PATCH] " Luis Machado via Gdb-patches
2021-06-22  1:56 ` [PING] [PATCH] " Luis Machado via Gdb-patches
2021-07-01 13:53 ` [PING][PATCH] " Luis Machado via Gdb-patches
2021-07-23 13:25 ` Luis Machado via Gdb-patches
2021-07-29 19:36 ` [PATCH] " Simon Marchi via Gdb-patches
2021-07-29 20:17   ` Luis Machado via Gdb-patches
2021-07-30  0:59     ` Simon Marchi via Gdb-patches
2021-07-30  1:32       ` Luis Machado via Gdb-patches
2021-08-19  1:31         ` Simon Marchi via Gdb-patches
2021-08-19 16:13           ` Luis Machado via Gdb-patches
2021-08-19 18:23             ` Simon Marchi via Gdb-patches
2021-08-19 18:48               ` Luis Machado via Gdb-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox