From 95022c620ce829785b858ded1f0eb0a904fc1975 Mon Sep 17 00:00:00 2001 From: ALTracer Date: Sun, 19 Nov 2023 22:39:33 +0300 Subject: [PATCH] gdb_hostio: Expect other-than immediate F-reply packets from GDB --- src/gdb_hostio.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gdb_hostio.c b/src/gdb_hostio.c index c21c56c70ea..98ecc049405 100644 --- a/src/gdb_hostio.c +++ b/src/gdb_hostio.c @@ -73,8 +73,16 @@ int hostio_reply(target_controller_s *const tc, char *const pbuf, const int len) static int hostio_get_response(target_controller_s *const tc) { char *const packet_buffer = gdb_packet_buffer(); - const size_t size = gdb_getpacket(packet_buffer, GDB_PACKET_BUFFER_SIZE); - return gdb_main_loop(tc, packet_buffer, GDB_PACKET_BUFFER_SIZE, size, true); + /* Still have to service normal 'X'/'m'-packets */ + while (true) { + const size_t size = gdb_getpacket(packet_buffer, GDB_PACKET_BUFFER_SIZE); + /* GDB will need us to proxy access the inferior's memory */ + if (packet_buffer[0] != 'F') + gdb_main_loop(tc, packet_buffer, GDB_PACKET_BUFFER_SIZE, size, false); + else + /* GDB finished proxied inferior memory manipulations and returns syscall exitcode */ + return gdb_main_loop(tc, packet_buffer, GDB_PACKET_BUFFER_SIZE, size, true); + }; } /* Interface to host system calls */