[PATCH] winedbg: gdb proxy mode: support qAttached packet

Paul Bolle pebolle at tiscali.nl
Wed Nov 4 07:48:00 CST 2009


Add support for the qAttached packet. Main benefit is that if gdb was
attached to a debuggee and it quits it will now ask if it should detach
from the debuggee instead of asking whether the debuggee should be
killed. (It still will ask whether the debuggee should be killed if it
launched the debuggee itself).

Signed-off-by: Paul Bolle <pebolle at tiscali.nl>
---
Would it be better to add a new member to gdbctx instead of using a
separate variable (qAttached_reply)?
---
 programs/winedbg/gdbproxy.c |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c
index 57be4b4..ee20961 100644
--- a/programs/winedbg/gdbproxy.c
+++ b/programs/winedbg/gdbproxy.c
@@ -130,6 +130,10 @@ static struct be_process_io be_process_gdbproxy_io =
     tgt_process_gdbproxy_write
 };
 
+static const char* qAttached_reply;
+#define GDBPXY_ATTACHED                 "1"
+#define GDBPXY_LAUNCHED                 "0"
+
 /* =============================================== *
  *       B A S I C   M A N I P U L A T I O N S     *
  * =============================================== *
@@ -1757,6 +1761,13 @@ static enum packet_return packet_query(struct gdb_context* gdbctx)
             return packet_done;
         }
         break;
+    case 'A':
+        if (strncmp(gdbctx->in_packet, "Attached", 8) == 0)
+        {
+            packet_reply(gdbctx, qAttached_reply, 1);
+            return packet_done;
+        }
+        break;
     case 'C':
         if (gdbctx->in_packet_len == 1)
         {
@@ -2376,9 +2387,14 @@ int gdb_main(int argc, char* argv[])
         }
         return -1;
     }
-    if (dbg_active_attach(argc, argv) == start_ok ||
-        dbg_active_launch(argc, argv) == start_ok)
+    if (dbg_active_attach(argc, argv) == start_ok) {
+        qAttached_reply = GDBPXY_ATTACHED;
+        return gdb_remote(gdb_flags);
+    }
+    else if (dbg_active_launch(argc, argv) == start_ok) {
+        qAttached_reply = GDBPXY_LAUNCHED;
         return gdb_remote(gdb_flags);
+    }
 #else
     fprintf(stderr, "GdbProxy mode not supported on this platform\n");
 #endif
-- 
1.6.5.2






More information about the wine-patches mailing list