+2020-01-21 Luis Machado <luis.machado@linaro.org>
+
+ * aarch64-tdep.c (struct aarch64_displaced_step_closure )
+ <pc_adjust>: Adjust the documentation.
+ (aarch64_displaced_step_fixup): Check if PC really moved before
+ adjusting it.
+
2020-01-19 Tom Tromey <tom@tromey.com>
* disasm.c (~gdb_disassembler): New destructor.
is being displaced stepping. */
int cond = 0;
- /* PC adjustment offset after displaced stepping. */
+ /* PC adjustment offset after displaced stepping. If 0, then we don't
+ write the PC back, assuming the PC is already the right address. */
int32_t pc_adjust = 0;
};
{
aarch64_displaced_step_closure *dsc = (aarch64_displaced_step_closure *) dsc_;
+ ULONGEST pc;
+
+ regcache_cooked_read_unsigned (regs, AARCH64_PC_REGNUM, &pc);
+
if (dsc->cond)
{
- ULONGEST pc;
-
- regcache_cooked_read_unsigned (regs, AARCH64_PC_REGNUM, &pc);
if (pc - to == 8)
{
/* Condition is true. */
if (dsc->pc_adjust != 0)
{
+ /* Make sure the previous instruction was executed (that is, the PC
+ has changed). If the PC didn't change, then discard the adjustment
+ offset. Otherwise we may skip an instruction before its execution
+ took place. */
+ if ((pc - to) == 0)
+ dsc->pc_adjust = 0;
+
if (debug_displaced)
{
debug_printf ("displaced: fixup: set PC to %s:%d\n",