This is a slightly simplified version of a patch submitted by Michael Müller. There are two major changes relative to that patch:
* The process name is taken from the initial argv, rather than the "normalized" argv. In practice this means that the executable name may or may not have its .exe extension, and the user of WINEDEBUG will have to guess. Unfortunately using the normalized argv requires dbg_init() to be called later, which would be somewhat unfortunate.
* The original patch had support for a syntax "-process.exe:+channel" that would allow channels to be toggled for all process *except* one. Since the same can be done almost as easily with "+channel,process.exe:-channel", I decided this extra logic was unnecessary.
This proved useful when trying to debug the issue in 4552; I was able to do
WINEDEBUG=+pid,+seh,+msvcrt,wineboot.exe:+heap
whereas enabling +heap for all processes made the log too slow and large.
With that said, in retrospect it would also have been easy to simply hack something specific and temporary into parse_options(), so if this patch set is deemed unnecessary I won't care too much.
From: Zebediah Figura zfigura@codeweavers.com
Based on a patch by Michael Müller. --- dlls/ntdll/unix/debug.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/dlls/ntdll/unix/debug.c b/dlls/ntdll/unix/debug.c index 11bb7a2df22..e73ee05fc03 100644 --- a/dlls/ntdll/unix/debug.c +++ b/dlls/ntdll/unix/debug.c @@ -129,7 +129,7 @@ static void add_option( const char *name, unsigned char set, unsigned char clear }
/* parse a set of debugging option specifications and add them to the option list */ -static void parse_options( const char *str ) +static void parse_options( const char *str, const char *app_name ) { char *opt, *next, *options; unsigned int i; @@ -137,11 +137,18 @@ static void parse_options( const char *str ) if (!(options = strdup(str))) return; for (opt = options; opt; opt = next) { - const char *p; + char *p; unsigned char set = 0, clear = 0;
if ((next = strchr( opt, ',' ))) *next++ = 0;
+ if ((p = strchr( opt, ':' ))) + { + *p = 0; + if (strcasecmp( opt, app_name )) continue; + opt = p + 1; + } + p = opt + strcspn( opt, "+-" ); if (!p[0]) p = opt; /* assume it's a debug channel name */
@@ -182,7 +189,7 @@ static void debug_usage(void) { static const char usage[] = "Syntax of the WINEDEBUG variable:\n" - " WINEDEBUG=[class]+xxx,[class]-yyy,...\n\n" + " WINEDEBUG=[[process:]class]+xxx,[[process:]class]-yyy,...\n\n" "Example: WINEDEBUG=+relay,warn-heap\n" " turns on relay traces, disable heap warnings\n" "Available message classes: err, warn, fixme, trace\n"; @@ -194,6 +201,7 @@ static void debug_usage(void) static void init_options(void) { char *wine_debug = getenv("WINEDEBUG"); + const char *app_name, *p; struct stat st1, st2;
nb_debug_options = 0; @@ -208,7 +216,11 @@ static void init_options(void) } if (!wine_debug) return; if (!strcmp( wine_debug, "help" )) debug_usage(); - parse_options( wine_debug ); + + app_name = main_argv[1]; + while ((p = strpbrk( app_name, "/\" ))) app_name = p + 1; + + parse_options( wine_debug, app_name ); }
/***********************************************************************