Skip to content

Commit

Permalink
Merge pull request riscv-collab#916 from riscv/getreg_assert
Browse files Browse the repository at this point in the history
target/riscv: Don't assert in riscv013_get_register()
  • Loading branch information
timsifive authored Sep 14, 2023
2 parents 67c2835 + 2c2135a commit 2427f58
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/target/riscv/riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -4945,8 +4945,11 @@ int riscv_get_register(struct target *target, riscv_reg_t *value,
*/
int riscv_save_register(struct target *target, enum gdb_regno regid)
{
assert(target->state == TARGET_HALTED &&
"Doesn't make sense to populate register cache on non-halted targets.");
if (target->state != TARGET_HALTED) {
LOG_TARGET_ERROR(target, "Can't save register %s on a hart that is not halted.",
gdb_regno_name(regid));
return ERROR_FAIL;
}
assert(gdb_regno_cacheable(regid, /* is write? */ false) &&
"Only cacheable registers can be saved.");

Expand Down

0 comments on commit 2427f58

Please sign in to comment.