diff options
author | Tim Newsome <tim@sifive.com> | 2022-11-28 08:49:07 -0800 |
---|---|---|
committer | Tim Newsome <tim@sifive.com> | 2022-11-29 09:24:24 -0800 |
commit | 86e84d3f6dce29246a1cd41b2aaaf3e02e2e7735 (patch) | |
tree | dc8e127d2075895e4eb592a349ac9800ecb58416 | |
parent | d6bf022560d54f83bb7d73d5b1b9ae78cb5eaf11 (diff) | |
download | riscv-openocd-86e84d3f6dce29246a1cd41b2aaaf3e02e2e7735.zip riscv-openocd-86e84d3f6dce29246a1cd41b2aaaf3e02e2e7735.tar.gz riscv-openocd-86e84d3f6dce29246a1cd41b2aaaf3e02e2e7735.tar.bz2 |
target/riscv: Set target->state in riscv013_halt_go()
Then also set it when we resume in examine(), which doesn't use the full
abstractions because not all required data structures are filled out
yet.
Hopefully fixes #749.
Change-Id: I0c6ab16da1f035ca2fbdb9f7be1462d44ddce3a0
Signed-off-by: Tim Newsome <tim@sifive.com>
-rw-r--r-- | src/target/riscv/riscv-013.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 4e9152c..013b633 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -1765,8 +1765,11 @@ static int examine(struct target *target) return ERROR_FAIL; } - if (!halted) + if (!halted) { riscv013_step_or_resume_current_hart(target, false); + target->state = TARGET_RUNNING; + target->debug_reason = DBG_REASON_NOTHALTED; + } if (target->smp) { bool haltgroup_supported; @@ -4331,8 +4334,17 @@ static int riscv013_halt_go(struct target *target) t->state = TARGET_UNAVAILABLE; } } + + } else { + /* Set state for the current target based on its dmstatus. */ + if (get_field(dmstatus, DM_DMSTATUS_ALLHALTED)) { + target->state = TARGET_HALTED; + if (target->debug_reason == DBG_REASON_NOTHALTED) + target->debug_reason = DBG_REASON_DBGRQ; + } else if (get_field(dmstatus, DM_DMSTATUS_ALLUNAVAIL)) { + target->state = TARGET_UNAVAILABLE; + } } - /* The "else" case is handled in halt_go(). */ return ERROR_OK; } |