A wine magic trace key

Mike Hearn mike at navi.cx
Tue Jun 29 08:59:39 CDT 2004


On Tue, 29 Jun 2004 12:02:26 -0400, Andrei Barbu wrote:
> Is there another way, possibly existing, to do this?
> Is this a really bad idea?

I already implemented this some time ago. You'll need to use
-p1 to patch. To use it set WINEDELAY=1 in the environment. You can then toggle 
tracing with the F12 key - it starts as being off.

thanks -mike


--- orig/dlls/ntdll/debugtools.c
+++ mod/dlls/ntdll/debugtools.c
@@ -244,6 +244,7 @@
     return res;
 }
  
+
 /***********************************************************************
  *             NTDLL_dbg_vprintf
  */
@@ -300,7 +301,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;
 }
  
@@ -313,5 +314,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;
 }
--- orig/dlls/x11drv/keyboard.c
+++ mod/dlls/x11drv/keyboard.c
@@ -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))
--- orig/include/wine/debug.h
+++ mod/include/wine/debug.h
@@ -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 )
 {
--- orig/libs/wine/debug.c
+++ mod/libs/wine/debug.c
@@ -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 );
 }
+
--- orig/libs/wine/wine.def
+++ mod/libs/wine/wine.def
@@ -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
--- orig/libs/wine/wine.map
+++ mod/libs/wine/wine.map
@@ -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;





More information about the wine-devel mailing list