aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErhan Kurubas <43336369+erhankur@users.noreply.github.com>2022-02-21 18:02:07 +0100
committerGitHub <noreply@github.com>2022-02-21 09:02:07 -0800
commit64f3f8877e9dbedf7b80ea3d544e5a6a5b17ed61 (patch)
treec31964d531e9958918659b9d6a71934ef7f4388b
parent435a6522366ba9ebc8104c190045483918b27ff8 (diff)
downloadriscv-openocd-64f3f8877e9dbedf7b80ea3d544e5a6a5b17ed61.zip
riscv-openocd-64f3f8877e9dbedf7b80ea3d544e5a6a5b17ed61.tar.gz
riscv-openocd-64f3f8877e9dbedf7b80ea3d544e5a6a5b17ed61.tar.bz2
riscv: call debug_execution related events (#679)
Change-Id: Ice7cdc816f3e568a6ba2db8f9101903b8f7a08ce Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com>
-rw-r--r--src/target/riscv/riscv.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c
index 8828694..91d1020 100644
--- a/src/target/riscv/riscv.c
+++ b/src/target/riscv/riscv.c
@@ -1490,13 +1490,14 @@ static int resume_go(struct target *target, int current,
return result;
}
-static int resume_finish(struct target *target)
+static int resume_finish(struct target *target, int debug_execution)
{
register_cache_invalidate(target->reg_cache);
- target->state = TARGET_RUNNING;
+ target->state = debug_execution ? TARGET_DEBUG_RUNNING : TARGET_RUNNING;
target->debug_reason = DBG_REASON_NOTHALTED;
- return target_call_event_callbacks(target, TARGET_EVENT_RESUMED);
+ return target_call_event_callbacks(target,
+ debug_execution ? TARGET_EVENT_DEBUG_RESUMED : TARGET_EVENT_RESUMED);
}
/* Return a newly allocated target list, that contains the same targets as in
@@ -1566,7 +1567,7 @@ int riscv_resume(
for (struct target_list *tlist = ordered_tlist; tlist; tlist = tlist->next) {
struct target *t = tlist->target;
- if (resume_finish(t) != ERROR_OK)
+ if (resume_finish(t, debug_execution) != ERROR_OK)
result = ERROR_FAIL;
}
@@ -1580,7 +1581,7 @@ int riscv_resume(
if (resume_go(target, current, address, handle_breakpoints,
debug_execution) != ERROR_OK)
result = ERROR_FAIL;
- if (resume_finish(target) != ERROR_OK)
+ if (resume_finish(target, debug_execution) != ERROR_OK)
return ERROR_FAIL;
}
@@ -1975,7 +1976,7 @@ static int riscv_run_algorithm(struct target *target, int num_mem_params,
/* Run algorithm */
LOG_DEBUG("resume at 0x%" TARGET_PRIxADDR, entry_point);
- if (riscv_resume(target, 0, entry_point, 0, 0, true) != ERROR_OK)
+ if (riscv_resume(target, 0, entry_point, 0, 1, true) != ERROR_OK)
return ERROR_FAIL;
int64_t start = timeval_ms();
@@ -2177,7 +2178,7 @@ static enum riscv_poll_hart riscv_poll_hart(struct target *target, int hartid)
LOG_DEBUG(" triggered a halt");
r->on_halt(target);
return RPH_DISCOVERED_HALTED;
- } else if (target->state != TARGET_RUNNING && !halted) {
+ } else if (target->state != TARGET_RUNNING && target->state != TARGET_DEBUG_RUNNING && !halted) {
LOG_DEBUG(" triggered running");
target->state = TARGET_RUNNING;
target->debug_reason = DBG_REASON_NOTHALTED;
@@ -2239,6 +2240,7 @@ int riscv_openocd_poll(struct target *target)
{
LOG_DEBUG("polling all harts");
int halted_hart = -1;
+ enum target_state old_state = target->state;
if (target->smp) {
unsigned halts_discovered = 0;
@@ -2354,7 +2356,10 @@ int riscv_openocd_poll(struct target *target)
return retval;
}
} else {
- target_call_event_callbacks(target, TARGET_EVENT_HALTED);
+ if (old_state == TARGET_DEBUG_RUNNING)
+ target_call_event_callbacks(target, TARGET_EVENT_DEBUG_HALTED);
+ else
+ target_call_event_callbacks(target, TARGET_EVENT_HALTED);
}
return ERROR_OK;