examine() should leave halted harts halted (#327)

Previously all harts would be resumed at the end of examine().
Fixes #326.

Change-Id: Id82b361e98f151911f8679538ee4b3c754efd6a5
This commit is contained in:
Tim Newsome 2018-11-12 13:01:55 -08:00 committed by GitHub
parent 498faf93e1
commit f042dcb0a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 6 deletions

View File

@ -1470,7 +1470,8 @@ static int examine(struct target *target)
dmi_write(target, DMI_DMCONTROL,
set_hartsel(DMI_DMCONTROL_DMACTIVE | DMI_DMCONTROL_ACKHAVERESET, i));
if (!riscv_is_halted(target)) {
bool halted = riscv_is_halted(target);
if (!halted) {
if (riscv013_halt_current_hart(target) != ERROR_OK) {
LOG_ERROR("Fatal: Hart %d failed to halt during examine()", i);
return ERROR_FAIL;
@ -1500,6 +1501,9 @@ static int examine(struct target *target)
* really slow simulators. */
LOG_DEBUG(" hart %d: XLEN=%d, misa=0x%" PRIx64, i, r->xlen[i],
r->misa[i]);
if (!halted)
riscv013_resume_current_hart(target);
}
LOG_DEBUG("Enumerated %d harts", r->hart_count);
@ -1509,11 +1513,6 @@ static int examine(struct target *target)
return ERROR_FAIL;
}
/* Resumes all the harts, so the debugger can later pause them. */
/* TODO: Only do this if the harts were halted to start with. */
riscv_resume_all_harts(target);
target->state = TARGET_RUNNING;
target_set_examined(target);
if (target->rtos)