diff --git a/src/xenia/debug/gdb/gdbstub.cc b/src/xenia/debug/gdb/gdbstub.cc index 7121d06688..b716bbf8d4 100644 --- a/src/xenia/debug/gdb/gdbstub.cc +++ b/src/xenia/debug/gdb/gdbstub.cc @@ -260,6 +260,7 @@ std::string GetPacketFriendlyName(const std::string& packetCommand) { {"p", "RegRead"}, {"P", "RegWrite"}, {"g", "RegReadAll"}, + {"G", "RegWriteAll"}, {"C", "Continue"}, {"c", "continue"}, {"s", "step"}, @@ -614,6 +615,28 @@ std::string GDBStub::RegisterReadAll() { return result; } +std::string GDBStub::RegisterWriteAll(const std::string& data) { + auto* thread = cache_.cur_thread_info(); + if (!thread) { + return kGdbReplyError; + } + + int string_offset = 0; + for (int i = 0; i < 71; ++i) { + int reg_size = 8; + if (i > 31 && i < 64) { + reg_size = 16; + } + + std::string_view reg_data(data.data() + string_offset, reg_size); + RegisterWrite(thread, i, reg_data); // TODO: check return value + + string_offset += reg_size; + } + + return kGdbReplyOK; +} + std::string GDBStub::ExecutionPause() { #ifdef DEBUG debugging::DebugPrint("GDBStub: ExecutionPause\n"); @@ -968,6 +991,9 @@ std::string GDBStub::HandleGDBCommand(const GDBCommand& command) { {"P", [&](const GDBCommand& cmd) { return RegisterWrite(cmd.data); }}, // Read all registers {"g", [&](const GDBCommand& cmd) { return RegisterReadAll(); }}, + // Write all registers + {"G", + [&](const GDBCommand& cmd) { return RegisterWriteAll(cmd.data); }}, // Attach to specific process ID - IDA used to send this, but doesn't // after some changes? diff --git a/src/xenia/debug/gdb/gdbstub.h b/src/xenia/debug/gdb/gdbstub.h index 0279538054..d8e4b8a97a 100644 --- a/src/xenia/debug/gdb/gdbstub.h +++ b/src/xenia/debug/gdb/gdbstub.h @@ -68,6 +68,7 @@ class GDBStub : public cpu::DebugListener { std::string RegisterRead(const std::string& data); std::string RegisterWrite(const std::string& data); std::string RegisterReadAll(); + std::string RegisterWriteAll(const std::string& data); std::string ExecutionPause(); std::string ExecutionContinue(); std::string ExecutionStep();