Commit d3ee9abf authored by unknown's avatar unknown

dbug changes:

1. dbug state is now local to a thread
2. new macros: DBUG_EXPLAIN, DBUG_EXPLAIN_INITIAL,
   DBUG_SET, DBUG_SET_INITIAL, DBUG_EVALUATE, DBUG_EVALUATE_IF
3. macros are do{}while(0) wrapped
4. incremental modifications to the dbug state (e.g. "+d,info:-t")
5. dbug code cleanup, style fixes
6. _db_on_ and DEBUGGER_ON/OFF removed
7. rest of MySQL code fixed because of 3 (missing ;) and 6
8. dbug manual updated
9. server variable @@debug (global and local) to control dbug from SQL!
a. -#T to print timestamps in the log


BitKeeper/deleted/.del-readme.prof~2f3bae1550a0038d:
  Delete: dbug/readme.prof
client/mysqlslap.c:
  typo fixed
configure.in:
  test for sleep() too
dbug/dbug.c:
  thread local dbug settings
  DBUG_EXPLAIN,DBUG_EXPLAIN_INITIAL,DBUG_SET,DBUG_SET_INITIAL
  style changes to be more in line with MySQL code
  cleanup (many mallocs removed)
  incremental modification of dbug state (e.g. DBUG_PUSH("+t:-d,info"))
  DBUG_SET, _db_explain_
  -#T
dbug/monty.doc:
  obsolete and duplicate docs removed
dbug/user.r:
  new features documented
include/my_dbug.h:
  correct do{}while wrapping
  thread local dbug settings
  DBUG_EXPLAIN,DBUG_EXPLAIN_INITIAL,DBUG_SET,DBUG_SET_INITIAL
  DBUG_EVALUATE,DBUG_EVALUATE_IF
libmysql/libmysql.c:
  remove _db_on_ and DEBUGGER_ON/OFF
mysys/my_init.c:
  missed DBUG_RETURN
mysys/my_thr_init.c:
  bugfix - transaction id's are unsigned
mysys/testhash.c:
  remove _db_on_ and DEBUGGER_ON/OFF
sql/ha_myisammrg.cc:
  missed ;
sql/ha_ndbcluster.cc:
  remove _db_on_ and DEBUGGER_ON/OFF
  missed ;
sql/ha_ndbcluster_binlog.cc:
  remove _db_on_ and DEBUGGER_ON/OFF
  missed ;
sql/item_cmpfunc.cc:
  missed ;
sql/lock.cc:
  missed DBUG_RETURN
sql/log_event.cc:
  missed ;
sql/mysqld.cc:
  remove _db_on_ and DEBUGGER_ON/OFF
  missed ;
  DBUG_SET_INITIAL
sql/opt_range.cc:
  remove _db_on_ and DEBUGGER_ON/OFF
sql/set_var.cc:
  class sys_var_thd_dbug and "debug" server variable
sql/set_var.h:
  class sys_var_thd_dbug and "debug" server variable
sql/slave.cc:
  missed ;
sql/sql_cache.cc:
  missed ;
sql/sql_plugin.cc:
  missed ;
sql/sql_select.cc:
  remove _db_on_ and DEBUGGER_ON/OFF
storage/heap/hp_test2.c:
  remove _db_on_ and DEBUGGER_ON/OFF
storage/myisam/ft_eval.c:
  remove _db_on_ and DEBUGGER_ON/OFF
storage/myisam/ft_test1.c:
  remove _db_on_ and DEBUGGER_ON/OFF
storage/myisam/mi_open.c:
  remove _db_on_ and DEBUGGER_ON/OFF
  missed ;
storage/myisam/mi_test1.c:
  remove _db_on_ and DEBUGGER_ON/OFF
storage/myisam/mi_test2.c:
  remove _db_on_ and DEBUGGER_ON/OFF
storage/myisam/mi_test3.c:
  remove _db_on_ and DEBUGGER_ON/OFF
storage/ndb/src/ndbapi/DictCache.cpp:
  missed ;
storage/ndb/src/ndbapi/NdbTransaction.cpp:
  missed ;
tests/mysql_client_test.c:
  remove _db_on_ and DEBUGGER_ON/OFF
