[PATCH 10/15] winedbg: Support qXfer:threads:read request.

Rémi Bernon rbernon at codeweavers.com
Mon Jan 27 06:07:13 CST 2020


As we don't report fork/vfork/exec events, this allows gdb to request
the list of known threads.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 programs/winedbg/gdbproxy.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c
index 6e6ff558081..ab8b9bdd07c 100644
--- a/programs/winedbg/gdbproxy.c
+++ b/programs/winedbg/gdbproxy.c
@@ -1722,6 +1722,24 @@ static void packet_query_libraries(struct gdb_context* gdbctx)
     packet_reply_add(gdbctx, "</library-list>");
 }
 
+static void packet_query_threads(struct gdb_context* gdbctx)
+{
+    struct dbg_process* proc = gdbctx->process;
+    struct dbg_thread* thrd;
+
+    packet_reply_add(gdbctx, "<threads>");
+    LIST_FOR_EACH_ENTRY(thrd, &proc->threads, struct dbg_thread, entry)
+    {
+        packet_reply_add(gdbctx, "<thread ");
+        packet_reply_add(gdbctx, "id=\"");
+        packet_reply_val(gdbctx, thrd->tid, 4);
+        packet_reply_add(gdbctx, "\" name=\"");
+        packet_reply_add(gdbctx, thrd->name);
+        packet_reply_add(gdbctx, "\"/>");
+    }
+    packet_reply_add(gdbctx, "</threads>");
+}
+
 static enum packet_return packet_query(struct gdb_context* gdbctx)
 {
     int off, len;
@@ -1814,6 +1832,7 @@ static enum packet_return packet_query(struct gdb_context* gdbctx)
             packet_reply_open(gdbctx);
             packet_reply_add(gdbctx, "qXfer:features:read+;");
             packet_reply_add(gdbctx, "qXfer:libraries:read+;");
+            packet_reply_add(gdbctx, "qXfer:threads:read+;");
             packet_reply_close(gdbctx);
             return packet_done;
         }
@@ -1859,6 +1878,14 @@ static enum packet_return packet_query(struct gdb_context* gdbctx)
             packet_reply_close_xfer(gdbctx, off, len);
             return packet_done;
         }
+
+        if (snscanf(gdbctx->in_packet, gdbctx->in_packet_len, "Xfer:threads:read::%x,%x", &off, &len) == 2)
+        {
+            packet_reply_open_xfer(gdbctx);
+            packet_query_threads(gdbctx);
+            packet_reply_close_xfer(gdbctx, off, len);
+            return packet_done;
+        }
         break;
     }
     ERR("Unhandled query %s\n", debugstr_an(gdbctx->in_packet, gdbctx->in_packet_len));
-- 
2.25.0




More information about the wine-devel mailing list