Modify debugger to understand special undocumented "Name Thread"
exception from MS VC6.
This commit is contained in:
parent
6df245dd68
commit
f552359c31
|
@ -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;
|
||||
|
|
|
@ -377,8 +377,11 @@ static DWORD DEBUG_ExceptionEpilog(void)
|
|||
|
||||
static BOOL DEBUG_HandleException(EXCEPTION_RECORD *rec, BOOL first_chance, BOOL force, LPDWORD cont)
|
||||
{
|
||||
BOOL is_debug = FALSE;
|
||||
BOOL ret = TRUE;
|
||||
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))
|
||||
|
|
Loading…
Reference in New Issue