Jump to the RTOS hartid after halting

When I disappeared the polls everywhere I forgot to sanitize the hartid
after halting.  This is an invariant that GDB expects: when you return
from a halt whatever thread is marked as currently selected is the
thread that the next register accesses reference.
This commit is contained in:
Palmer Dabbelt 2017-06-12 17:46:31 -07:00
parent ee1c404ef4
commit 5747469eae
1 changed files with 7 additions and 0 deletions

View File

@ -736,6 +736,8 @@ int riscv_openocd_poll(struct target *target)
int riscv_openocd_halt(struct target *target) int riscv_openocd_halt(struct target *target)
{ {
RISCV_INFO(r);
LOG_DEBUG("halting all harts"); LOG_DEBUG("halting all harts");
int out = riscv_halt_all_harts(target); int out = riscv_halt_all_harts(target);
@ -745,6 +747,11 @@ int riscv_openocd_halt(struct target *target)
} }
register_cache_invalidate(target->reg_cache); register_cache_invalidate(target->reg_cache);
if (riscv_rtos_enabled(target)) {
target->rtos->current_threadid = r->rtos_hartid + 1;
target->rtos->current_thread = r->rtos_hartid + 1;
}
target->state = TARGET_HALTED; target->state = TARGET_HALTED;
target->debug_reason = DBG_REASON_DBGRQ; target->debug_reason = DBG_REASON_DBGRQ;
target_call_event_callbacks(target, TARGET_EVENT_HALTED); target_call_event_callbacks(target, TARGET_EVENT_HALTED);