diff options
author | Jerry Zhao <jerryz123@berkeley.edu> | 2022-10-14 11:41:58 -0700 |
---|---|---|
committer | Andrew Waterman <aswaterman@gmail.com> | 2022-10-14 15:38:59 -0700 |
commit | 5cf439b24e945db47edf6e259044c923384ccdfd (patch) | |
tree | 8c5f42b3583840b9fc9fd7ae966b2df851fcbe7f /riscv/interactive.cc | |
parent | 7e8d1e6f29a0e6b9f8b1b65a88b5dc87c25a4f9a (diff) | |
download | spike-5cf439b24e945db47edf6e259044c923384ccdfd.zip spike-5cf439b24e945db47edf6e259044c923384ccdfd.tar.gz spike-5cf439b24e945db47edf6e259044c923384ccdfd.tar.bz2 |
Add dump memory command to interactive mode
Diffstat (limited to 'riscv/interactive.cc')
-rw-r--r-- | riscv/interactive.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/riscv/interactive.cc b/riscv/interactive.cc index bba4540..ffc706b 100644 --- a/riscv/interactive.cc +++ b/riscv/interactive.cc @@ -318,6 +318,7 @@ void sim_t::interactive() funcs["until"] = &sim_t::interactive_until_silent; funcs["untiln"] = &sim_t::interactive_until_noisy; funcs["while"] = &sim_t::interactive_until_silent; + funcs["dump"] = &sim_t::interactive_dumpmems; funcs["quit"] = &sim_t::interactive_quit; funcs["q"] = funcs["quit"]; funcs["help"] = &sim_t::interactive_help; @@ -395,6 +396,7 @@ void sim_t::interactive_help(const std::string& cmd, const std::vector<std::stri "pc <core> # Show current PC in <core>\n" "mem [core] <hex addr> # Show contents of virtual memory <hex addr> in [core] (physical memory <hex addr> if omitted)\n" "str [core] <hex addr> # Show NUL-terminated C string at virtual address <hex addr> in [core] (physical address <hex addr> if omitted)\n" + "dump # Dump physical memory to binary files\n" "until reg <core> <reg> <val> # Stop when <reg> in <core> hits <val>\n" "untiln reg <core> <reg> <val> # Run noisy and stop when <reg> in <core> hits <val>\n" "until pc <core> <val> # Stop when PC in <core> hits <val>\n" @@ -774,3 +776,15 @@ void sim_t::interactive_until(const std::string& cmd, const std::vector<std::str step(1); } } + +void sim_t::interactive_dumpmems(const std::string& cmd, const std::vector<std::string>& args) +{ + for (unsigned i = 0; i < mems.size(); i++) { + std::stringstream mem_fname; + mem_fname << "mem.0x" << std::hex << mems[i].first << ".bin"; + + std::ofstream mem_file(mem_fname.str()); + mems[i].second->dump(mem_file); + mem_file.close(); + } +} |