From 75ecb87fed3c78a9f2295eb32ff3a9d5f63d1200 Mon Sep 17 00:00:00 2001 From: Jan Zerebecki Date: Wed, 14 Jul 2010 00:13:25 +0200 Subject: [PATCH] libs/wine winex11.drv: Toggle debug traces with the key F12. To disable debug traces on startup set the environment variable WINEDELAY=enable , to only enable the hotkey (with traces enabled on startup) set the variable to anything (e.g. empty). If keypresses are not picked up you might need to set wine to unmanaged or use the virtual desktop mode. Based on a patch from http://wiki.winehq.org/Debug_trace_toggle_key by Mike Hearn, with additions from http://kegel.com/wine/debug-delay-3.patch by Dan Kegel. --- dlls/winex11.drv/keyboard.c | 5 +++++ include/wine/debug.h | 1 + libs/wine/debug.c | 13 +++++++++++++ libs/wine/wine.def | 1 + libs/wine/wine.map | 1 + 5 files changed, 21 insertions(+) diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c index d9da4d282c2..c11ec4399b9 100644 --- a/dlls/winex11.drv/keyboard.c +++ b/dlls/winex11.drv/keyboard.c @@ -1480,6 +1480,11 @@ void X11DRV_KeyEvent( HWND hwnd, XEvent *xev ) update_lock_state(VK_SCROLL, 0x46, event_time); } + /* we get this event repeatedly if we hold down the key (keyboard repeat) */ + if ((VK_F12 == vkey) && (event->type == KeyPress) && getenv("WINEDELAY")) { + __wine_dbg_toggle_block(); + } + bScan = keyc2scan[event->keycode] & 0xFF; TRACE_(key)("bScan = 0x%02x.\n", bScan); diff --git a/include/wine/debug.h b/include/wine/debug.h index ba6fabef1ab..bae075a2964 100644 --- a/include/wine/debug.h +++ b/include/wine/debug.h @@ -152,6 +152,7 @@ struct __wine_debug_functions const char *function, const char *format, va_list args ); }; +extern void __wine_dbg_toggle_block(void); extern unsigned char __wine_dbg_get_channel_flags( struct __wine_debug_channel *channel ); extern int __wine_dbg_set_channel_flags( struct __wine_debug_channel *channel, unsigned char set, unsigned char clear ); diff --git a/libs/wine/debug.c b/libs/wine/debug.c index 12dbeb81ec1..3ff43f3c4db 100644 --- a/libs/wine/debug.c +++ b/libs/wine/debug.c @@ -49,6 +49,14 @@ static int cmp_name( const void *p1, const void *p2 ) return strcmp( name, chan->name ); } +static int block_traces = 0; + +/* enable or disable printing of debug messages temporarily */ +void __wine_dbg_toggle_block() { + block_traces = !block_traces; + fprintf(stderr, "wine: tracing is now %s\n", block_traces ? "disabled" : "enabled"); +} + /* 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 ) { @@ -56,9 +64,11 @@ unsigned char __wine_dbg_get_channel_flags( struct __wine_debug_channel *channel if (nb_debug_options) { + if(!block_traces) { struct __wine_debug_channel *opt = bsearch( channel->name, debug_options, nb_debug_options, sizeof(debug_options[0]), cmp_name ); if (opt) return opt->flags; + } else return default_flags; } /* no option for this channel */ if (channel->flags & (1 << __WINE_DBCL_INIT)) channel->flags = default_flags; @@ -194,6 +204,9 @@ static void debug_init(void) if (!strcmp( wine_debug, "help" )) debug_usage(); parse_options( wine_debug ); } + if(!block_traces && getenv("WINEDELAY") && 0 == strncasecmp(getenv("WINEDELAY"), "enable", 6) ) { + __wine_dbg_toggle_block(); + } } /* varargs wrapper for funcs.dbg_vprintf */ diff --git a/libs/wine/wine.def b/libs/wine/wine.def index ed315bd08b1..e1263e18182 100644 --- a/libs/wine/wine.def +++ b/libs/wine/wine.def @@ -2,6 +2,7 @@ LIBRARY libwine.dll EXPORTS __wine_dbg_get_channel_flags + __wine_dbg_toggle_block __wine_dbg_set_channel_flags __wine_dbg_set_functions __wine_dll_register diff --git a/libs/wine/wine.map b/libs/wine/wine.map index 2159fac852b..19d454e0586 100644 --- a/libs/wine/wine.map +++ b/libs/wine/wine.map @@ -2,6 +2,7 @@ WINE_1.0 { global: __wine_dbg_get_channel_flags; + __wine_dbg_toggle_block; __wine_dbg_set_channel_flags; __wine_dbg_set_functions; __wine_dll_register; -- 2.11.4.GIT