parent 8017e9c4
......@@ -730,10 +730,10 @@ build_query_string(void)
strmov(ptr->string, query_string.str);
DBUG_PRINT("info", ("user_supplied_query %s", ptr->string));
dynstr_free(&query_string);
DBUG_RETURN(0);
DBUG_RETURN(ptr);
}
static int
static int
get_options(int *argc,char ***argv)
{
int ho_error;
......
......@@ -1856,7 +1856,7 @@ AC_CHECK_FUNCS(alarm bcmp bfill bmove bsearch bzero \
pthread_setprio_np pthread_setschedparam pthread_sigmask readlink \
realpath rename rint rwlock_init setupterm \
shmget shmat shmdt shmctl sigaction sigemptyset sigaddset \
sighold sigset sigthreadmask \
sighold sigset sigthreadmask sleep \
snprintf socket stpcpy strcasecmp strerror strsignal strnlen strpbrk strstr strtol \
strtoll strtoul strtoull tell tempnam thr_setconcurrency vidattr \
posix_fallocate)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Some extra options to DBUG_PUSH:
O,logfile - As in "o,logfile", but do a close and reopen each time anything
is written to the logfile. This is needed when one expects
the program to crash anywhere, in which case one doesn't
(at least in MSDOS) get a full log-file.
If one wants a logfile with a ':' in the filename, one can get it by
giving a double ':'. (As in "O,c::\tmp\log")
DBUG_DUMP("keyword",memory-position,length) writes a hexdump of the
given memory-area to the outputfile.
All changes that I or other people at MySQL AB have done to all files
in the dbug library (Mainly in dbug.c, dbug_analyze.c, dbug_long.h,
......@@ -18,3 +6,4 @@ dbug.h) are put in public domain, as the rest of the dbug.c library)
To my knowledge, all code in dbug library is in public domain.
Michael Widenius
Hi,
I'm sending you the modifications I made to your Dbug routines to
allow profiling in a (relatively) machine independent fashion.
I use your Dbug routines fairly extensively. Unfortunately, it's
a royal pain to have to keep profiled versions of various libraries
around. The modifications allow profiling without the need for this.
How it works.
------------
Basically, I just added code in the dbug routines to write out a file
called dbugmon.out (by default). This is an ascii file containing lines
of the form:
<function-name> E <time-entered>
<function-name> X <time-exited>
A second program (analyze) reads this file, and produces a report on
standard output.
Profiling is enabled through the `g' flag. It can take a list of
procedure names for which profiling is enabled. By default, it
profiles all procedures.
The code in ``dbug.c'' opens the profile file for appending. This
is in order that one can run a program several times, and get the
sum total of all the times, etc.
The only system dependent part that I'm aware of is the routine
Clock() at the end of dbug.c. This returns the elapsed user time
in milliseconds. The version which I have is for 4.3 BSD. As I
don't have access to other systems, I'm not certain how this would
change.
An example of the report generated follows:
Profile of Execution
Execution times are in milliseconds
Calls Time
----- ----
Times Percentage Time Spent Percentage
Function Called of total in Function of total Importance
======== ====== ========== =========== ========== ==========
factorial 5 83.33 30 100.00 8333
main 1 16.67 0 0.00 0
======== ====== ========== =========== ==========
Totals 6 100.00 30 100.00
As you can see, it's quite self-evident. The ``Importance'' column is a
metric obtained by multiplying the percentage of the calls and the percentage
of the time. Functions with higher 'importance' benefit the most from
being sped up.
I'm really not certain how to add support for setjmp/longjmp, or for
child processes, so I've ignored that for the time being. In most of
the code that I write, it isn't necessary. If you have any good ideas,
feel free to add them.
This has been very useful to me. If you can use it as part of your
dbug distribution, please feel free to do so.
Regards,
Binayak Banerjee
{allegra | astrovax | bpa | burdvax}!sjuvax!bbanerje
bbanerje%sjuvax.sju.edu@relay.cs.net
July 9, 1987
This diff is collapsed.
......@@ -21,15 +21,18 @@
extern "C" {
#endif
#if !defined(DBUG_OFF) && !defined(_lint)
extern int _db_on_,_no_db_;
extern FILE *_db_fp_;
extern char *_db_process_;
extern int _db_keyword_(const char *keyword);
struct _db_code_state_;
extern int _db_keyword_(struct _db_code_state_ *cs, const char *keyword);
extern int _db_strict_keyword_(const char *keyword);
extern int _db_explain_(struct _db_code_state_ *cs, char *buf, int len);
extern int _db_explain_init_(char *buf, int len);
extern void _db_setjmp_(void);
extern void _db_longjmp_(void);
extern void _db_process_(const char *name);
extern void _db_push_(const char *control);
extern void _db_pop_(void);
extern void _db_set_(struct _db_code_state_ *cs, const char *control);
extern void _db_set_init_(const char *control);
extern void _db_enter_(const char *_func_,const char *_file_,uint _line_,
const char **_sfunc_,const char **_sfile_,
uint *_slevel_, char ***);
......@@ -39,61 +42,66 @@ extern void _db_pargs_(uint _line_,const char *keyword);
extern void _db_doprnt_ _VARARGS((const char *format,...));
extern void _db_dump_(uint _line_,const char *keyword,const char *memory,
uint length);
extern void _db_output_(uint flag);
extern void _db_lock_file(void);
extern void _db_unlock_file(void);
extern void _db_lock_file_(void);
extern void _db_unlock_file_(void);
extern FILE *_db_fp_(void);
#define DBUG_ENTER(a) const char *_db_func_, *_db_file_; uint _db_level_; \
char **_db_framep_; \
_db_enter_ (a,__FILE__,__LINE__,&_db_func_,&_db_file_,&_db_level_, \
&_db_framep_)
#define DBUG_LEAVE \
(_db_return_ (__LINE__, &_db_func_, &_db_file_, &_db_level_))
#define DBUG_RETURN(a1) {DBUG_LEAVE; return(a1);}
#define DBUG_VOID_RETURN {DBUG_LEAVE; return;}
_db_return_ (__LINE__, &_db_func_, &_db_file_, &_db_level_)
#define DBUG_RETURN(a1) do {DBUG_LEAVE; return(a1);} while(0)
#define DBUG_VOID_RETURN do {DBUG_LEAVE; return;} while(0)
#define DBUG_EXECUTE(keyword,a1) \
{if (_db_on_) {if (_db_keyword_ (keyword)) { a1 }}}
do {if (_db_keyword_(0, (keyword))) { a1 }} while(0)
#define DBUG_EXECUTE_IF(keyword,a1) \
do {if (_db_strict_keyword_ (keyword)) { a1 } } while(0)
#define DBUG_EVALUATE(keyword,a1,a2) \
(_db_keyword_(0,(keyword)) ? (a1) : (a2))
#define DBUG_EVALUATE_IF(keyword,a1,a2) \
(_db_strict_keyword_((keyword)) ? (a1) : (a2))
#define DBUG_PRINT(keyword,arglist) \
{if (_db_on_) {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;}}
do {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;} while(0)
#define DBUG_PUSH(a1) _db_push_ (a1)
#define DBUG_POP() _db_pop_ ()
#define DBUG_PROCESS(a1) (_db_process_ = a1)
#define DBUG_FILE (_db_fp_)
#define DBUG_SET(a1) _db_set_ (0, (a1))
#define DBUG_SET_INITIAL(a1) _db_set_init_ (a1)
#define DBUG_PROCESS(a1) _db_process_(a1)
#define DBUG_FILE _db_fp_()
#define DBUG_SETJMP(a1) (_db_setjmp_ (), setjmp (a1))
#define DBUG_LONGJMP(a1,a2) (_db_longjmp_ (), longjmp (a1, a2))
#define DBUG_DUMP(keyword,a1,a2)\
{if (_db_on_) {_db_dump_(__LINE__,keyword,a1,a2);}}
#define DBUG_IN_USE (_db_fp_ && _db_fp_ != stderr)
#define DEBUGGER_OFF _no_db_=1;_db_on_=0;
#define DEBUGGER_ON _no_db_=0
#define DBUG_LOCK_FILE { _db_lock_file(); }
#define DBUG_UNLOCK_FILE { _db_unlock_file(); }
#define DBUG_OUTPUT(A) { _db_output_(A); }
#define DBUG_DUMP(keyword,a1,a2) _db_dump_(__LINE__,keyword,a1,a2)
#define DBUG_LOCK_FILE _db_lock_file_()
#define DBUG_UNLOCK_FILE _db_unlock_file_()
#define DBUG_ASSERT(A) assert(A)
#define DBUG_EXECUTE_IF(keyword,a1) \
{if (_db_on_) {if (_db_strict_keyword_ (keyword)) { a1 }}}
#define DBUG_EXPLAIN(buf,len) _db_explain_(0, (buf),(len))
#define DBUG_EXPLAIN_INITIAL(buf,len) _db_explain_init_((buf),(len))
#else /* No debugger */
#define DBUG_ENTER(a1)
#define DBUG_RETURN(a1) return(a1)
#define DBUG_VOID_RETURN return
#define DBUG_EXECUTE(keyword,a1) {}
#define DBUG_EXECUTE_IF(keyword,a1) {}
#define DBUG_PRINT(keyword,arglist) {}
#define DBUG_PUSH(a1) {}
#define DBUG_POP() {}
#define DBUG_PROCESS(a1) {}
#define DBUG_FILE (stderr)
#define DBUG_SETJMP setjmp
#define DBUG_LONGJMP longjmp
#define DBUG_DUMP(keyword,a1,a2) {}
#define DBUG_IN_USE 0
#define DEBUGGER_OFF
#define DEBUGGER_ON
#define DBUG_RETURN(a1) do { return(a1); } while(0)
#define DBUG_VOID_RETURN do { return; } while(0)
#define DBUG_EXECUTE(keyword,a1) do { } while(0)
#define DBUG_EXECUTE_IF(keyword,a1) do { } while(0)
#define DBUG_EVALUATE(keyword,a1,a2) (a2)
#define DBUG_EVALUATE_IF(keyword,a1,a2) (a2)
#define DBUG_PRINT(keyword,arglist) do { } while(0)
#define DBUG_PUSH(a1)
#define DBUG_SET(a1)
#define DBUG_SET_INITIAL(a1)
#define DBUG_POP()
#define DBUG_PROCESS(a1) (a1)
#define DBUG_SETJMP(a1) setjmp(a1)
#define DBUG_LONGJMP(a1) longjmp(a1)
#define DBUG_DUMP(keyword,a1,a2)
#define DBUG_ASSERT(A)
#define DBUG_LOCK_FILE
#define DBUG_FILE (stderr)
#define DBUG_UNLOCK_FILE
#define DBUG_OUTPUT(A)
#define DBUG_ASSERT(A) {}
#define DBUG_EXPLAIN(buf,len)
#define DBUG_EXPLAIN_INITIAL(buf,len)
#endif
#ifdef __cplusplus
}
......
......@@ -179,10 +179,8 @@ void STDCALL mysql_server_end()
if (!org_my_init_done)
{
my_end(0);
#ifndef THREAD
/* Remove TRACING, if enabled by mysql_debug() */
DBUG_POP();
#endif
}
else
mysql_thread_end();
......@@ -267,16 +265,12 @@ mysql_debug(const char *debug __attribute__((unused)))
{
#ifndef DBUG_OFF
char *env;
if (_db_on_)
return; /* Already using debugging */
if (debug)
{
DEBUGGER_ON;
DBUG_PUSH(debug);
}
else if ((env = getenv("MYSQL_DEBUG")))
{
DEBUGGER_ON;
DBUG_PUSH(env);
#if !defined(_WINVER) && !defined(WINVER)
puts("\n-------------------------------------------------------");
......
......@@ -213,6 +213,7 @@ Voluntary context switches %ld, Involuntary context switches %ld\n",
WSACleanup();
#endif /* __WIN__ */
my_init_done=0;
DBUG_VOID_RETURN;
} /* my_end */
......
......@@ -282,7 +282,7 @@ const char *my_thread_name(void)
if (!tmp->name[0])
{
long id=my_thread_id();
sprintf(name_buff,"T@%ld", id);
sprintf(name_buff,"T@%lu", id);
strmake(tmp->name,name_buff,THREAD_NAME_SIZE);
}
return tmp->name;
......
......@@ -250,7 +250,6 @@ err:
static int get_options(int argc, char **argv)
{
char *pos,*progname;
DEBUGGER_OFF;
progname= argv[0];
......@@ -270,7 +269,6 @@ static int get_options(int argc, char **argv)
printf("Usage: %s [-?ABIKLWv] [-m#] [-t#]\n",progname);
exit(0);
case '#':
DEBUGGER_ON;
DBUG_PUSH (++pos);
break;
}
......
......@@ -116,7 +116,7 @@ int ha_myisammrg::open(const char *name, int mode, uint test_if_locked)
DBUG_PRINT("info", ("ha_myisammrg::open exit %d", my_errno));
return (my_errno ? my_errno : -1);
}
DBUG_PRINT("info", ("ha_myisammrg::open myrg_extrafunc..."))
DBUG_PRINT("info", ("ha_myisammrg::open myrg_extrafunc..."));
myrg_extrafunc(file, query_cache_invalidate_by_MyISAM_filename_ref);
if (!(test_if_locked == HA_OPEN_WAIT_IF_LOCKED ||
test_if_locked == HA_OPEN_ABORT_IF_LOCKED))
......
......@@ -2773,7 +2773,7 @@ void ndb_unpack_record(TABLE *table, NdbValue *value,
ndb_blob->getDefined(isNull);
if (isNull == 1)
{
DBUG_PRINT("info",("[%u] NULL", col_no))
DBUG_PRINT("info",("[%u] NULL", col_no));
field->set_null(row_offset);
}
else if (isNull == -1)
......@@ -2811,15 +2811,18 @@ void ha_ndbcluster::unpack_record(byte *buf)
const NDBCOL *hidden_col= tab->getColumn(hidden_no);
const NdbRecAttr* rec= m_value[hidden_no].rec;
DBUG_ASSERT(rec);
DBUG_PRINT("hidden", ("%d: %s \"%llu\"", hidden_no,
DBUG_PRINT("hidden", ("%d: %s \"%llu\"", hidden_no,
hidden_col->getName(), rec->u_64_value()));
}
//print_results();
}
//DBUG_EXECUTE("value", print_results(););
#endif
}
/*
Utility function to print/dump the fetched field
to avoid unnecessary work, wrap in DBUG_EXECUTE as in:
DBUG_EXECUTE("value", print_results(););
*/
void ha_ndbcluster::print_results()
......@@ -2827,8 +2830,6 @@ void ha_ndbcluster::print_results()
DBUG_ENTER("print_results");
#ifndef DBUG_OFF
if (!_db_on_)
DBUG_VOID_RETURN;
char buf_type[MAX_FIELD_WIDTH], buf_val[MAX_FIELD_WIDTH];
String type(buf_type, sizeof(buf_type), &my_charset_bin);
......@@ -6413,7 +6414,7 @@ ha_ndbcluster::register_query_cache_table(THD *thd,
if (!is_autocommit)
{
DBUG_PRINT("exit", ("Can't register table during transaction"))
DBUG_PRINT("exit", ("Can't register table during transaction"));
DBUG_RETURN(FALSE);
}
......@@ -6421,7 +6422,7 @@ ha_ndbcluster::register_query_cache_table(THD *thd,
if (ndb_get_commitcount(thd, m_dbname, m_tabname, &commit_count))
{
*engine_data= 0;
DBUG_PRINT("exit", ("Error, could not get commitcount"))
DBUG_PRINT("exit", ("Error, could not get commitcount"));
DBUG_RETURN(FALSE);
}
*engine_data= commit_count;
......
......@@ -100,24 +100,21 @@ static TABLE_LIST binlog_tables;
#ifndef DBUG_OFF
static void print_records(TABLE *table, const char *record)
{
if (_db_on_)
for (uint j= 0; j < table->s->fields; j++)
{
for (uint j= 0; j < table->s->fields; j++)
char buf[40];
int pos= 0;
Field *field= table->field[j];
const byte* field_ptr= field->ptr - table->record[0] + record;
int pack_len= field->pack_length();
int n= pack_len < 10 ? pack_len : 10;
for (int i= 0; i < n && pos < 20; i++)
{
char buf[40];
int pos= 0;
Field *field= table->field[j];
const byte* field_ptr= field->ptr - table->record[0] + record;
int pack_len= field->pack_length();
int n= pack_len < 10 ? pack_len : 10;
for (int i= 0; i < n && pos < 20; i++)
{
pos+= sprintf(&buf[pos]," %x", (int) (unsigned char) field_ptr[i]);
}
buf[pos]= 0;
DBUG_PRINT("info",("[%u]field_ptr[0->%d]: %s", j, n, buf));
pos+= sprintf(&buf[pos]," %x", (int) (unsigned char) field_ptr[i]);
}
buf[pos]= 0;
DBUG_PRINT("info",("[%u]field_ptr[0->%d]: %s", j, n, buf));
}
}
#else
......@@ -2483,7 +2480,7 @@ ndb_binlog_thread_handle_data_event(Ndb *ndb, NdbEventOperation *pOp,
DBUG_ASSERT(ret == 0);
}
ndb_unpack_record(table, share->ndb_value[n], &b, table->record[n]);
print_records(table, table->record[n]);
DBUG_EXECUTE("info", print_records(table, table->record[n]););
trans.delete_row(::server_id, injector::transaction::table(table, true),
&b, n_fields, table->record[n]);
}
......@@ -2502,7 +2499,7 @@ ndb_binlog_thread_handle_data_event(Ndb *ndb, NdbEventOperation *pOp,
}
ndb_unpack_record(table, share->ndb_value[0],
&b, table->record[0]);
print_records(table, table->record[0]);
DBUG_EXECUTE("info", print_records(table, table->record[0]););
if (table->s->primary_key != MAX_KEY)
{
/*
......@@ -2527,7 +2524,7 @@ ndb_binlog_thread_handle_data_event(Ndb *ndb, NdbEventOperation *pOp,
DBUG_ASSERT(ret == 0);
}
ndb_unpack_record(table, share->ndb_value[1], &b, table->record[1]);
print_records(table, table->record[1]);
DBUG_EXECUTE("info", print_records(table, table->record[1]););
trans.update_row(::server_id,
injector::transaction::table(table, true),
&b, n_fields,
......
......@@ -2860,7 +2860,7 @@ longlong Item_is_not_null_test::val_int()
}
if (args[0]->is_null())
{
DBUG_PRINT("info", ("null"))
DBUG_PRINT("info", ("null"));
owner->was_null|= 1;
DBUG_RETURN(0);
}
......
......@@ -622,7 +622,7 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count,
table_ptr[i], count,
(thd == logger.get_general_log_thd()) ||
(thd == logger.get_slow_log_thd())))
return 0;
DBUG_RETURN(0);
}
if (!(sql_lock= (MYSQL_LOCK*)
......
......@@ -5654,7 +5654,7 @@ Table_map_log_event::Table_map_log_event(THD *thd, TABLE *tbl, ulong tid,
m_data_size= TABLE_MAP_HEADER_LEN;
DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master", m_data_size= 6;)
DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master", m_data_size= 6;);
m_data_size+= m_dblen + 2; // Include length and terminating \0
m_data_size+= m_tbllen + 2; // Include length and terminating \0
m_data_size+= 1 + m_colcnt; // COLCNT and column types
......
......@@ -1089,12 +1089,8 @@ pthread_handler_t kill_server_thread(void *arg __attribute__((unused)))
extern "C" sig_handler print_signal_warning(int sig)
{
if (!DBUG_IN_USE)
{
if (global_system_variables.log_warnings)
sql_print_warning("Got signal %d from thread %d",
sig,my_thread_id());
}
if (global_system_variables.log_warnings)
sql_print_warning("Got signal %d from thread %d", sig,my_thread_id());
#ifdef DONT_REMEMBER_SIGNAL
my_sigset(sig,print_signal_warning); /* int. thread system calls */
#endif
......@@ -1717,7 +1713,7 @@ void end_thread(THD *thd, bool put_in_cache)
! abort_loop && !kill_cached_threads)
{
/* Don't kill the thread, just put it in cache for reuse */
DBUG_PRINT("info", ("Adding thread to cache"))
DBUG_PRINT("info", ("Adding thread to cache"));
cached_thread_count++;
while (!abort_loop && ! wake_thread && ! kill_cached_threads)
(void) pthread_cond_wait(&COND_thread_cache, &LOCK_thread_count);
......@@ -1738,13 +1734,13 @@ void end_thread(THD *thd, bool put_in_cache)
}
}
DBUG_PRINT("info", ("sending a broadcast"))
DBUG_PRINT("info", ("sending a broadcast"));
/* Tell main we are ready */
(void) pthread_mutex_unlock(&LOCK_thread_count);
/* It's safe to broadcast outside a lock (COND... is not deleted here) */
(void) pthread_cond_broadcast(&COND_thread_count);
DBUG_PRINT("info", ("unlocked thread_count mutex"))
DBUG_PRINT("info", ("unlocked thread_count mutex"));
#ifdef ONE_THREAD
if (!(test_flags & TEST_NO_THREADS)) // For debugging under Linux
#endif
......@@ -3467,8 +3463,6 @@ int win_main(int argc, char **argv)
int main(int argc, char **argv)
#endif
{
DEBUGGER_OFF;
rpl_filter= new Rpl_filter;
binlog_filter= new Rpl_filter;
if (!rpl_filter || !binlog_filter)
......@@ -7065,7 +7059,6 @@ static void mysql_init_variables(void)
max_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
global_system_variables.old_passwords= 0;
global_system_variables.old_alter_table= 0;
/*
Default behavior for 4.1 and 5.0 is to treat NULL values as unequal
when collecting index statistics for MyISAM tables.
......@@ -7172,7 +7165,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
switch(optid) {
case '#':
#ifndef DBUG_OFF
DBUG_PUSH(argument ? argument : default_dbug_option);
DBUG_SET(argument ? argument : default_dbug_option);
DBUG_SET_INITIAL(argument ? argument : default_dbug_option);
#endif
opt_endinfo=1; /* unireg: memory allocation */
break;
......
......@@ -10162,8 +10162,6 @@ static void print_sel_tree(PARAM *param, SEL_TREE *tree, key_map *tree_map,
int idx;
char buff[1024];
DBUG_ENTER("print_sel_tree");
if (! _db_on_)
DBUG_VOID_RETURN;
String tmp(buff,sizeof(buff),&my_charset_bin);
tmp.length(0);
......@@ -10192,9 +10190,7 @@ static void print_ror_scans_arr(TABLE *table, const char *msg,
struct st_ror_scan_info **start,
struct st_ror_scan_info **end)
{
DBUG_ENTER("print_ror_scans");
if (! _db_on_)
DBUG_VOID_RETURN;
DBUG_ENTER("print_ror_scans_arr");
char buff[1024];
String tmp(buff,sizeof(buff),&my_charset_bin);
......@@ -10258,7 +10254,7 @@ static void print_quick(QUICK_SELECT_I *quick, const key_map *needed_reg)
{
char buf[MAX_KEY/8+1];
DBUG_ENTER("print_quick");
if (! _db_on_ || !quick)
if (!quick)
DBUG_VOID_RETURN;
DBUG_LOCK_FILE;
......
......@@ -205,6 +205,9 @@ sys_var_long_ptr sys_concurrent_insert("concurrent_insert",
&myisam_concurrent_insert);
sys_var_long_ptr sys_connect_timeout("connect_timeout",
&connect_timeout);
#ifndef DBUG_OFF
sys_var_thd_dbug sys_dbug("debug");
#endif
sys_var_enum sys_delay_key_write("delay_key_write",
&delay_key_write_options,
&delay_key_write_typelib,
......@@ -722,13 +725,16 @@ SHOW_VAR init_vars[]= {
{"datadir", mysql_real_data_home, SHOW_CHAR},
{sys_date_format.name, (char*) &sys_date_format, SHOW_SYS},
{sys_datetime_format.name, (char*) &sys_datetime_format, SHOW_SYS},
#ifndef DBUG_OFF
{sys_dbug.name, (char*) &sys_dbug, SHOW_SYS},
#endif
{sys_default_week_format.name, (char*) &sys_default_week_format, SHOW_SYS},
{sys_delay_key_write.name, (char*) &sys_delay_key_write, SHOW_SYS},
{sys_delayed_insert_limit.name, (char*) &sys_delayed_insert_limit,SHOW_SYS},
{sys_delayed_insert_timeout.name, (char*) &sys_delayed_insert_timeout, SHOW_SYS},
{sys_delayed_queue_size.name,(char*) &sys_delayed_queue_size, SHOW_SYS},
{sys_div_precincrement.name,(char*) &sys_div_precincrement,SHOW_SYS},
{sys_engine_condition_pushdown.name,
{sys_engine_condition_pushdown.name,
(char*) &sys_engine_condition_pushdown, SHOW_SYS},
{sys_event_executor.name, (char*) &sys_event_executor, SHOW_SYS},
{sys_expire_logs_days.name, (char*) &sys_expire_logs_days, SHOW_SYS},
......@@ -3461,6 +3467,33 @@ bool sys_var_trust_routine_creators::update(THD *thd, set_var *var)
return sys_var_bool_ptr::update(thd, var);
}
/* even session variable here requires SUPER, because of -#o,file */
bool sys_var_thd_dbug::check(THD *thd, set_var *var)
{
return check_global_access(thd, SUPER_ACL);
}
bool sys_var_thd_dbug::update(THD *thd, set_var *var)
{
if (var->type == OPT_GLOBAL)
DBUG_SET_INITIAL(var ? var->value->str_value.c_ptr() : "");
else
{
DBUG_POP();
DBUG_PUSH(var ? var->value->str_value.c_ptr() : "");
}
return 0;
}
byte *sys_var_thd_dbug::value_ptr(THD *thd, enum_var_type type, LEX_STRING *b)
{
char buf[256];
if (type == OPT_GLOBAL)
DBUG_EXPLAIN_INITIAL(buf, sizeof(buf));
else
DBUG_EXPLAIN(buf, sizeof(buf));
(byte*) thd->strdup(buf);
}
/****************************************************************************
Used templates
......
......@@ -45,7 +45,7 @@ public:
struct my_option *option_limits; /* Updated by by set_var_init() */
uint name_length; /* Updated by by set_var_init() */
const char *name;
sys_after_update_func after_update;
bool no_support_one_shot;
sys_var(const char *name_arg)
......@@ -413,7 +413,7 @@ class sys_var_thd_bit :public sys_var_thd
public:
ulong bit_flag;
bool reverse;
sys_var_thd_bit(const char *name_arg,
sys_var_thd_bit(const char *name_arg,
sys_check_func c_func, sys_update_func u_func,
ulong bit, bool reverse_arg=0)
:sys_var_thd(name_arg), check_func(c_func), update_func(u_func),
......@@ -427,6 +427,24 @@ public:
byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
};
class sys_var_thd_dbug :public sys_var_thd
{
public:
sys_var_thd_dbug(const char *name_arg) :sys_var_thd(name_arg) {}
bool check_update_type(Item_result type) { return type != STRING_RESULT; }
bool check(THD *thd, set_var *var);
SHOW_TYPE type() { return SHOW_CHAR; }
bool update(THD *thd, set_var *var);
void set_default(THD *thd, enum_var_type type)
{
char buf[256];
DBUG_EXPLAIN_INITIAL(buf, sizeof(buf));
DBUG_SET(buf);
}
byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *b);
};
/* some variables that require special handling */
......
......@@ -2920,7 +2920,7 @@ static int has_temporary_error(THD *thd)
MYSQL_ERROR *err;
while ((err= it++))
{
DBUG_PRINT("info", ("has warning %d %s", err->code, err->msg))
DBUG_PRINT("info", ("has warning %d %s", err->code, err->msg));
switch (err->code)
{
case ER_GET_TEMPORARY_ERRMSG:
......
......@@ -316,13 +316,13 @@ TODO list:
#define MUTEX_UNLOCK(M) {DBUG_PRINT("lock", ("mutex unlock 0x%lx",\
(ulong)(M))); pthread_mutex_unlock(M);}
#define RW_WLOCK(M) {DBUG_PRINT("lock", ("rwlock wlock 0x%lx",(ulong)(M))); \
if (!rw_wrlock(M)) DBUG_PRINT("lock", ("rwlock wlock ok")) \
if (!rw_wrlock(M)) DBUG_PRINT("lock", ("rwlock wlock ok")); \
else DBUG_PRINT("lock", ("rwlock wlock FAILED %d", errno)); }
#define RW_RLOCK(M) {DBUG_PRINT("lock", ("rwlock rlock 0x%lx", (ulong)(M))); \
if (!rw_rdlock(M)) DBUG_PRINT("lock", ("rwlock rlock ok")) \
if (!rw_rdlock(M)) DBUG_PRINT("lock", ("rwlock rlock ok")); \
else DBUG_PRINT("lock", ("rwlock wlock FAILED %d", errno)); }
#define RW_UNLOCK(M) {DBUG_PRINT("lock", ("rwlock unlock 0x%lx",(ulong)(M))); \
if (!rw_unlock(M)) DBUG_PRINT("lock", ("rwlock unlock ok")) \
if (!rw_unlock(M)) DBUG_PRINT("lock", ("rwlock unlock ok")); \
else DBUG_PRINT("lock", ("rwlock unlock FAILED %d", errno)); }
#define STRUCT_LOCK(M) {DBUG_PRINT("lock", ("%d struct lock...",__LINE__)); \
pthread_mutex_lock(M);DBUG_PRINT("lock", ("struct lock OK"));}
......
......@@ -518,7 +518,7 @@ static int plugin_initialize(struct st_plugin_int *plugin)
sql_print_error("Plugin '%s' init function returned error.",
plugin->name.str);
DBUG_PRINT("warning", ("Plugin '%s' init function returned error.",
plugin->name.str))
plugin->name.str));
goto err;
}
}
......@@ -531,7 +531,7 @@ static int plugin_initialize(struct st_plugin_int *plugin)
sql_print_error("Plugin '%s' handlerton init returned error.",
plugin->name.str);
DBUG_PRINT("warning", ("Plugin '%s' handlerton init returned error.",
plugin->name.str))
plugin->name.str));
goto err;
}
break;
......@@ -580,7 +580,7 @@ static void plugin_call_deinitializer(void)
if (tmp->plugin->deinit())
{
DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.",
tmp->name.str))
tmp->name.str));
}
}
tmp->state= PLUGIN_IS_UNINITIALIZED;
......
......@@ -13197,7 +13197,7 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array,
for (i= 0; (item= it++); i++)
{
Field *field;
if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM)
item_field= item;
else
......@@ -13216,7 +13216,7 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array,
DBUG_RETURN(TRUE); // Fatal error
item_field->name= item->name;
#ifndef DBUG_OFF
if (_db_on_ && !item_field->name)
if (!item_field->name)
{
char buff[256];
String str(buff,sizeof(buff),&my_charset_bin);
......
......@@ -617,7 +617,6 @@ err:
static int get_options(int argc,char *argv[])
{
char *pos,*progname;
DEBUGGER_OFF;
progname= argv[0];
......@@ -646,7 +645,6 @@ static int get_options(int argc,char *argv[])
printf("Usage: %s [-?ABIKLsWv] [-m#] [-t#]\n",progname);
exit(0);
case '#':
DEBUGGER_ON;
DBUG_PUSH (++pos);
break;
}
......
......@@ -170,7 +170,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case 'q': silent=1; break;
case 'S': if (stopwordlist==ft_precompiled_stopwords) stopwordlist=NULL; break;
case '#':
DEBUGGER_ON;
DBUG_PUSH (argument);
break;
case 'V':
......
......@@ -284,7 +284,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case 'N': no_search=1; break;
case 'S': no_stopwords=1; break;
case '#':
DEBUGGER_ON;
DBUG_PUSH (argument);
break;
case 'V':
......
......@@ -208,9 +208,9 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
if (len != MI_BASE_INFO_SIZE)
{
DBUG_PRINT("warning",("saved_base_info_length: %d base_info_length: %d",
len,MI_BASE_INFO_SIZE))
len,MI_BASE_INFO_SIZE));
}
disk_pos= (char*)
disk_pos= (char*)
my_n_base_info_read((uchar*) disk_cache + base_pos, &share->base);
share->state.state_length=base_pos;
......
......@@ -648,7 +648,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
printf("test1 Ver 1.2 \n");
exit(0);
case '#':
DEBUGGER_ON;
DBUG_PUSH (argument);
break;
case '?':
......
......@@ -864,7 +864,6 @@ err:
static void get_options(int argc, char **argv)
{
char *pos,*progname;
DEBUGGER_OFF;
progname= argv[0];
......@@ -977,7 +976,6 @@ static void get_options(int argc, char **argv)
progname);
exit(0);
case '#':
DEBUGGER_ON;
DBUG_PUSH (++pos);
break;
default:
......
......@@ -120,7 +120,6 @@ int main(int argc,char **argv)
static void get_options(int argc, char **argv)
{
char *pos,*progname;
DEBUGGER_OFF;
progname= argv[0];
......@@ -150,7 +149,6 @@ static void get_options(int argc, char **argv)
printf("Usage: %s [-?lKA] [-f#] [-t#]\n",progname);
exit(0);
case '#':
DEBUGGER_ON;
DBUG_PUSH (++pos);
break;
default:
......
......@@ -281,7 +281,7 @@ GlobalDictCache::drop(NdbTableImpl * tab)
ver.m_refCount--;
ver.m_status = DROPPED;
if(ver.m_refCount == 0){
DBUG_PRINT("info", ("refCount is zero, deleting m_impl"))
DBUG_PRINT("info", ("refCount is zero, deleting m_impl"));
delete ver.m_impl;
vers->erase(i);
}
......
......@@ -978,7 +978,7 @@ void
NdbTransaction::releaseExecutedScanOperation(NdbIndexScanOperation* cursorOp)
{
DBUG_ENTER("NdbTransaction::releaseExecutedScanOperation");
DBUG_PRINT("enter", ("this=0x%x op=0x%x", (UintPtr)this, (UintPtr)cursorOp))
DBUG_PRINT("enter", ("this=0x%x op=0x%x", (UintPtr)this, (UintPtr)cursorOp));
// here is one reason to make op lists doubly linked
if (m_firstExecutedScanOp == cursorOp) {
......
......@@ -15153,7 +15153,6 @@ int main(int argc, char **argv)
{
struct my_tests_st *fptr;
DEBUGGER_OFF;
MY_INIT(argv[0]);
load_defaults("my", client_test_load_default_groups, &argc, &argv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment