Added even more handling of unexamined harts

This commit is contained in:
cgsfv 2024-02-13 20:39:58 -08:00
parent ae53788985
commit c1c46fbcad
3 changed files with 17 additions and 2 deletions

View File

@ -2056,6 +2056,14 @@ static int examine(struct target *target)
enum riscv_hart_state state_at_examine_start;
if (riscv_get_hart_state(target, &state_at_examine_start) != ERROR_OK)
return ERROR_FAIL;
/* Skip full examination of hart if it is unavailable */
const bool hart_unavailable_at_examine_start = state_at_examine_start == RISCV_STATE_UNAVAILABLE;
if (hart_unavailable_at_examine_start) {
LOG_TARGET_INFO(target, "Did not fully examine hart %d as it was unavailable, deferring examine.", info->index);
target->defer_examine = true;
return ERROR_OK;
}
const bool hart_halted_at_examine_start = state_at_examine_start == RISCV_STATE_HALTED;
if (!hart_halted_at_examine_start) {
r->prepped = true;

View File

@ -3214,6 +3214,11 @@ int riscv_openocd_poll(struct target *target)
if (!target_was_examined(t))
continue;
if (target->defer_examine) {
target->examined = false;
continue;
}
enum riscv_next_action next_action;
if (riscv_poll_hart(t, &next_action) != ERROR_OK)
return ERROR_FAIL;

View File

@ -686,7 +686,8 @@ int target_examine_one(struct target *target)
}
LOG_USER("[%s] Target successfully examined.", target_name(target));
target_set_examined(target);
if (!target->defer_examine)
target_set_examined(target);
target_call_event_callbacks(target, TARGET_EVENT_EXAMINE_END);
LOG_TARGET_INFO(target, "Examination succeed");
@ -5267,7 +5268,8 @@ COMMAND_HANDLER(handle_target_examine)
return retval;
}
target_set_examined(target);
if (!target->defer_examine)
target_set_examined(target);
return ERROR_OK;
}