From 5cf439b24e945db47edf6e259044c923384ccdfd Mon Sep 17 00:00:00 2001 From: Jerry Zhao Date: Fri, 14 Oct 2022 11:41:58 -0700 Subject: Add dump memory command to interactive mode --- riscv/devices.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'riscv/devices.cc') diff --git a/riscv/devices.cc b/riscv/devices.cc index eb677a5..81b232d 100644 --- a/riscv/devices.cc +++ b/riscv/devices.cc @@ -137,3 +137,16 @@ char* mem_t::contents(reg_t addr) { } return search->second + pgoff; } + +void mem_t::dump(std::ostream& o) { + const char empty[PGSIZE] = {0}; + for (reg_t i = 0; i < sz; i += PGSIZE) { + reg_t ppn = i >> PGSHIFT; + auto search = sparse_memory_map.find(ppn); + if (search == sparse_memory_map.end()) { + o.write(empty, PGSIZE); + } else { + o.write(sparse_memory_map[ppn], PGSIZE); + } + } +} -- cgit v1.1