Delay debug tracing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Well, I have no idea if this patch is acceptable but it may prove useful
to some people. I'm not sure if the marked line is fully thread safe,
but I'm not sure how to make it so without a mutex. It's confusing that
InterlockedExchange does not in fact exchange things, rather it moves
them.

Alexandre, is patch this ok?

ChangeLog:
Allow toggling of debug tracing on F12 when WINEDELAY is set

Index: libs/wine/debug.c
===================================================================
RCS file: /home/wine/wine/libs/wine/debug.c,v
retrieving revision 1.2
diff -u -r1.2 debug.c
--- libs/wine/debug.c	3 Oct 2003 03:35:20 -0000	1.2
+++ libs/wine/debug.c	13 Dec 2003 18:58:03 -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 )
 {
@@ -411,3 +424,4 @@
 {
     return __wine_dbgstr_wn( s, -1 );
 }
+
Index: dlls/x11drv/keyboard.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/keyboard.c,v
retrieving revision 1.43
diff -u -r1.43 keyboard.c
--- dlls/x11drv/keyboard.c	21 Nov 2003 21:48:36 -0000	1.43
+++ dlls/x11drv/keyboard.c	13 Dec 2003 18:58:14 -0000
@@ -1162,6 +1162,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: dlls/ntdll/debugtools.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/debugtools.c,v
retrieving revision 1.35
diff -u -r1.35 debugtools.c
--- dlls/ntdll/debugtools.c	8 Oct 2003 22:34:37 -0000	1.35
+++ dlls/ntdll/debugtools.c	13 Dec 2003 18:58:21 -0000
@@ -298,7 +298,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;
 }
Index: include/wine/debug.h
===================================================================
RCS file: /home/wine/wine/include/wine/debug.h,v
retrieving revision 1.12
diff -u -r1.12 debug.h
--- include/wine/debug.h        18 Nov 2003 20:47:48 -0000      1.12
+++ include/wine/debug.h        13 Dec 2003 19:01:12 -0000
@@ -146,6 +146,8 @@
 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 )
 {
     if (!id) return "(null)";





[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux