From 0175ef0c80dd077b44f697b77ba24eef8b16dc72 Mon Sep 17 00:00:00 2001 From: Konstantin Nazarov Date: Mon, 9 Dec 2024 01:26:28 +0000 Subject: [PATCH] Implement reading memory and registers with the debugger --- src/debug.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/debug.cpp b/src/debug.cpp index dbfadf0..3f04e3c 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -203,15 +203,18 @@ bool GDBStub::parse_memory_request(const std::string &packet, size_t &addr, std::string GDBStub::read_registers() { std::ostringstream out; for (int i = 0; i < 32; ++i) { - out << std::string(8, '0'); // TODO: stub + out << std::hex << std::setfill('0') << std::setw(8) << vm.read_register(i); } return out.str(); } std::string GDBStub::read_memory(size_t addr, size_t length) { std::ostringstream out; + std::vector mem = vm.read_memory(addr, length); for (size_t i = 0; i < length; ++i) { - out << "00"; // TODO: stub + out << std::hex << std::setfill('0') << std::setw(2) + << (unsigned int)mem[i]; + out.flush(); } return out.str(); }