Still restore registers if an access failed.
Change-Id: I11571f0926f69a34f95b4929f633fdecd3a4e810
This commit is contained in:
parent
7edd9b1786
commit
5d3f5c35d2
|
@ -781,14 +781,13 @@ static int register_write_direct(struct target *target, unsigned number,
|
||||||
int exec_out = riscv_program_exec(&program, target);
|
int exec_out = riscv_program_exec(&program, target);
|
||||||
if (exec_out != ERROR_OK) {
|
if (exec_out != ERROR_OK) {
|
||||||
riscv013_clear_abstract_error(target);
|
riscv013_clear_abstract_error(target);
|
||||||
return ERROR_FAIL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore S0.
|
// Restore S0.
|
||||||
if (register_write_direct(target, GDB_REGNO_S0, s0) != ERROR_OK)
|
if (register_write_direct(target, GDB_REGNO_S0, s0) != ERROR_OK)
|
||||||
return ERROR_FAIL;
|
return ERROR_FAIL;
|
||||||
|
|
||||||
return ERROR_OK;
|
return exec_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Actually read registers from the target right now. */
|
/** Actually read registers from the target right now. */
|
||||||
|
@ -798,6 +797,8 @@ static int register_read_direct(struct target *target, uint64_t *value, uint32_t
|
||||||
riscv_xlen(target));
|
riscv_xlen(target));
|
||||||
|
|
||||||
if (result != ERROR_OK) {
|
if (result != ERROR_OK) {
|
||||||
|
result = ERROR_OK;
|
||||||
|
|
||||||
struct riscv_program program;
|
struct riscv_program program;
|
||||||
riscv_program_init(&program, target);
|
riscv_program_init(&program, target);
|
||||||
assert(number != GDB_REGNO_S0);
|
assert(number != GDB_REGNO_S0);
|
||||||
|
@ -823,10 +824,9 @@ static int register_read_direct(struct target *target, uint64_t *value, uint32_t
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute program.
|
// Execute program.
|
||||||
int exec_out = riscv_program_exec(&program, target);
|
result = riscv_program_exec(&program, target);
|
||||||
if (exec_out != ERROR_OK) {
|
if (result != ERROR_OK) {
|
||||||
riscv013_clear_abstract_error(target);
|
riscv013_clear_abstract_error(target);
|
||||||
return ERROR_FAIL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read S0
|
// Read S0
|
||||||
|
@ -837,9 +837,12 @@ static int register_read_direct(struct target *target, uint64_t *value, uint32_t
|
||||||
return ERROR_FAIL;
|
return ERROR_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result == ERROR_OK) {
|
||||||
LOG_DEBUG("[%d] reg[0x%x] = 0x%" PRIx64, riscv_current_hartid(target),
|
LOG_DEBUG("[%d] reg[0x%x] = 0x%" PRIx64, riscv_current_hartid(target),
|
||||||
number, *value);
|
number, *value);
|
||||||
return ERROR_OK;
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** OpenOCD target functions. ***/
|
/*** OpenOCD target functions. ***/
|
||||||
|
|
Loading…
Reference in New Issue