Implement reading memory and registers with the debugger

This commit is contained in:
Konstantin Nazarov 2024-12-09 01:26:28 +00:00
parent c7ff2c784c
commit 0175ef0c80
Signed by: knazarov
GPG key ID: 4CFE0A42FA409C22

View file

@ -203,15 +203,18 @@ bool GDBStub::parse_memory_request(const std::string &packet, size_t &addr,
std::string GDBStub::read_registers() { std::string GDBStub::read_registers() {
std::ostringstream out; std::ostringstream out;
for (int i = 0; i < 32; ++i) { 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(); return out.str();
} }
std::string GDBStub::read_memory(size_t addr, size_t length) { std::string GDBStub::read_memory(size_t addr, size_t length) {
std::ostringstream out; std::ostringstream out;
std::vector<uint8_t> mem = vm.read_memory(addr, length);
for (size_t i = 0; i < length; ++i) { 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(); return out.str();
} }