diff options
author | unknown <monty@narttu.mysql.fi> | 2007-12-30 22:52:33 +0200 |
---|---|---|
committer | unknown <monty@narttu.mysql.fi> | 2007-12-30 22:52:33 +0200 |
commit | 1e9ee8abbd348f3bf1f4342b4db69a025a289523 (patch) | |
tree | 5b0392a55726cb9210e71fbc3b88c4bc7dcd2b33 /dbug | |
parent | f21390874d1325bd829edc952501eb4381ed8732 (diff) | |
parent | bfd5c273c4fb16396279a8a7b396a6558e5a59b0 (diff) | |
download | mariadb-git-1e9ee8abbd348f3bf1f4342b4db69a025a289523.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-maria
into mysql.com:/home/my/mysql-maria
dbug/dbug.c:
Auto merged
include/my_dbug.h:
Auto merged
include/my_global.h:
Auto merged
mysql-test/mysql-test-run.pl:
Auto merged
mysql-test/r/maria-recovery.result:
Auto merged
mysql-test/t/maria-recovery.test:
Auto merged
mysql-test/t/maria.test:
Auto merged
sql/mysqld.cc:
Auto merged
sql/sql_show.cc:
Auto merged
storage/maria/Makefile.am:
Auto merged
storage/maria/ha_maria.cc:
Auto merged
storage/maria/ma_bitmap.c:
Auto merged
storage/maria/ma_check.c:
Auto merged
storage/maria/ma_key_recover.c:
Auto merged
storage/maria/ma_loghandler.c:
Auto merged
storage/maria/ma_open.c:
Auto merged
storage/maria/ma_recovery.c:
Auto merged
storage/maria/maria_chk.c:
Auto merged
storage/maria/maria_def.h:
Auto merged
storage/maria/ma_test_all.sh:
Use remote version
mysql-test/r/maria.result:
Trivial merge
storage/maria/ma_pagecache.c:
Trivial merge
Diffstat (limited to 'dbug')
-rw-r--r-- | dbug/dbug.c | 81 |
1 files changed, 48 insertions, 33 deletions
diff --git a/dbug/dbug.c b/dbug/dbug.c index 4ddf785b27c..9c92fcc9a7e 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -123,11 +123,7 @@ * Typedefs to make things more obvious. */ -#ifndef __WIN__ -typedef int BOOLEAN; -#else -#define BOOLEAN BOOL -#endif +#define BOOLEAN my_bool /* * Make it easy to change storage classes if necessary. @@ -216,6 +212,7 @@ struct settings { static BOOLEAN init_done= FALSE; /* Set to TRUE when initialization done */ static struct settings init_settings; static const char *db_process= 0;/* Pointer to process name; argv[0] */ +my_bool _dbug_on_= TRUE; /* FALSE if no debugging at all */ typedef struct _db_code_state_ { const char *process; /* Pointer to process name; usually argv[0] */ @@ -248,7 +245,8 @@ typedef struct _db_code_state_ { The test below is so we could call functions with DBUG_ENTER before my_thread_init(). */ -#define get_code_state_or_return if (!cs && !((cs=code_state()))) return +#define get_code_state_if_not_set_or_return if (!cs && !((cs=code_state()))) return +#define get_code_state_or_return if (!((cs=code_state()))) return /* Handling lists */ static struct link *ListAdd(struct link *, const char *, const char *); @@ -332,13 +330,20 @@ static CODE_STATE *code_state(void) { CODE_STATE *cs, **cs_ptr; + /* + _dbug_on_ is reset if we don't plan to use any debug commands at all and + we want to run on maximum speed + */ + if (!_dbug_on_) + return 0; + if (!init_done) { + init_done=TRUE; pthread_mutex_init(&THR_LOCK_dbug,MY_MUTEX_INIT_FAST); bzero(&init_settings, sizeof(init_settings)); init_settings.out_file=stderr; init_settings.flags=OPEN_APPEND; - init_done=TRUE; } if (!(cs_ptr= (CODE_STATE**) my_thread_var_dbug())) @@ -405,7 +410,7 @@ static CODE_STATE *code_state(void) void _db_process_(const char *name) { - CODE_STATE *cs=0; + CODE_STATE *cs; if (!db_process) db_process= name; @@ -449,10 +454,10 @@ void _db_process_(const char *name) void _db_set_(CODE_STATE *cs, const char *control) { const char *end; - int rel=0; + int rel; struct settings *stack; - get_code_state_or_return; + get_code_state_if_not_set_or_return; stack= cs->stack; if (control[0] == '-' && control[1] == '#') @@ -693,7 +698,7 @@ void _db_set_(CODE_STATE *cs, const char *control) void _db_push_(const char *control) { - CODE_STATE *cs=0; + CODE_STATE *cs; get_code_state_or_return; PushState(cs); _db_set_(cs, control); @@ -742,7 +747,7 @@ void _db_set_init_(const char *control) void _db_pop_() { struct settings *discard; - CODE_STATE *cs=0; + CODE_STATE *cs; get_code_state_or_return; @@ -836,7 +841,7 @@ int _db_explain_ (CODE_STATE *cs, char *buf, size_t len) { char *start=buf, *end=buf+len-4; - get_code_state_or_return *buf=0; + get_code_state_if_not_set_or_return *buf=0; op_list_to_buf('d', cs->stack->keywords, DEBUGGING); op_int_to_buf ('D', cs->stack->delay, 0); @@ -939,9 +944,15 @@ void _db_enter_(const char *_func_, const char *_file_, uint _line_, const char **_sfunc_, const char **_sfile_, uint *_slevel_, char ***_sframep_ __attribute__((unused))) { - int save_errno=errno; - CODE_STATE *cs=0; + int save_errno; + CODE_STATE *cs; + if (!((cs=code_state()))) + { + *_slevel_= 0; /* Set to avoid valgrind warnings if dbug is enabled later */ + return; + } get_code_state_or_return; + save_errno= errno; *_sfunc_= cs->func; *_sfile_= cs->file; @@ -1015,7 +1026,7 @@ void _db_return_(uint _line_, const char **_sfunc_, const char **_sfile_, uint *_slevel_) { int save_errno=errno; - CODE_STATE *cs=0; + CODE_STATE *cs; get_code_state_or_return; if (cs->level != (int) *_slevel_) @@ -1049,7 +1060,11 @@ void _db_return_(uint _line_, const char **_sfunc_, dbug_flush(cs); } } - cs->level= *_slevel_-1; + /* + Check to not set level < 0. This can happen if DBUG was disabled when + function was entered and enabled in function. + */ + cs->level= *_slevel_ != 0 ? *_slevel_-1 : 0; cs->func= *_sfunc_; cs->file= *_sfile_; #ifndef THREAD @@ -1082,7 +1097,7 @@ void _db_return_(uint _line_, const char **_sfunc_, void _db_pargs_(uint _line_, const char *keyword) { - CODE_STATE *cs=0; + CODE_STATE *cs; get_code_state_or_return; cs->u_line= _line_; cs->u_keyword= keyword; @@ -1118,8 +1133,7 @@ void _db_pargs_(uint _line_, const char *keyword) void _db_doprnt_(const char *format,...) { va_list args; - - CODE_STATE *cs=0; + CODE_STATE *cs; get_code_state_or_return; va_start(args,format); @@ -1167,8 +1181,7 @@ void _db_dump_(uint _line_, const char *keyword, { int pos; char dbuff[90]; - - CODE_STATE *cs=0; + CODE_STATE *cs; get_code_state_or_return; if (_db_keyword_(cs, keyword)) @@ -1480,8 +1493,12 @@ void _db_end_() { struct settings *discard; static struct settings tmp; - CODE_STATE *cs=0; - + CODE_STATE *cs; + /* + Set _dbug_on_ to be able to do full reset even when DEBUGGER_OFF was + called after dbug was initialized + */ + _dbug_on_= 1; get_code_state_or_return; while ((discard= cs->stack)) @@ -1568,7 +1585,7 @@ static BOOLEAN DoProfile(CODE_STATE *cs) FILE *_db_fp_(void) { - CODE_STATE *cs=0; + CODE_STATE *cs; get_code_state_or_return NULL; return cs->stack->out_file; } @@ -1596,7 +1613,7 @@ FILE *_db_fp_(void) BOOLEAN _db_strict_keyword_(const char *keyword) { - CODE_STATE *cs=0; + CODE_STATE *cs; get_code_state_or_return FALSE; if (!DEBUGGING || cs->stack->keywords == NULL) return FALSE; @@ -1630,7 +1647,7 @@ BOOLEAN _db_strict_keyword_(const char *keyword) BOOLEAN _db_keyword_(CODE_STATE *cs, const char *keyword) { - get_code_state_or_return FALSE; + get_code_state_if_not_set_or_return FALSE; return (DEBUGGING && (!TRACING || cs->level <= cs->stack->maxdepth) && @@ -2155,7 +2172,7 @@ static void ChangeOwner(CODE_STATE *cs, char *pathname) EXPORT void _db_setjmp_() { - CODE_STATE *cs=0; + CODE_STATE *cs; get_code_state_or_return; cs->jmplevel= cs->level; @@ -2182,7 +2199,7 @@ EXPORT void _db_setjmp_() EXPORT void _db_longjmp_() { - CODE_STATE *cs=0; + CODE_STATE *cs; get_code_state_or_return; cs->level= cs->jmplevel; @@ -2235,9 +2252,7 @@ char *s; static void dbug_flush(CODE_STATE *cs) { -#ifndef THREAD if (cs->stack->flags & FLUSH_ON_WRITE) -#endif { (void) fflush(cs->stack->out_file); if (cs->stack->delay) @@ -2250,7 +2265,7 @@ static void dbug_flush(CODE_STATE *cs) void _db_lock_file_() { - CODE_STATE *cs=0; + CODE_STATE *cs; get_code_state_or_return; pthread_mutex_lock(&THR_LOCK_dbug); cs->locked=1; @@ -2258,7 +2273,7 @@ void _db_lock_file_() void _db_unlock_file_() { - CODE_STATE *cs=0; + CODE_STATE *cs; get_code_state_or_return; cs->locked=0; pthread_mutex_unlock(&THR_LOCK_dbug); |