winedbg: fixing attach command
Eric Pouech
eric.pouech at wanadoo.fr
Sat Feb 1 07:30:47 CST 2003
attach command no longer worked as expected. this should fix it
A+
--
Eric Pouech
-------------- next part --------------
Name: wd_attach
ChangeLog:
License: X11
GenDate: 2003/02/01 10:55:31 UTC
ModifiedFiles: programs/winedbg/debugger.h programs/winedbg/winedbg.c programs/winedbg/dbg.y
AddedFiles:
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/programs/winedbg/debugger.h,v
retrieving revision 1.4
diff -u -u -r1.4 debugger.h
--- programs/winedbg/debugger.h 30 Jan 2003 00:24:18 -0000 1.4
+++ programs/winedbg/debugger.h 1 Feb 2003 09:29:52 -0000
@@ -531,7 +531,7 @@
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);
Index: programs/winedbg/winedbg.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/programs/winedbg/winedbg.c,v
retrieving revision 1.4
diff -u -u -r1.4 winedbg.c
--- programs/winedbg/winedbg.c 9 Jan 2003 06:00:09 -0000 1.4
+++ programs/winedbg/winedbg.c 1 Feb 2003 10:30:04 -0000
@@ -303,17 +303,40 @@
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 @@
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 @@
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 @@
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);
Index: programs/winedbg/dbg.y
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/programs/winedbg/dbg.y,v
retrieving revision 1.5
diff -u -u -r1.5 dbg.y
--- programs/winedbg/dbg.y 30 Jan 2003 00:24:18 -0000 1.5
+++ programs/winedbg/dbg.y 1 Feb 2003 09:42:42 -0000
@@ -150,9 +150,9 @@
| 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 +427,7 @@
/***********************************************************************
* DEBUG_Parser
*
- * Debugger editline parser
+ * Debugger command line parser
*/
void DEBUG_Parser(LPCSTR filename)
{
@@ -453,7 +454,7 @@
do
{
__TRY
- {
+ {
ret_ok = TRUE;
yyparse();
}
More information about the wine-patches
mailing list