Attach command no longer worked as expected, fixed it.
This commit is contained in:
parent
fdd0bfa13c
commit
8e0dcc410c
|
@ -150,7 +150,7 @@ command:
|
|||
| tSYMBOLFILE pathname tEOL { DEBUG_ReadSymbolTable($2, 0); }
|
||||
| tSYMBOLFILE pathname tNUM tEOL { DEBUG_ReadSymbolTable($2, $3); }
|
||||
| tWHATIS expr_addr tEOL { DEBUG_PrintType(&$2); DEBUG_FreeExprMem(); }
|
||||
| tATTACH tNUM tEOL { DEBUG_Attach($2, FALSE); }
|
||||
| tATTACH tNUM tEOL { DEBUG_Attach($2, FALSE, TRUE); }
|
||||
| tDETACH tEOL { return DEBUG_Detach(); /* FIXME: we shouldn't return, but since we cannot simply clean the symbol table, exit debugger for now */ }
|
||||
| list_command
|
||||
| disassemble_command
|
||||
|
@ -426,7 +426,7 @@ static void set_default_channels(void)
|
|||
/***********************************************************************
|
||||
* DEBUG_Parser
|
||||
*
|
||||
* Debugger editline parser
|
||||
* Debugger command line parser
|
||||
*/
|
||||
void DEBUG_Parser(LPCSTR filename)
|
||||
{
|
||||
|
|
|
@ -531,7 +531,7 @@ extern int DEBUG_Printf(int chn, const char* format, ...) __attribute__(
|
|||
extern int DEBUG_Printf(int chn, const char* format, ...);
|
||||
#endif
|
||||
extern DBG_INTVAR* DEBUG_GetIntVar(const char*);
|
||||
extern BOOL DEBUG_Attach(DWORD pid, BOOL cofe);
|
||||
extern BOOL DEBUG_Attach(DWORD pid, BOOL cofe, BOOL wfe);
|
||||
extern BOOL DEBUG_Detach(void);
|
||||
extern void DEBUG_Run(const char* args);
|
||||
extern DBG_PROCESS* DEBUG_AddProcess(DWORD pid, HANDLE h, const char* imageName);
|
||||
|
|
|
@ -262,7 +262,7 @@ DBG_THREAD* DEBUG_AddThread(DBG_PROCESS* p, DWORD tid,
|
|||
t->exec_mode = EXEC_CONT;
|
||||
t->exec_count = 0;
|
||||
|
||||
sprintf(t->name, "%08lx", tid);
|
||||
snprintf(t->name, sizeof(t->name), "%08lx", tid);
|
||||
|
||||
p->num_threads++;
|
||||
t->next = p->threads;
|
||||
|
@ -303,17 +303,40 @@ void DEBUG_DelThread(DBG_THREAD* t)
|
|||
DBG_free(t);
|
||||
}
|
||||
|
||||
BOOL DEBUG_Attach(DWORD pid, BOOL cofe)
|
||||
static BOOL DEBUG_HandleDebugEvent(DEBUG_EVENT* de);
|
||||
|
||||
/******************************************************************
|
||||
* DEBUG_Attach
|
||||
*
|
||||
* Sets the debuggee to <pid>
|
||||
* cofe instructs winedbg what to do when first exception is received
|
||||
* (break=FALSE, continue=TRUE)
|
||||
* wfe is set to TRUE if DEBUG_Attach should also proceed with all debug events
|
||||
* until the first exception is received (aka: attach to an already running process)
|
||||
*/
|
||||
BOOL DEBUG_Attach(DWORD pid, BOOL cofe, BOOL wfe)
|
||||
{
|
||||
DEBUG_EVENT de;
|
||||
|
||||
if (!(DEBUG_CurrProcess = DEBUG_AddProcess(pid, 0, NULL))) return FALSE;
|
||||
|
||||
if (!DebugActiveProcess(pid)) {
|
||||
DEBUG_Printf(DBG_CHN_MESG, "Can't attach process %lx: error %ld\n", pid, GetLastError());
|
||||
DEBUG_DelProcess(DEBUG_CurrProcess);
|
||||
DEBUG_CurrProcess = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
DEBUG_CurrProcess->continue_on_first_exception = cofe;
|
||||
|
||||
if (wfe) /* shall we proceed all debug events until we get an exception ? */
|
||||
{
|
||||
DEBUG_InteractiveP = FALSE;
|
||||
while (DEBUG_CurrProcess && WaitForDebugEvent(&de, INFINITE))
|
||||
{
|
||||
if (DEBUG_HandleDebugEvent(&de)) break;
|
||||
ContinueDebugEvent(de.dwProcessId, de.dwThreadId, DBG_CONTINUE);
|
||||
}
|
||||
if (DEBUG_CurrProcess) DEBUG_InteractiveP = TRUE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -329,7 +352,6 @@ BOOL DEBUG_Detach(void)
|
|||
SetThreadContext(DEBUG_CurrThread->handle, &DEBUG_context);
|
||||
DebugActiveProcessStop(DEBUG_CurrProcess->pid);
|
||||
DEBUG_DelProcess(DEBUG_CurrProcess);
|
||||
DEBUG_CurrProcess = NULL;
|
||||
/* FIXME: should zero out the symbol table too */
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1040,18 +1062,18 @@ int main(int argc, char** argv)
|
|||
|
||||
if (local_mode == none_mode) local_mode = winedbg_mode;
|
||||
|
||||
/* try the from <myself> pid */
|
||||
/* try the form <myself> pid */
|
||||
if (DEBUG_CurrPid == 0 && argc == 2)
|
||||
{
|
||||
char* ptr;
|
||||
|
||||
DEBUG_CurrPid = strtol(argv[1], &ptr, 10);
|
||||
if (DEBUG_CurrPid == 0 || ptr == NULL ||
|
||||
!DEBUG_Attach(DEBUG_CurrPid, local_mode != gdb_mode))
|
||||
!DEBUG_Attach(DEBUG_CurrPid, local_mode != gdb_mode, FALSE))
|
||||
DEBUG_CurrPid = 0;
|
||||
}
|
||||
|
||||
/* try the from <myself> pid evt (Win32 JIT debugger) */
|
||||
/* try the form <myself> pid evt (Win32 JIT debugger) */
|
||||
if (DEBUG_CurrPid == 0 && argc == 3)
|
||||
{
|
||||
HANDLE hEvent;
|
||||
|
@ -1061,7 +1083,7 @@ int main(int argc, char** argv)
|
|||
if ((pid = strtol(argv[1], &ptr, 10)) != 0 && ptr != NULL &&
|
||||
(hEvent = (HANDLE)strtol(argv[2], &ptr, 10)) != 0 && ptr != NULL)
|
||||
{
|
||||
if (!DEBUG_Attach(pid, TRUE))
|
||||
if (!DEBUG_Attach(pid, TRUE, FALSE))
|
||||
{
|
||||
/* don't care about result */
|
||||
SetEvent(hEvent);
|
||||
|
|
Loading…
Reference in New Issue