Brendan Shanks : winedbg: Prefer thread name from GetThreadDescription() in GDB proxy mode.

Alexandre Julliard julliard at winehq.org
Wed Jul 27 16:17:07 CDT 2022


Module: wine
Branch: master
Commit: 2dba29a6538374f6fec39db63fc4d64b5655544d
URL:    https://gitlab.winehq.org/wine/wine/-/commit/2dba29a6538374f6fec39db63fc4d64b5655544d

Author: Brendan Shanks <bshanks at codeweavers.com>
Date:   Wed Feb 23 16:22:09 2022 -0800

winedbg: Prefer thread name from GetThreadDescription() in GDB proxy mode.

---

 programs/winedbg/gdbproxy.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c
index 1999c103372..6b523b30337 100644
--- a/programs/winedbg/gdbproxy.c
+++ b/programs/winedbg/gdbproxy.c
@@ -269,6 +269,18 @@ static inline void reply_buffer_append_str(struct reply_buffer* reply, const cha
     reply_buffer_append(reply, str, strlen(str));
 }
 
+static inline void reply_buffer_append_wstr(struct reply_buffer* reply, const WCHAR* wstr)
+{
+    char* str;
+    int len;
+
+    len = WideCharToMultiByte(CP_ACP, 0, wstr, -1, NULL, 0, NULL, NULL);
+    str = malloc(len);
+    if (str && WideCharToMultiByte(CP_ACP, 0, wstr, -1, str, len, NULL, NULL))
+        reply_buffer_append_str(reply, str);
+    free(str);
+}
+
 static inline void reply_buffer_append_hex(struct reply_buffer* reply, const void* src, size_t len)
 {
     reply_buffer_grow(reply, len * 2);
@@ -1777,6 +1789,7 @@ static enum packet_return packet_query_threads(struct gdb_context* gdbctx)
     struct reply_buffer* reply = &gdbctx->qxfer_buffer;
     struct dbg_process* process = gdbctx->process;
     struct dbg_thread* thread;
+    WCHAR* description;
 
     if (!process) return packet_error;
 
@@ -1790,7 +1803,12 @@ static enum packet_return packet_query_threads(struct gdb_context* gdbctx)
         reply_buffer_append_str(reply, "id=\"");
         reply_buffer_append_uinthex(reply, thread->tid, 4);
         reply_buffer_append_str(reply, "\" name=\"");
-        if (strlen(thread->name))
+        if ((description = fetch_thread_description(thread->tid)))
+        {
+            reply_buffer_append_wstr(reply, description);
+            LocalFree(description);
+        }
+        else if (strlen(thread->name))
         {
             reply_buffer_append_str(reply, thread->name);
         }




More information about the wine-cvs mailing list