Skip to content

Commit

Permalink
[GDBStub] Add RegisterWriteAll
Browse files Browse the repository at this point in the history
  • Loading branch information
emoose committed Oct 7, 2024
1 parent 14e7ff4 commit bd964f9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/xenia/debug/gdb/gdbstub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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?
Expand Down
1 change: 1 addition & 0 deletions src/xenia/debug/gdb/gdbstub.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit bd964f9

Please sign in to comment.