Updated debug delay patch

Mike Hearn mh at codeweavers.com
Sat Mar 13 15:34:20 CST 2004


Here is the updated version of my debug delay patch, back by popular
request (well, ok, one person asked for it :)

Usage is simple:

WINEDELAY=1 WINEDEBUG=+relay wine foobar.exe

Hit f12 in any window to switch debug tracing on/off

thanks -mike

Index: dlls/ntdll/debugtools.c
===================================================================
RCS file: /cvstrees/crossover/office/wine/dlls/ntdll/debugtools.c,v
retrieving revision 1.1.1.16
diff -u -r1.1.1.16 debugtools.c
--- dlls/ntdll/debugtools.c     10 Jan 2004 00:11:57 -0000      1.1.1.16
+++ dlls/ntdll/debugtools.c     13 Mar 2004 21:25:28 -0000
@@ -242,6 +242,7 @@
     return res;
 }
  
+
 /***********************************************************************
  *             NTDLL_dbg_vprintf
  */
@@ -298,7 +299,7 @@
             ret += wine_dbg_printf( "%s:%s:%s ", classes[cls], channel + 1, function );
     }
     if (format)
-        ret += NTDLL_dbg_vprintf( format, args );
+        ret += __wine_dbg_vprintf( format, args );
     return ret;
 }
  
@@ -311,5 +312,6 @@
     __wine_dbgstr_wn    = NTDLL_dbgstr_wn;
     __wine_dbg_vsprintf = NTDLL_dbg_vsprintf;
     __wine_dbg_vprintf  = NTDLL_dbg_vprintf;
+    if (getenv("WINEDELAY")) wine_dbg_toggle_block();
     __wine_dbg_vlog     = NTDLL_dbg_vlog;
 }
Index: libs/wine/debug.c
===================================================================
RCS file: /cvstrees/crossover/office/wine/libs/wine/debug.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 debug.c
--- libs/wine/debug.c   5 Dec 2003 00:35:18 -0000       1.1.1.3
+++ libs/wine/debug.c   13 Mar 2004 21:25:28 -0000
@@ -54,6 +54,9 @@
  
 static const char * const debug_classes[] = { "fixme", "err", "warn", "trace" };
  
+static int disabled_dbg_vprintf( const char *format, va_list args );
+static void* old_vprintf = &disabled_dbg_vprintf; /* used when blocking debug output */
+
 static int cmp_name( const void *p1, const void *p2 )
 {
     const char *name = p1;
@@ -140,6 +143,16 @@
     }
 }
  
+static int disabled_dbg_vprintf( const char *format, va_list args ) {
+    return 0;
+}
+
+/* prevents printing of debug messages temporarily */
+void wine_dbg_toggle_block() {
+    fprintf(stderr, "wine: toggling tracing\n");
+    old_vprintf = interlocked_xchg_ptr((void**)&__wine_dbg_vprintf, old_vprintf); /* fixme: is this thread safe? */
+}
+
 /* parse a set of debugging option specifications and add them to the option list */
 int wine_dbg_parse_options( const char *str )
 {
@@ -412,3 +425,4 @@
 {
     return __wine_dbgstr_wn( s, -1 );
 }
+
Index: libs/wine/wine.def
===================================================================
RCS file: /cvstrees/crossover/office/wine/libs/wine/wine.def,v
retrieving revision 1.1.1.8
diff -u -r1.1.1.8 wine.def
--- libs/wine/wine.def  5 Feb 2004 04:00:30 -0000       1.1.1.8
+++ libs/wine/wine.def  13 Mar 2004 21:25:28 -0000
@@ -9,6 +9,7 @@
     __wine_dbgstr_an
     __wine_dbgstr_wn
     __wine_dll_register
+    wine_dbg_toggle_block
     __wine_main_argc
     __wine_main_argv
     __wine_main_environ
Index: libs/wine/wine.map
===================================================================
RCS file: /cvstrees/crossover/office/wine/libs/wine/wine.map,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 wine.map
--- libs/wine/wine.map  14 Feb 2004 01:09:50 -0000      1.1.1.1
+++ libs/wine/wine.map  13 Mar 2004 21:25:28 -0000
@@ -6,6 +6,7 @@
     __wine_dbg_vlog;
     __wine_dbg_vprintf;
     __wine_dbg_vsprintf;
+    wine_dbg_toggle_block;
     __wine_dbgstr_an;
     __wine_dbgstr_wn;
     __wine_dll_register;
Index: dlls/x11drv/keyboard.c
===================================================================
RCS file: /cvstrees/crossover/office/wine/dlls/x11drv/keyboard.c,v
retrieving revision 1.60
diff -u -r1.60 keyboard.c
--- dlls/x11drv/keyboard.c      14 Feb 2004 02:07:55 -0000      1.60
+++ dlls/x11drv/keyboard.c      13 Mar 2004 21:25:30 -0000
@@ -1171,6 +1171,11 @@
       KEYBOARD_GenerateMsg( VK_CAPITAL, 0x3A, event->type, event_time );
       TRACE("State after : %#.2x\n",pKeyStateTable[vkey]);
       break;
+    case VK_F12:
+      if ((event->type == KeyPress) && getenv("WINEDELAY")) {
+   /* we get this event repeatedly if we hold down the key (keyboard repeat) */
+   wine_dbg_toggle_block();
+      }
     default:
         /* Adjust the NUMLOCK state if it has been changed outside wine */
        if (!(pKeyStateTable[VK_NUMLOCK] & 0x01) != !(event->state & NumLockMask))
Index: include/wine/debug.h
===================================================================
RCS file: /cvstrees/crossover/office/wine/include/wine/debug.h,v
retrieving revision 1.1.1.9
diff -u -r1.1.1.9 debug.h
--- include/wine/debug.h        19 Nov 2003 23:42:44 -0000      1.1.1.9
+++ include/wine/debug.h        13 Mar 2004 21:25:31 -0000
@@ -145,6 +145,7 @@
 extern int wine_dbg_printf( const char *format, ... ) __WINE_PRINTF_ATTR(1,2);
 extern int wine_dbg_log( unsigned int cls, const char *ch, const char *func,
                          const char *format, ... ) __WINE_PRINTF_ATTR(4,5);
+extern void wine_dbg_toggle_block();
  
 static inline const char *wine_dbgstr_guid( const GUID *id )
 {







More information about the wine-patches mailing list