diff options
author | Oxore <oxore@protonmail.com> | 2022-08-30 00:22:07 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2022-08-30 00:22:07 +0300 |
commit | 026894023fa53fa32fd342d18e05f55743cf6c4b (patch) | |
tree | ba744e909c5e8c8067f535d4dcac1d295f55e228 /gdbremote.cpp | |
parent | 8c012736814265e198d68654ccdc597c265f4f82 (diff) |
Convince GDB that it is connected
Diffstat (limited to 'gdbremote.cpp')
-rw-r--r-- | gdbremote.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/gdbremote.cpp b/gdbremote.cpp index a093192..eb0fed8 100644 --- a/gdbremote.cpp +++ b/gdbremote.cpp @@ -56,6 +56,24 @@ static int setup_socket(uint16_t port) return socket_fd; } +static std::string CreateResponse(const GDBRemote::Packet& packet) +{ + using namespace GDBRemote; + if (0) { + } else if (packet.type == PacketType::kQueryHaltReason) { + return "S05"; + } else if (packet.type == PacketType::kSetThreadForCont) { + return "OK"; + } else if (packet.type == PacketType::kQueryAttached) { + return "1"; + } else if (packet.type == PacketType::kInterrupt) { + return "OK"; + } else if (packet.type == PacketType::kReadGeneralRegisters) { + return std::string(2*4*17, '0') + "00000200"; // 17 registers + PC + } + return ""; +} + int main(int argc, char *argv[]) { const int port = argc > 1 ? atoi(argv[1]) : 3333; @@ -94,9 +112,8 @@ int main(int argc, char *argv[]) } if (res->packet.length() > 0) { const auto packet = GDBRemote::Packet::Parse(res->packet); - - (void) packet; - const auto response = exchange_ctx.WrapDataToSend(); + const auto response = + exchange_ctx.WrapDataToSend(CreateResponse(packet)); printf("-> \"%s\"\n", response.c_str()); if (send(conn_fd, &response[0], response.length(), 0) == -1) perror("Send failed (response)"); |