[PATCH 4/4] winedbg: Prefer thread name from GetThreadDescription() in 'info thread' listing.
Brendan Shanks
bshanks at codeweavers.com
Tue Mar 15 14:05:17 CDT 2022
Signed-off-by: Brendan Shanks <bshanks at codeweavers.com>
---
programs/winedbg/info.c | 37 +++++++++++++++++++++++++++++++++----
1 file changed, 33 insertions(+), 4 deletions(-)
diff --git a/programs/winedbg/info.c b/programs/winedbg/info.c
index 2b8e377e6f4..1c75280aeec 100644
--- a/programs/winedbg/info.c
+++ b/programs/winedbg/info.c
@@ -581,6 +581,26 @@ static BOOL get_process_name(DWORD pid, PROCESSENTRY32* entry)
return ret;
}
+static WCHAR *get_thread_description(DWORD tid)
+{
+ HANDLE h;
+ WCHAR *desc = NULL;
+
+ h = OpenThread(THREAD_QUERY_LIMITED_INFORMATION, FALSE, tid);
+ if (!h)
+ return NULL;
+
+ GetThreadDescription(h, &desc);
+ CloseHandle(h);
+
+ if (desc && desc[0] == '\0')
+ {
+ LocalFree(desc);
+ return NULL;
+ }
+ return desc;
+}
+
void info_win32_threads(void)
{
HANDLE snap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
@@ -591,6 +611,7 @@ void info_win32_threads(void)
DWORD lastProcessId = 0;
struct dbg_process* p = NULL;
struct dbg_thread* t = NULL;
+ WCHAR *description;
entry.dwSize = sizeof(entry);
ok = Thread32First(snap, &entry);
@@ -622,12 +643,20 @@ void info_win32_threads(void)
entry.th32OwnerProcessID, p ? " (D)" : "", exename);
lastProcessId = entry.th32OwnerProcessID;
}
- t = dbg_get_thread(p, entry.th32ThreadID);
- dbg_printf("\t%08lx %4ld%s %s\n",
+ dbg_printf("\t%08lx %4ld%s ",
entry.th32ThreadID, entry.tpBasePri,
- (entry.th32ThreadID == dbg_curr_tid) ? " <==" : " ",
- t ? t->name : "");
+ (entry.th32ThreadID == dbg_curr_tid) ? " <==" : " ");
+ if ((description = get_thread_description(entry.th32ThreadID)))
+ {
+ dbg_printf("%ls\n", description);
+ LocalFree(description);
+ }
+ else
+ {
+ t = dbg_get_thread(p, entry.th32ThreadID);
+ dbg_printf("%s\n", t ? t->name : "");
+ }
}
ok = Thread32Next(snap, &entry);
}
--
2.34.1
More information about the wine-devel
mailing list