diff options
author | Jan Matyas <matyas@codasip.com> | 2021-06-04 12:27:45 +0200 |
---|---|---|
committer | Jan Matyas <matyas@codasip.com> | 2021-06-04 12:27:45 +0200 |
commit | c2cd33d7cbac8105e50995c8260accb588e585dc (patch) | |
tree | 06cf32bb5dff1e56fdb1ced2c4a29c9d6570221b | |
parent | 3249d415595ee430164aa0429bcc7452c0f251fa (diff) | |
download | riscv-openocd-fix-halt-reason-after-singlestep.zip riscv-openocd-fix-halt-reason-after-singlestep.tar.gz riscv-openocd-fix-halt-reason-after-singlestep.tar.bz2 |
Fixed halt reason after single-stepfix-halt-reason-after-singlestep
After single step operation, we should not assume that the halt
reason is single-step. There can be a higher-priority halt cause,
e.g. a breakpoint.
The real halt reason should be obtained from the target (dcsr.cause).
-rw-r--r-- | src/target/riscv/riscv.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c index 8cfb227..42b0483 100644 --- a/src/target/riscv/riscv.c +++ b/src/target/riscv/riscv.c @@ -2227,6 +2227,8 @@ int riscv_openocd_poll(struct target *target) int riscv_openocd_step(struct target *target, int current, target_addr_t address, int handle_breakpoints) { + RISCV_INFO(r); + LOG_DEBUG("stepping rtos hart"); if (!current) @@ -2249,8 +2251,11 @@ int riscv_openocd_step(struct target *target, int current, target->state = TARGET_RUNNING; target_call_event_callbacks(target, TARGET_EVENT_RESUMED); + target->state = TARGET_HALTED; - target->debug_reason = DBG_REASON_SINGLESTEP; + /* Read real debug reason from the target. Do not presume the target halted due + * to the single-step. There may be a higher-priority halt cause, e.g. a breakpoint. */ + set_debug_reason(target, r->current_hartid); target_call_event_callbacks(target, TARGET_EVENT_HALTED); return out; } |