diff options
author | Tim Newsome <tim@sifive.com> | 2020-12-13 20:08:08 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-13 20:08:08 -0800 |
commit | 4e3d8df5a8c45c1b3cf3059d0786e947a9f2aba6 (patch) | |
tree | 185170d0298f69727b3fcce4a19effe14419bd25 /riscv/debug_module.cc | |
parent | d74b2cd324bd88f7d824a8f106a63dce06038bcf (diff) | |
download | riscv-isa-sim-4e3d8df5a8c45c1b3cf3059d0786e947a9f2aba6.zip riscv-isa-sim-4e3d8df5a8c45c1b3cf3059d0786e947a9f2aba6.tar.gz riscv-isa-sim-4e3d8df5a8c45c1b3cf3059d0786e947a9f2aba6.tar.bz2 |
Preserve abstract s0 write if progbuf excepts. (#615)
When a single abstract command writes s0 and executes a program buffer
that leads to an exception, the value of s0 should still persist. The
fact that it did not masked the following bug in OpenOCD:
https://github.com/riscv/riscv-openocd/issues/559
Diffstat (limited to 'riscv/debug_module.cc')
-rw-r--r-- | riscv/debug_module.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/riscv/debug_module.cc b/riscv/debug_module.cc index 5490d0e..920166c 100644 --- a/riscv/debug_module.cc +++ b/riscv/debug_module.cc @@ -661,6 +661,17 @@ bool debug_module_t::perform_abstract_command() return true; } + if (regno == 0x1000 + S0 && write) { + /* + * The exception handler starts out be restoring dscratch to s0, + * which was saved before executing the abstract memory region. Since + * we just wrote s0, also make sure to write that same value to + * dscratch in case an exception occurs in a program buffer that + * might be executed later. + */ + write32(debug_abstract, i++, csrw(S0, CSR_DSCRATCH0)); + } + } else if (regno >= 0x1020 && regno < 0x1040) { unsigned fprnum = regno - 0x1020; |