Commit f89c8be8 authored by Brendan Shanks's avatar Brendan Shanks Committed by Alexandre Julliard

winedbg: Prefer thread name from GetThreadDescription() in 'info thread' listing.

parent 546638a8
...@@ -385,6 +385,7 @@ extern void info_win32_virtual(DWORD pid); ...@@ -385,6 +385,7 @@ extern void info_win32_virtual(DWORD pid);
extern void info_win32_segments(DWORD start, int length); extern void info_win32_segments(DWORD start, int length);
extern void info_win32_exception(void); extern void info_win32_exception(void);
extern void info_wine_dbg_channel(BOOL add, const char* chnl, const char* name); extern void info_wine_dbg_channel(BOOL add, const char* chnl, const char* name);
extern WCHAR* fetch_thread_description(DWORD tid);
/* memory.c */ /* memory.c */
extern BOOL memory_read_value(const struct dbg_lvalue* lvalue, DWORD size, void* result); extern BOOL memory_read_value(const struct dbg_lvalue* lvalue, DWORD size, void* result);
......
...@@ -595,6 +595,39 @@ static BOOL get_process_name(DWORD pid, PROCESSENTRY32W* entry) ...@@ -595,6 +595,39 @@ static BOOL get_process_name(DWORD pid, PROCESSENTRY32W* entry)
return ret; return ret;
} }
WCHAR* fetch_thread_description(DWORD tid)
{
static HRESULT (WINAPI *my_GetThreadDescription)(HANDLE, PWSTR*) = NULL;
static BOOL resolved = FALSE;
HANDLE h;
WCHAR* desc = NULL;
if (!resolved)
{
HMODULE kernelbase = GetModuleHandleA("kernelbase.dll");
if (kernelbase)
my_GetThreadDescription = (void *)GetProcAddress(kernelbase, "GetThreadDescription");
resolved = TRUE;
}
if (!my_GetThreadDescription)
return NULL;
h = OpenThread(THREAD_QUERY_LIMITED_INFORMATION, FALSE, tid);
if (!h)
return NULL;
my_GetThreadDescription(h, &desc);
CloseHandle(h);
if (desc && desc[0] == '\0')
{
LocalFree(desc);
return NULL;
}
return desc;
}
void info_win32_threads(void) void info_win32_threads(void)
{ {
HANDLE snap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); HANDLE snap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
...@@ -605,6 +638,7 @@ void info_win32_threads(void) ...@@ -605,6 +638,7 @@ void info_win32_threads(void)
DWORD lastProcessId = 0; DWORD lastProcessId = 0;
struct dbg_process* p = NULL; struct dbg_process* p = NULL;
struct dbg_thread* t = NULL; struct dbg_thread* t = NULL;
WCHAR *description;
entry.dwSize = sizeof(entry); entry.dwSize = sizeof(entry);
ok = Thread32First(snap, &entry); ok = Thread32First(snap, &entry);
...@@ -636,12 +670,20 @@ void info_win32_threads(void) ...@@ -636,12 +670,20 @@ void info_win32_threads(void)
entry.th32OwnerProcessID, p ? " (D)" : "", exename); entry.th32OwnerProcessID, p ? " (D)" : "", exename);
lastProcessId = entry.th32OwnerProcessID; lastProcessId = entry.th32OwnerProcessID;
} }
t = dbg_get_thread(p, entry.th32ThreadID); dbg_printf("\t%08lx %4ld%s ",
dbg_printf("\t%08lx %4ld%s %s\n",
entry.th32ThreadID, entry.tpBasePri, entry.th32ThreadID, entry.tpBasePri,
(entry.th32ThreadID == dbg_curr_tid) ? " <==" : " ", (entry.th32ThreadID == dbg_curr_tid) ? " <==" : " ");
t ? t->name : "");
if ((description = fetch_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); ok = Thread32Next(snap, &entry);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment