Skip to content

Commit f042dcb

Browse files
authored
examine() should leave halted harts halted (#327)
Previously all harts would be resumed at the end of examine(). Fixes #326. Change-Id: Id82b361e98f151911f8679538ee4b3c754efd6a5
1 parent 498faf9 commit f042dcb

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/target/riscv/riscv-013.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,8 @@ static int examine(struct target *target)
14701470
dmi_write(target, DMI_DMCONTROL,
14711471
set_hartsel(DMI_DMCONTROL_DMACTIVE | DMI_DMCONTROL_ACKHAVERESET, i));
14721472

1473-
if (!riscv_is_halted(target)) {
1473+
bool halted = riscv_is_halted(target);
1474+
if (!halted) {
14741475
if (riscv013_halt_current_hart(target) != ERROR_OK) {
14751476
LOG_ERROR("Fatal: Hart %d failed to halt during examine()", i);
14761477
return ERROR_FAIL;
@@ -1500,6 +1501,9 @@ static int examine(struct target *target)
15001501
* really slow simulators. */
15011502
LOG_DEBUG(" hart %d: XLEN=%d, misa=0x%" PRIx64, i, r->xlen[i],
15021503
r->misa[i]);
1504+
1505+
if (!halted)
1506+
riscv013_resume_current_hart(target);
15031507
}
15041508

15051509
LOG_DEBUG("Enumerated %d harts", r->hart_count);
@@ -1509,11 +1513,6 @@ static int examine(struct target *target)
15091513
return ERROR_FAIL;
15101514
}
15111515

1512-
/* Resumes all the harts, so the debugger can later pause them. */
1513-
/* TODO: Only do this if the harts were halted to start with. */
1514-
riscv_resume_all_harts(target);
1515-
target->state = TARGET_RUNNING;
1516-
15171516
target_set_examined(target);
15181517

15191518
if (target->rtos)

0 commit comments

Comments
 (0)