Commit f552359c authored by James Hatheway's avatar James Hatheway Committed by Alexandre Julliard

Modify debugger to understand special undocumented "Name Thread"

exception from MS VC6.
parent 6df245dd
......@@ -150,6 +150,23 @@ enum dbg_mode
MODE_INVALID, MODE_16, MODE_32, MODE_VM86
};
/* Wine extension; Windows doesn't have a name for this code. This is an
undocumented exception understood by MS VC debugger, allowing the program
to name a particular thread. Search google.com or deja.com for "0x406d1388"
for more info. */
#define EXCEPTION_NAME_THREAD 0x406D1388
/* Helper structure */
typedef struct tagTHREADNAME_INFO
{
DWORD dwType; /* Must be 0x1000 */
LPCTSTR szName; /* Pointer to name - limited to 9 bytes (8 characters + terminator) */
DWORD dwThreadID; /* Thread ID (-1 = caller thread) */
DWORD dwFlags; /* Reserved for future use. Must be zero. */
} THREADNAME_INFO;
typedef struct tagDBG_THREAD {
struct tagDBG_PROCESS* process;
HANDLE handle;
......@@ -161,6 +178,7 @@ typedef struct tagDBG_THREAD {
enum exec_mode dbg_exec_mode;
int dbg_exec_count;
DBG_BREAKPOINT stepOverBP;
char name[9];
struct tagDBG_THREAD* next;
struct tagDBG_THREAD* prev;
} DBG_THREAD;
......
......@@ -379,6 +379,9 @@ static BOOL DEBUG_HandleException(EXCEPTION_RECORD *rec, BOOL first_chance, BOOL
{
BOOL is_debug = FALSE;
BOOL ret = TRUE;
THREADNAME_INFO *pThreadName;
DBG_THREAD *pThread;
*cont = DBG_CONTINUE;
......@@ -388,6 +391,19 @@ static BOOL DEBUG_HandleException(EXCEPTION_RECORD *rec, BOOL first_chance, BOOL
case EXCEPTION_SINGLE_STEP:
is_debug = TRUE;
break;
case EXCEPTION_NAME_THREAD:
pThreadName = (THREADNAME_INFO*)(rec->ExceptionInformation);
if (pThreadName->dwThreadID == -1)
pThread = DEBUG_CurrThread;
else
pThread = DEBUG_GetThread(DEBUG_CurrProcess, pThreadName->dwThreadID);
if (ReadProcessMemory(DEBUG_CurrThread->process->handle, pThreadName->szName,
pThread->name, 9, NULL))
DEBUG_Printf (DBG_CHN_MESG,
"Thread ID=0x%lx renamed using MS VC6 extension (name==\"%s\")\n",
pThread->tid, pThread->name);
return TRUE;
}
if (first_chance && !force && !DBG_IVAR(BreakOnFirstChance))
......
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