KERNEL: invoke the debugger with WINEDEBUG=-all to get a clean backtrace

Mike McCormack mike at codeweavers.com
Tue Jun 29 16:27:20 CDT 2004


ChangeLog:
* invoke the debugger with WINEDEBUG=-all to get a clean backtrace
-------------- next part --------------
Index: dlls/kernel/except.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/except.c,v
retrieving revision 1.6
diff -u -r1.6 except.c
--- dlls/kernel/except.c	1 Jun 2004 19:45:15 -0000	1.6
+++ dlls/kernel/except.c	29 Jun 2004 22:24:01 -0000
@@ -211,6 +211,46 @@
 }
 
 /******************************************************************
+ *		build_debugger_env
+ *
+ *  Build a new environment string for the debugger, 
+ *   and supress it's debug output.
+ */
+static char *build_debugger_env( const char *env )
+{
+    static const char szWineDebug[] = "WINEDEBUG=";
+    static const char szAll[] = "-all";
+    const char *p;
+    char *ret, *dest;
+    int len;
+
+    /* calculate the size of the new environment */
+    len = 0;
+    while( env[len] )
+        len += strlen( &env[len] ) + 1;
+    len += (sizeof szWineDebug + sizeof szAll + 1);
+
+    /* copy the environment, set WINEDEBUG to -all */
+    ret = HeapAlloc( GetProcessHeap(), 0, len );
+    dest = ret;
+    p = env;
+    while( *p )
+    {
+        len = strlen(p) + 1;
+        if (memcmp( p, szWineDebug, sizeof szWineDebug-1 ))
+        {
+            strcpy( dest, p );
+            dest += len;
+        }
+        p += len;
+    }
+    strcpy( dest, szWineDebug );
+    strcat( dest, szAll );
+
+    return ret;
+}
+
+/******************************************************************
  *		start_debugger
  *
  * Does the effective debugger startup according to 'format'
@@ -219,7 +259,7 @@
 {
     OBJECT_ATTRIBUTES attr;
     UNICODE_STRING nameW;
-    char *cmdline, *env, *p;
+    char *cmdline, *env, *dbg_env;
     HKEY		hDbgConf;
     DWORD		bAuto = FALSE;
     PROCESS_INFORMATION	info;
@@ -331,24 +371,15 @@
 
     /* remove WINEDEBUG from the environment */
     env = GetEnvironmentStringsA();
-    for (p = env; *p; p += strlen(p) + 1)
-    {
-        if (!memcmp( p, "WINEDEBUG=", sizeof("WINEDEBUG=")-1 ))
-        {
-            char *next = p + strlen(p) + 1;
-            char *end = next;
-            while (*end) end += strlen(end) + 1;
-            memmove( p, next, end + 1 - next );
-            break;
-        }
-    }
+    dbg_env = build_debugger_env( env );
 
     TRACE("Starting debugger %s\n", debugstr_a(cmdline));
     memset(&startup, 0, sizeof(startup));
     startup.cb = sizeof(startup);
     startup.dwFlags = STARTF_USESHOWWINDOW;
     startup.wShowWindow = SW_SHOWNORMAL;
-    ret = CreateProcessA(NULL, cmdline, NULL, NULL, TRUE, 0, env, NULL, &startup, &info);
+    ret = CreateProcessA(NULL, cmdline, NULL, NULL, TRUE, 0, dbg_env, NULL, &startup, &info);
+    HeapFree(GetProcessHeap(), 0, dbg_env );
     FreeEnvironmentStringsA( env );
 
     if (ret) WaitForSingleObject(hEvent, INFINITE);  /* wait for debugger to come up... */


More information about the wine-patches mailing list