[GDBStub] Add RegisterWriteAll
This commit is contained in:
parent
ea9cf0c8f9
commit
a4187736ad
|
@ -260,6 +260,7 @@ std::string GetPacketFriendlyName(const std::string& packetCommand) {
|
||||||
{"p", "RegRead"},
|
{"p", "RegRead"},
|
||||||
{"P", "RegWrite"},
|
{"P", "RegWrite"},
|
||||||
{"g", "RegReadAll"},
|
{"g", "RegReadAll"},
|
||||||
|
{"G", "RegWriteAll"},
|
||||||
{"C", "Continue"},
|
{"C", "Continue"},
|
||||||
{"c", "continue"},
|
{"c", "continue"},
|
||||||
{"s", "step"},
|
{"s", "step"},
|
||||||
|
@ -614,6 +615,28 @@ std::string GDBStub::RegisterReadAll() {
|
||||||
return result;
|
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; // 8 hex-nibbles per 32-bit register
|
||||||
|
if (i > 31 && i < 64) {
|
||||||
|
reg_size = 16; // 16 hex-nibbles for 64-bit FPR registers
|
||||||
|
}
|
||||||
|
|
||||||
|
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() {
|
std::string GDBStub::ExecutionPause() {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
debugging::DebugPrint("GDBStub: ExecutionPause\n");
|
debugging::DebugPrint("GDBStub: ExecutionPause\n");
|
||||||
|
@ -968,6 +991,9 @@ std::string GDBStub::HandleGDBCommand(const GDBCommand& command) {
|
||||||
{"P", [&](const GDBCommand& cmd) { return RegisterWrite(cmd.data); }},
|
{"P", [&](const GDBCommand& cmd) { return RegisterWrite(cmd.data); }},
|
||||||
// Read all registers
|
// Read all registers
|
||||||
{"g", [&](const GDBCommand& cmd) { return RegisterReadAll(); }},
|
{"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
|
// Attach to specific process ID - IDA used to send this, but doesn't
|
||||||
// after some changes?
|
// after some changes?
|
||||||
|
|
|
@ -68,6 +68,7 @@ class GDBStub : public cpu::DebugListener {
|
||||||
std::string RegisterRead(const std::string& data);
|
std::string RegisterRead(const std::string& data);
|
||||||
std::string RegisterWrite(const std::string& data);
|
std::string RegisterWrite(const std::string& data);
|
||||||
std::string RegisterReadAll();
|
std::string RegisterReadAll();
|
||||||
|
std::string RegisterWriteAll(const std::string& data);
|
||||||
std::string ExecutionPause();
|
std::string ExecutionPause();
|
||||||
std::string ExecutionContinue();
|
std::string ExecutionContinue();
|
||||||
std::string ExecutionStep();
|
std::string ExecutionStep();
|
||||||
|
|
Loading…
Reference in New Issue