Debug trace toggle key

Updated / rebased version can be found in the http://repo.or.cz/w/wine/hacks.git repository. This patch adds F12 as a key for enabling/disabling traces. Note you need to have the environment variable WINEDELAY set. You might need to set Wine to unmanaged in case key presses aren't triggered (this happens in some games).

Index: dlls/winex11.drv/keyboard.c
===================================================================
RCS file: /home/wine/wine/dlls/winex11.drv/keyboard.c,v
retrieving revision 1.85
diff -u -r1.85 keyboard.c
--- dlls/winex11.drv/keyboard.c 9 Feb 2006 11:50:16 -0000       1.85
+++ dlls/winex11.drv/keyboard.c 11 Mar 2006 16:00:02 -0000
@@ -1383,6 +1383,12 @@
       KEYBOARD_GenerateMsg( VK_CAPITAL, 0x3A, event->type, event_time );
       TRACE("State after : %#.2x\n",key_state_table[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 (!(key_state_table[VK_NUMLOCK] & 0x01) != !(event->state & NumLockMask))
Index: libs/wine/debug.c
===================================================================
RCS file: /home/wine/wine/libs/wine/debug.c,v
retrieving revision 1.12
diff -u -r1.12 debug.c
--- libs/wine/debug.c   27 Jan 2006 15:22:50 -0000      1.12
+++ libs/wine/debug.c   11 Mar 2006 16:00:02 -0000
@@ -48,6 +48,14 @@
     return strcmp( name, chan->name );
 }
 
+static int block_traces = 1;
+
+/* prevents printing of debug messages temporarily */
+void wine_dbg_toggle_block() {
+    block_traces = block_traces ? 0 : 1;
+    fprintf(stderr, "wine: toggling tracing: %d\n", block_traces);
+}
+
 /* get the flags to use for a given channel, possibly setting them too in case of lazy init */
 unsigned char __wine_dbg_get_channel_flags( struct __wine_debug_channel *channel )
 {
@@ -226,6 +234,8 @@
     int ret;
     va_list valist;
 
+    if(block_traces) return;
+
     if (!(__wine_dbg_get_channel_flags( channel ) & (1 << cls))) return -1;
 
     va_start(valist, format);
Index: libs/wine/wine.def
===================================================================
RCS file: /home/wine/wine/libs/wine/wine.def,v
retrieving revision 1.19
diff -u -r1.19 wine.def
--- libs/wine/wine.def  6 Mar 2006 18:55:45 -0000       1.19
+++ libs/wine/wine.def  11 Mar 2006 16:00:02 -0000
@@ -5,6 +5,7 @@
     __wine_dbg_set_channel_flags
     __wine_dbg_set_functions
     __wine_dll_register
+    wine_dbg_toggle_block
     __wine_main_argc
     __wine_main_argv
     __wine_main_environ
Index: libs/wine/wine.map
===================================================================
RCS file: /home/wine/wine/libs/wine/wine.map,v
retrieving revision 1.10
diff -u -r1.10 wine.map
--- libs/wine/wine.map  6 Mar 2006 18:55:45 -0000       1.10
+++ libs/wine/wine.map  11 Mar 2006 16:00:02 -0000
@@ -5,6 +5,7 @@
     __wine_dbg_set_channel_flags;
     __wine_dbg_set_functions;
     __wine_dll_register;
+    wine_dbg_toggle_block;
     __wine_main_argc;
     __wine_main_argv;
     __wine_main_environ;

Debug trace toggle key (last edited 2009-10-08 23:15:07 by AlexanderScottJohns)