diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 45d079685..2e6f85592 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -2386,21 +2386,17 @@ static int riscv013_get_register(struct target *target, riscv_set_current_hartid(target, hid); int result = ERROR_OK; - if (rid <= GDB_REGNO_XPR31) { - result = register_read_direct(target, value, rid); - } else if (rid == GDB_REGNO_PC) { + if (rid == GDB_REGNO_PC) { result = register_read_direct(target, value, GDB_REGNO_DPC); LOG_DEBUG("read PC from DPC: 0x%016" PRIx64, *value); } else if (rid == GDB_REGNO_PRIV) { uint64_t dcsr; result = register_read_direct(target, &dcsr, GDB_REGNO_DCSR); - buf_set_u64((unsigned char *)value, 0, 8, get_field(dcsr, CSR_DCSR_PRV)); + *value = get_field(dcsr, CSR_DCSR_PRV); } else { result = register_read_direct(target, value, rid); - if (result != ERROR_OK) { - LOG_ERROR("Unable to read %s", gdb_regno_name(rid)); + if (result != ERROR_OK) *value = -1; - } } return result;