Skip to content

Commit afc9eb6

Browse files
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.
1 parent 099a302 commit afc9eb6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/target/riscv/riscv.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,8 @@ int riscv_openocd_poll(struct target *target)
737737

738738
int riscv_openocd_halt(struct target *target)
739739
{
740+
RISCV_INFO(r);
741+
740742
LOG_DEBUG("halting all harts");
741743

742744
int out = riscv_halt_all_harts(target);
@@ -746,6 +748,11 @@ int riscv_openocd_halt(struct target *target)
746748
}
747749

748750
register_cache_invalidate(target->reg_cache);
751+
if (riscv_rtos_enabled(target)) {
752+
target->rtos->current_threadid = r->rtos_hartid + 1;
753+
target->rtos->current_thread = r->rtos_hartid + 1;
754+
}
755+
749756
target->state = TARGET_HALTED;
750757
target->debug_reason = DBG_REASON_DBGRQ;
751758
target_call_event_callbacks(target, TARGET_EVENT_HALTED);

0 commit comments

Comments
 (0)