'winedbg --auto'

François Gouget fgouget at codeweavers.com
Sun Oct 21 22:12:46 CDT 2001


   This patch adds an '--auto' mode to winedbg. All Wine packages
(Debian, RPM, ...) should configure the registry so that winedbg is
started in this mode in case of a crash. This can be achieved by putting
the following lines in the AeDebug section of 'system.reg':

"Auto"="1"
"Debugger"=str(2):"%WINEDBG% --debugmsg -all -- --auto %ld %ld"

   The important items are "--debugmsg -all", the goal is not to debug
the winedbg, and "--auto". When started with this flag winedbg will do
the following:
 * ignore all XTerm and other such settings. Everything will be sent to
stderr for easy inclusion in a debug log.
 * dump the registers
 * do a backtrace
 * list the modules (to help correlate addresses)
 * list the threads

   This should make it very easy for end-users to produce more complete
(and thus more usable) bug reports (at least for those cases where we
have a crash). For instance if you ask a user to generate a "+relay"
log, not only will this log contain the relay, but it will also contain
the description of the exception, the backtrace, ...
   Of course Wine developpers would continue starting the debugger in
manual mode and interact with it manually.


Changelog:

   Alexandre Julliard <julliard at codeweavers.com>

 * debugger/winedbg.c

   Add a "--auto" mode to winedbg


-- 
François Gouget
fgouget at codeweavers.com
-------------- next part --------------
Index: debugger/winedbg.c
===================================================================
RCS file: /home/wine/wine/debugger/winedbg.c,v
retrieving revision 1.41
diff -u -r1.41 winedbg.c
--- debugger/winedbg.c	2001/10/21 15:18:15	1.41
+++ debugger/winedbg.c	2001/10/21 19:18:42
@@ -33,6 +33,7 @@
 static char*	DEBUG_LastCmdLine = NULL;
 
 static DBG_PROCESS* DEBUG_ProcessList = NULL;
+static int automatic_mode;
 DBG_INTVAR DEBUG_IntVars[DBG_IV_LAST];
 
 void	DEBUG_Output(int chn, const char* buffer, int len)
@@ -519,6 +520,12 @@
 		 DEBUG_CurrThread->dbg_exec_mode, DEBUG_CurrThread->dbg_exec_count);
 #endif
 
+    if (automatic_mode)
+    {
+        DEBUG_ExceptionProlog(is_debug, FALSE, rec->ExceptionCode);
+        return FALSE;  /* terminate execution */
+    }
+
     if (DEBUG_ExceptionProlog(is_debug, force, rec->ExceptionCode)) {
 	DEBUG_interactiveP = TRUE;
 	while ((ret = DEBUG_Parser())) {
@@ -822,6 +829,29 @@
     return 0;
 }
 
+static DWORD DEBUG_AutoMode(void)
+{
+    DEBUG_EVENT de;
+    DWORD cont;
+    BOOL ret = TRUE;
+
+    DEBUG_Printf(DBG_CHN_MESG, " on pid %lx\n", DEBUG_CurrPid);
+
+    while (ret && DEBUG_ProcessList && WaitForDebugEvent(&de, INFINITE))
+    {
+        ret = DEBUG_HandleDebugEvent(&de, &cont);
+        ContinueDebugEvent(de.dwProcessId, de.dwThreadId, cont);
+    }
+    /* print some extra information */
+    DEBUG_Printf(DBG_CHN_MESG, "Modules:\n");
+    DEBUG_WalkModules();
+    DEBUG_Printf(DBG_CHN_MESG, "Threads:\n");
+    DEBUG_WalkThreads();
+
+    DEBUG_Printf(DBG_CHN_MESG, "WineDbg terminated on pid %lx\n", DEBUG_CurrPid);
+    return 0;
+}
+
 static	BOOL	DEBUG_Start(LPSTR cmdLine)
 {
     PROCESS_INFORMATION	info;
@@ -875,6 +905,18 @@
     /* Initialize internal vars (types must have been initialized before) */
     if (!DEBUG_IntVarsRW(TRUE)) return -1;
 
+    if (argc > 1 && !strcmp( argv[1], "--auto" ))
+    {
+        argc--;
+        argv++;
+        automatic_mode = 1;
+        /* force some internal variables */
+        DBG_IVAR(UseXTerm) = 0;
+        DBG_IVAR(BreakOnDllLoad) = 0;
+        DBG_IVAR(ConChannelMask) = 0;
+        DBG_IVAR(StdChannelMask) = DBG_CHN_MESG;
+    }
+
     /* keep it as a guiexe for now, so that Wine won't touch the Unix stdin, 
      * stdout and stderr streams
      */
@@ -930,10 +972,17 @@
 	DEBUG_LastCmdLine = cmdLine;
     }
 
-    retv = DEBUG_MainLoop();
-
-    /* saves modified variables */
-    DEBUG_IntVarsRW(FALSE);
+    if (automatic_mode)
+    {
+        retv = DEBUG_AutoMode();
+        /* don't save modified variables in auto mode */
+    }
+    else
+    {
+        retv = DEBUG_MainLoop();
+        /* saves modified variables */
+        DEBUG_IntVarsRW(FALSE);
+    }
 
  leave:
     return retv;


More information about the wine-patches mailing list