From f042dcb0a3a76bbe6030de53b873a79ba1506b41 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Mon, 12 Nov 2018 13:01:55 -0800 Subject: [PATCH] examine() should leave halted harts halted (#327) Previously all harts would be resumed at the end of examine(). Fixes #326. Change-Id: Id82b361e98f151911f8679538ee4b3c754efd6a5 --- src/target/riscv/riscv-013.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index ccb003287..00714aae7 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -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)