target/xtensa: fix step state transition
authorIan Thompson <ianst@cadence.com>
Mon, 29 Aug 2022 14:34:18 +0000 (07:34 -0700)
committerAntonio Borneo <borneo.antonio@gmail.com>
Tue, 13 Sep 2022 22:09:02 +0000 (22:09 +0000)
For some configurations, notably on DAP systems, resolve issue where single-stepping does not always transition into the HALTED state.

Signed-off-by: Ian Thompson <ianst@cadence.com>
Change-Id: I053f4eaffad8c3228878ba87580ada640e4bd2fe
Reviewed-on: https://review.openocd.org/c/openocd/+/7150
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
src/target/xtensa/xtensa.c

index 0c975a4ea6e043e729f53d6725878d0b968e0f05..2e978b387fbed5e8ccfabe056ec49e4d42e79625 100644 (file)
@@ -1586,11 +1586,8 @@ int xtensa_do_step(struct target *target, int current, target_addr_t address, in
                        target->state = TARGET_RUNNING;
                        return ERROR_FAIL;
                }
-               target->debug_reason = DBG_REASON_SINGLESTEP;
-               target->state = TARGET_HALTED;
 
                xtensa_fetch_all_regs(target);
-
                cur_pc = xtensa_reg_get(target, XT_REG_IDX_PC);
 
                LOG_TARGET_DEBUG(target,
@@ -1620,6 +1617,10 @@ int xtensa_do_step(struct target *target, int current, target_addr_t address, in
                        LOG_DEBUG("Stepped from %" PRIX32 " to %" PRIX32, oldpc, cur_pc);
                break;
        } while (true);
+
+       target->debug_reason = DBG_REASON_SINGLESTEP;
+       target->state = TARGET_HALTED;
+       target_call_event_callbacks(target, TARGET_EVENT_HALTED);
        LOG_DEBUG("Done stepping, PC=%" PRIX32, cur_pc);
 
        if (cause & DEBUGCAUSE_DB) {