From 535de48ca69ba34860067dfe5ea6f7fa6638f7f9 Mon Sep 17 00:00:00 2001 From: Erhan Kurubas Date: Tue, 18 Oct 2022 17:23:15 +0200 Subject: [PATCH] target/xtensa: remove redundant call for `TARGET_EVENT_HALTED` `xtensa_do_step` is invoked from `xtensa_prepare_resume` to silently step over BP/WP before resuming. For example; in the case of WPs (DEBUGCAUSE_DB), in the current implementation `xtensa_do_step` will generate one more `TARGET_EVENT_HALTED` after the original one caused by WP itself. This patch moves the halted event cb call after the step is done successfully. Signed-off-by: Erhan Kurubas Change-Id: I9048e14fb316dc124847a42cfaefb1f76b5ce53e Reviewed-on: https://review.openocd.org/c/openocd/+/7274 Tested-by: jenkins Reviewed-by: Ian Thompson Reviewed-by: Antonio Borneo --- src/target/xtensa/xtensa.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/target/xtensa/xtensa.c b/src/target/xtensa/xtensa.c index c1b5f43c8..c2c047edb 100644 --- a/src/target/xtensa/xtensa.c +++ b/src/target/xtensa/xtensa.c @@ -1630,7 +1630,6 @@ int xtensa_do_step(struct target *target, int current, target_addr_t address, in 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) { @@ -1658,7 +1657,12 @@ int xtensa_do_step(struct target *target, int current, target_addr_t address, in int xtensa_step(struct target *target, int current, target_addr_t address, int handle_breakpoints) { - return xtensa_do_step(target, current, address, handle_breakpoints); + int retval = xtensa_do_step(target, current, address, handle_breakpoints); + if (retval != ERROR_OK) + return retval; + target_call_event_callbacks(target, TARGET_EVENT_HALTED); + + return ERROR_OK; } /**