target/riscv: set `state` and `debug_reason` in `riscv_halt_go_all_harts()`

If targets are in a halt group, and a target in the group reaches a
breakpoint, the target's state was able to remain `TARGET_RUNNING`.

Addresses issue #1010

Change-Id: I734bc6da71d289c4d05b417c8bf67a7d1a56574f
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
This commit is contained in:
Evgeniy Naydanov 2024-01-30 17:14:54 +03:00
parent 87331a82a2
commit 24d71d7a72
1 changed files with 6 additions and 0 deletions

View File

@ -1874,6 +1874,12 @@ static int riscv_halt_go_all_harts(struct target *target)
return ERROR_FAIL; return ERROR_FAIL;
if (state == RISCV_STATE_HALTED) { if (state == RISCV_STATE_HALTED) {
LOG_TARGET_DEBUG(target, "Hart is already halted."); LOG_TARGET_DEBUG(target, "Hart is already halted.");
if (target->state != TARGET_HALTED) {
target->state = TARGET_HALTED;
enum riscv_halt_reason halt_reason = riscv_halt_reason(target);
if (set_debug_reason(target, halt_reason) != ERROR_OK)
return ERROR_FAIL;
}
} else { } else {
if (r->halt_go(target) != ERROR_OK) if (r->halt_go(target) != ERROR_OK)
return ERROR_FAIL; return ERROR_FAIL;