diff options
author | Michael Widenius <monty@askmonty.org> | 2010-11-24 00:09:54 +0200 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2010-11-24 00:09:54 +0200 |
commit | b16c389248d03f0c3de549884f607f3f191827b4 (patch) | |
tree | 6068b9d90b4127b1c3608e29913fa82bf1a1f20e /dbug | |
parent | 01b100b5dd3040daa18791abb88a9ffef06efe67 (diff) | |
parent | b52020221e8b4e58d1bc6dd5a5a6f065a6a3a083 (diff) | |
download | mariadb-git-b16c389248d03f0c3de549884f607f3f191827b4.tar.gz |
Automerge with 5.1
Diffstat (limited to 'dbug')
-rw-r--r-- | dbug/Makefile.am | 9 | ||||
-rw-r--r-- | dbug/dbug.c | 30 | ||||
-rwxr-xr-x | dbug/remove_function_from_trace.pl | 11 |
3 files changed, 27 insertions, 23 deletions
diff --git a/dbug/Makefile.am b/dbug/Makefile.am index 528a6a02fbf..e8acb0ca2c0 100644 --- a/dbug/Makefile.am +++ b/dbug/Makefile.am @@ -16,10 +16,11 @@ # MA 02111-1307, USA INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -LDADD = libdbug.a ../mysys/libmysys.a ../strings/libmystrings.a +LDADD = libdbug.a $(top_builddir)/mysys/libmysys.a $(top_builddir)/strings/libmystrings.a pkglib_LIBRARIES = libdbug.a +noinst_LTLIBRARIES = libdbug.la noinst_HEADERS = dbug_long.h -libdbug_a_SOURCES = dbug.c sanity.c +libdbug_la_SOURCES = dbug.c sanity.c EXTRA_DIST = CMakeLists.txt example1.c example2.c example3.c \ user.r monty.doc dbug_add_tags.pl \ my_main.c main.c factorial.c dbug_analyze.c \ @@ -65,3 +66,7 @@ output5.r: factorial # a hack to have executable in builddir, not in srcdir tests-t: tests-t.pl cp -f $(srcdir)/tests-t.pl ./tests-t + +libdbug_a_SOURCES= +libdbug.a: libdbug.la + $(CP) .libs/libdbug.a $@ diff --git a/dbug/dbug.c b/dbug/dbug.c index cad7fbb3030..e653013e09a 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -286,7 +286,7 @@ typedef struct _db_code_state_ { #define ListDel(A,B,C) ListAddDel(A,B,C,EXCLUDE) static struct link *ListAddDel(struct link *, const char *, const char *, int); static struct link *ListCopy(struct link *); -static int InList(struct link *linkp,const char *cp); +static int InList(struct link *linkp,const char *cp, int exact_match); static uint ListFlags(struct link *linkp); static void FreeList(struct link *linkp); @@ -982,7 +982,7 @@ void _db_pop_() } while (0) #define str_to_buf(S) do { \ char_to_buf(','); \ - buf=strnmov(buf, (S), len+1); \ + buf=strnmov(buf, (S), (uint) (end-buf)); \ if (buf >= end) goto overflow; \ } while (0) #define list_to_buf(l, f) do { \ @@ -1581,13 +1581,13 @@ static struct link *ListCopy(struct link *orig) * */ -static int InList(struct link *linkp, const char *cp) +static int InList(struct link *linkp, const char *cp, int exact_match) { int result; for (result=MATCHED; linkp != NULL; linkp= linkp->next_link) { - if (!fnmatch(linkp->str, cp, 0)) + if (!(exact_match ? strcmp(linkp->str,cp) : fnmatch(linkp->str, cp, 0))) return linkp->flags; if (!(linkp->flags & EXCLUDE)) result=NOT_MATCHED; @@ -1637,8 +1637,8 @@ static void PushState(CODE_STATE *cs) struct settings *new_malloc; new_malloc= (struct settings *) DbugMalloc(sizeof(struct settings)); + bzero(new_malloc, sizeof(struct settings)); new_malloc->next= cs->stack; - new_malloc->out_file= NULL; cs->stack= new_malloc; } @@ -1752,8 +1752,8 @@ void _db_end_() static int DoTrace(CODE_STATE *cs) { if ((cs->stack->maxdepth == 0 || cs->level <= cs->stack->maxdepth) && - InList(cs->stack->processes, cs->process) & (MATCHED|INCLUDE)) - switch(InList(cs->stack->functions, cs->func)) { + InList(cs->stack->processes, cs->process, 0) & (MATCHED|INCLUDE)) + switch(InList(cs->stack->functions, cs->func, 0)) { case INCLUDE|SUBDIR: return ENABLE_TRACE; case INCLUDE: return DO_TRACE; case MATCHED|SUBDIR: @@ -1790,10 +1790,10 @@ static int DoTrace(CODE_STATE *cs) #ifndef THREAD static BOOLEAN DoProfile(CODE_STATE *cs) { - return PROFILING && - cs->level <= cs->stack->maxdepth && - InList(cs->stack->p_functions, cs->func) & (INCLUDE|MATCHED) && - InList(cs->stack->processes, cs->process) & (INCLUDE|MATCHED); + return (PROFILING && + cs->level <= cs->stack->maxdepth && + InList(cs->stack->p_functions, cs->func, 0) & (INCLUDE|MATCHED) && + InList(cs->stack->processes, cs->process, 0) & (INCLUDE|MATCHED)); } #endif @@ -1826,11 +1826,11 @@ FILE *_db_fp_(void) BOOLEAN _db_keyword_(CODE_STATE *cs, const char *keyword, int strict) { + int match= strict ? INCLUDE : INCLUDE|MATCHED; get_code_state_if_not_set_or_return FALSE; - strict=strict ? INCLUDE : INCLUDE|MATCHED; - return DEBUGGING && DoTrace(cs) & DO_TRACE && - InList(cs->stack->keywords, keyword) & strict; + return (DEBUGGING && DoTrace(cs) & DO_TRACE && + InList(cs->stack->keywords, keyword, strict) & match); } /* @@ -2121,7 +2121,7 @@ static FILE *OpenProfile(CODE_STATE *cs, const char *name) static void DBUGCloseFile(CODE_STATE *cs, FILE *fp) { - if (fp != stderr && fp != stdout && fclose(fp) == EOF) + if (fp != NULL && fp != stderr && fp != stdout && fclose(fp) == EOF) { if (!cs->locked) pthread_mutex_lock(&THR_LOCK_dbug); diff --git a/dbug/remove_function_from_trace.pl b/dbug/remove_function_from_trace.pl index 1da9e25f9ba..380df168caf 100755 --- a/dbug/remove_function_from_trace.pl +++ b/dbug/remove_function_from_trace.pl @@ -1,6 +1,5 @@ #!/usr/bin/perl - die <<EEE unless @ARGV; Usage: $0 func1 [func2 [ ...] ] @@ -11,16 +10,16 @@ DBUG_ENTER() and DBUG_POP(); right before DBUG_RETURN in every such a function. EEE $re=join('|', @ARGV); -$skip=''; while(<STDIN>) { - print unless $skip; + ($thd) = /^(T@\d+)/; + print unless $skip{$thd}; next unless /^(?:.*: )*((?:\| )*)([<>])($re)\n/o; if ($2 eq '>') { - $skip=$1.$3 unless $skip; + $skip{$thd}=$1.$3 unless $skip{$thd}; next; } - next if $skip ne $1.$3; - $skip=''; + next if $skip{$thd} ne $1.$3; + delete $skip{$thd}; print; } |