summaryrefslogtreecommitdiff
path: root/gdbremote.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gdbremote.cpp')
-rw-r--r--gdbremote.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/gdbremote.cpp b/gdbremote.cpp
index 98a0e2a..a093192 100644
--- a/gdbremote.cpp
+++ b/gdbremote.cpp
@@ -78,15 +78,28 @@ int main(int argc, char *argv[])
while ((read_size = recv(conn_fd, msg_buf, MESSAGE_BUFFER_SIZE, 0)) > 0) {
for (size_t i = 0; i < static_cast<size_t>(read_size); i++) {
const auto res = exchange_ctx.Consume(msg_buf[i]);
- if (res != nullptr) {
- if (res->packet.length() > 0) {
- printf("<- \"%s\"\n", res->packet.c_str());
- }
- if (res->response.length() > 0) {
- printf("-> \"%s\"\n", res->response.c_str());
- if (send(conn_fd, &res->response[0], res->response.length(), 0) == -1)
- perror("Send failed");
- }
+ if (res == nullptr) continue;
+ if (res->packet.length() > 0) {
+ if (0) printf("<- \"%s\"\n", res->packet.c_str());
+ printf("<- \"%s\"\n", exchange_ctx.GetLastPacket().c_str());
+ const auto packet = GDBRemote::Packet::Parse(res->packet);
+ printf(
+ " Packet type: \"%s\"\n",
+ GDBRemote::Packet::PacketTypeToString(packet.type));
+ }
+ if (res->ack.length() > 0) {
+ printf("-> \"%s\"\n", res->ack.c_str());
+ if (send(conn_fd, &res->ack[0], res->ack.length(), 0) == -1)
+ perror("Send failed (ack/nak)");
+ }
+ if (res->packet.length() > 0) {
+ const auto packet = GDBRemote::Packet::Parse(res->packet);
+
+ (void) packet;
+ const auto response = exchange_ctx.WrapDataToSend();
+ printf("-> \"%s\"\n", response.c_str());
+ if (send(conn_fd, &response[0], response.length(), 0) == -1)
+ perror("Send failed (response)");
}
}
memset(msg_buf, '\0', MESSAGE_BUFFER_SIZE);