diff options
Diffstat (limited to 'dbug')
-rw-r--r-- | dbug/dbug.c | 28 | ||||
-rwxr-xr-x | dbug/remove_function_from_trace.pl | 26 |
2 files changed, 36 insertions, 18 deletions
diff --git a/dbug/dbug.c b/dbug/dbug.c index b2a70fd7ebe..9c92fcc9a7e 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -1845,7 +1845,13 @@ static void DBUGOpenFile(CODE_STATE *cs, else { newfile= !EXISTS(name); - if (!(fp= fopen(name, append ? "a+" : "w"))) + if (!(fp= fopen(name, +#if defined(MSDOS) || defined(__WIN__) + append ? "a+c" : "wc" +#else + append ? "a+" : "w" +#endif + ))) { (void) fprintf(stderr, ERR_OPEN, cs->process, name); perror(""); @@ -2248,23 +2254,9 @@ static void dbug_flush(CODE_STATE *cs) { if (cs->stack->flags & FLUSH_ON_WRITE) { -#if defined(MSDOS) || defined(__WIN__) - if (cs->stack->out_file != stdout && cs->stack->out_file != stderr) - { - if (!(freopen(cs->stack->name,"a",cs->stack->out_file))) - { - (void) fprintf(stderr, ERR_OPEN, cs->process, cs->stack->name); - fflush(stderr); - cs->stack->out_file= stderr; - } - } - else -#endif - { - (void) fflush(cs->stack->out_file); - if (cs->stack->delay) - (void) Delay(cs->stack->delay); - } + (void) fflush(cs->stack->out_file); + if (cs->stack->delay) + (void) Delay(cs->stack->delay); } if (!cs->locked) pthread_mutex_unlock(&THR_LOCK_dbug); diff --git a/dbug/remove_function_from_trace.pl b/dbug/remove_function_from_trace.pl new file mode 100755 index 00000000000..1da9e25f9ba --- /dev/null +++ b/dbug/remove_function_from_trace.pl @@ -0,0 +1,26 @@ +#!/usr/bin/perl + + +die <<EEE unless @ARGV; +Usage: $0 func1 [func2 [ ...] ] + +This filter (stdin->stdout) removes lines from dbug trace that were generated +by specified functions and all functions down the call stack. Produces the +same effect as if the original source had DBUG_PUSH(""); right after +DBUG_ENTER() and DBUG_POP(); right before DBUG_RETURN in every such a function. +EEE + +$re=join('|', @ARGV); +$skip=''; + +while(<STDIN>) { + print unless $skip; + next unless /^(?:.*: )*((?:\| )*)([<>])($re)\n/o; + if ($2 eq '>') { + $skip=$1.$3 unless $skip; + next; + } + next if $skip ne $1.$3; + $skip=''; + print; +} |