Fixed halt reason after single-step

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).
This commit is contained in:
Jan Matyas 2021-06-04 12:27:45 +02:00
parent 3249d41559
commit c2cd33d7cb
1 changed files with 6 additions and 1 deletions

View File

@ -2227,6 +2227,8 @@ int riscv_openocd_poll(struct target *target)
int riscv_openocd_step(struct target *target, int current, int riscv_openocd_step(struct target *target, int current,
target_addr_t address, int handle_breakpoints) target_addr_t address, int handle_breakpoints)
{ {
RISCV_INFO(r);
LOG_DEBUG("stepping rtos hart"); LOG_DEBUG("stepping rtos hart");
if (!current) if (!current)
@ -2249,8 +2251,11 @@ int riscv_openocd_step(struct target *target, int current,
target->state = TARGET_RUNNING; target->state = TARGET_RUNNING;
target_call_event_callbacks(target, TARGET_EVENT_RESUMED); target_call_event_callbacks(target, TARGET_EVENT_RESUMED);
target->state = TARGET_HALTED; 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); target_call_event_callbacks(target, TARGET_EVENT_HALTED);
return out; return out;
} }