Bug#26243 mysql command line crash after control-c
- Backported the 5.1 DBUG to 5.0. - Avoid memory cleanup race on Windows client for CTRL-C
This commit is contained in:
parent
e09d983825
commit
79e434bc67
@ -1216,21 +1216,35 @@ sig_handler mysql_sigint(int sig)
|
||||
char kill_buffer[40];
|
||||
MYSQL *kill_mysql= NULL;
|
||||
|
||||
signal(SIGINT, mysql_sigint);
|
||||
|
||||
/* terminate if no query being executed, or we already tried interrupting */
|
||||
if (!executing_query || interrupted_query++)
|
||||
mysql_end(sig);
|
||||
goto err;
|
||||
|
||||
kill_mysql= mysql_init(kill_mysql);
|
||||
if (!mysql_real_connect(kill_mysql,current_host, current_user, opt_password,
|
||||
"", opt_mysql_port, opt_mysql_unix_port,0))
|
||||
mysql_end(sig);
|
||||
goto err;
|
||||
/* kill_buffer is always big enough because max length of %lu is 15 */
|
||||
sprintf(kill_buffer, "KILL /*!50000 QUERY */ %lu", mysql_thread_id(&mysql));
|
||||
mysql_real_query(kill_mysql, kill_buffer, strlen(kill_buffer));
|
||||
mysql_close(kill_mysql);
|
||||
tee_fprintf(stdout, "Query aborted by Ctrl+C\n");
|
||||
|
||||
return;
|
||||
|
||||
err:
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
When SIGINT is raised on Windows, the OS creates a new thread to handle the
|
||||
interrupt. Once that thread completes, the main thread continues running
|
||||
only to find that it's resources have already been free'd when the sigint
|
||||
handler called mysql_end().
|
||||
*/
|
||||
mysql_thread_end();
|
||||
return;
|
||||
#else
|
||||
mysql_end(sig);
|
||||
#endif
|
||||
}
|
||||
|
||||
sig_handler mysql_end(int sig)
|
||||
@ -1271,7 +1285,7 @@ sig_handler mysql_end(int sig)
|
||||
my_free(current_prompt,MYF(MY_ALLOW_ZERO_PTR));
|
||||
mysql_server_end();
|
||||
free_defaults(defaults_argv);
|
||||
my_end(info_flag ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
|
||||
my_end(info_flag ? MY_CHECK_ERROR | MY_GIVE_INFO : MY_CHECK_ERROR);
|
||||
exit(status.exit_status);
|
||||
}
|
||||
|
||||
|
2851
dbug/dbug.c
2851
dbug/dbug.c
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,13 @@
|
||||
#ifdef DBUG_OFF /* We are testing dbug */
|
||||
#undef DBUG_OFF
|
||||
#endif
|
||||
|
||||
int factorial(register int value) {
|
||||
if(value > 1) {
|
||||
value *= factorial(value-1);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <my_global.h>
|
||||
|
||||
@ -15,3 +22,6 @@ register int value)
|
||||
DBUG_PRINT ("result", ("result is %d", value));
|
||||
DBUG_RETURN (value);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
297
dbug/user.r
297
dbug/user.r
@ -672,52 +672,26 @@ from the standard include directory.
|
||||
.SP 2
|
||||
.BL 20
|
||||
.LI DBUG_ENTER\
|
||||
Used to tell the runtime support module the name of the function
|
||||
being entered.
|
||||
The argument must be of type "pointer to character".
|
||||
The
|
||||
DBUG_ENTER
|
||||
macro must precede all executable lines in the
|
||||
function just entered, and must come after all local declarations.
|
||||
Each
|
||||
DBUG_ENTER
|
||||
macro must have a matching
|
||||
DBUG_RETURN
|
||||
or
|
||||
DBUG_VOID_RETURN
|
||||
macro
|
||||
at the function exit points.
|
||||
DBUG_ENTER
|
||||
macros used without a matching
|
||||
DBUG_RETURN
|
||||
or
|
||||
DBUG_VOID_RETURN
|
||||
macro
|
||||
will cause warning messages from the
|
||||
Used to tell the runtime support module the name of the function being
|
||||
entered. The argument must be of type "pointer to character". The
|
||||
DBUG_ENTER macro must precede all executable lines in the function
|
||||
just entered, and must come after all local declarations. Each
|
||||
DBUG_ENTER macro must have a matching DBUG_RETURN or DBUG_VOID_RETURN
|
||||
macro at the function exit points. DBUG_ENTER macros used without a
|
||||
matching DBUG_RETURN or DBUG_VOID_RETURN macro will cause warning
|
||||
messages from the
|
||||
.I dbug
|
||||
package runtime support module.
|
||||
.SP 1
|
||||
EX:\ \fCDBUG_ENTER\ ("main");\fR
|
||||
.SP 1
|
||||
.LI DBUG_RETURN\
|
||||
Used at each exit point of a function containing a
|
||||
DBUG_ENTER
|
||||
macro
|
||||
at the entry point.
|
||||
The argument is the value to return.
|
||||
Functions which return no value (void) should use the
|
||||
DBUG_VOID_RETURN
|
||||
macro.
|
||||
It
|
||||
is an error to have a
|
||||
DBUG_RETURN
|
||||
or
|
||||
DBUG_VOID_RETURN
|
||||
macro in a function
|
||||
which has no matching
|
||||
DBUG_ENTER
|
||||
macro, and the compiler will complain
|
||||
if the macros are actually used (expanded).
|
||||
Used at each exit point of a function containing a DBUG_ENTER macro at
|
||||
the entry point. The argument is the value to return. Functions
|
||||
which return no value (void) should use the DBUG_VOID_RETURN macro.
|
||||
It is an error to have a DBUG_RETURN or DBUG_VOID_RETURN macro in a
|
||||
function which has no matching DBUG_ENTER macro, and the compiler will
|
||||
complain if the macros are actually used (expanded).
|
||||
.SP 1
|
||||
EX:\ \fCDBUG_RETURN\ (value);\fR
|
||||
.br
|
||||
@ -727,24 +701,20 @@ EX:\ \fCDBUG_VOID_RETURN;\fR
|
||||
Used to name the current process being executed.
|
||||
A typical argument for this macro is "argv[0]", though
|
||||
it will be perfectly happy with any other string.
|
||||
Im multi-threaded environment threads may have different names.
|
||||
.SP 1
|
||||
EX:\ \fCDBUG_PROCESS\ (argv[0]);\fR
|
||||
.SP 1
|
||||
.LI DBUG_PUSH\
|
||||
Sets a new debugger state by pushing the current
|
||||
.B dbug
|
||||
state onto an
|
||||
internal stack and setting up the new state using the debug control
|
||||
string passed as the macro argument.
|
||||
The most common usage is to set the state specified by a debug
|
||||
control string retrieved from the argument list.
|
||||
Note that the leading "-#" in a debug control string specified
|
||||
as a command line argument must
|
||||
.B not
|
||||
be passed as part of the macro argument.
|
||||
The proper usage is to pass a pointer to the first character
|
||||
.B after
|
||||
the "-#" string.
|
||||
state onto an internal stack and setting up the new state using the
|
||||
debug control string passed as the macro argument. The most common
|
||||
usage is to set the state specified by a debug control string
|
||||
retrieved from the argument list. If the control string is
|
||||
.I incremental,
|
||||
the new state is a copy of the old state, modified by the control
|
||||
string.
|
||||
.SP 1
|
||||
EX:\ \fCDBUG_PUSH\ (\&(argv[i][2]));\fR
|
||||
.br
|
||||
@ -755,32 +725,38 @@ EX:\ \fCDBUG_PUSH\ ("");\fR
|
||||
.LI DBUG_POP\
|
||||
Restores the previous debugger state by popping the state stack.
|
||||
Attempting to pop more states than pushed will be ignored and no
|
||||
warning will be given.
|
||||
The
|
||||
DBUG_POP
|
||||
macro has no arguments.
|
||||
warning will be given. The DBUG_POP macro has no arguments.
|
||||
.SP 1
|
||||
EX:\ \fCDBUG_POP\ ();\fR
|
||||
.SP 1
|
||||
.LI DBUG_SET\
|
||||
Modifies the current debugger state on top of the stack or pushes
|
||||
a new state if the current is set to the initial settings, using
|
||||
the debug control string passed as the macro argument. Unless
|
||||
.I incremental
|
||||
control string is used (see below), it's equivalent to a combination of
|
||||
DBUG_POP and DBUG_PUSH.
|
||||
.SP 1
|
||||
EX:\ \fCDBUG_SET\ ("d:t");\fR
|
||||
.br
|
||||
EX:\ \fCDBUG_SET\ ("+d,info");\fR
|
||||
.br
|
||||
EX:\ \fCDBUG_SET\ ("+t:-d");\fR
|
||||
.SP 1
|
||||
.LI DBUG_FILE\
|
||||
The
|
||||
DBUG_FILE
|
||||
macro is used to do explicit I/O on the debug output
|
||||
stream.
|
||||
It is used in the same manner as the symbols "stdout" and "stderr"
|
||||
in the standard I/O package.
|
||||
The DBUG_FILE macro is used to do explicit I/O on the debug output
|
||||
stream. It is used in the same manner as the symbols "stdout" and
|
||||
"stderr" in the standard I/O package.
|
||||
.SP 1
|
||||
EX:\ \fCfprintf\ (DBUG_FILE,\ "Doing\ my\ own\ I/O!\\n");\fR
|
||||
.SP 1
|
||||
.LI DBUG_EXECUTE\
|
||||
The DBUG_EXECUTE macro is used to execute any arbitrary C code.
|
||||
The first argument is the debug keyword, used to trigger execution
|
||||
of the code specified as the second argument.
|
||||
This macro must be used cautiously because, like the
|
||||
DBUG_PRINT
|
||||
macro,
|
||||
it is automatically selected by default whenever the 'd' flag has
|
||||
no argument list (i.e., a "-#d:t" control string).
|
||||
The DBUG_EXECUTE macro is used to execute any arbitrary C code. The
|
||||
first argument is the debug keyword, used to trigger execution of the
|
||||
code specified as the second argument. This macro must be used
|
||||
cautiously because, like the DBUG_PRINT macro, it is automatically
|
||||
selected by default whenever the 'd' flag has no argument list (i.e.,
|
||||
a "-#d:t" control string).
|
||||
.SP 1
|
||||
EX:\ \fCDBUG_EXECUTE\ ("status",\ print_status\ ());\fR
|
||||
.SP 1
|
||||
@ -794,17 +770,40 @@ artificial delay checking for race conditions.
|
||||
.SP 1
|
||||
EX:\ \fCDBUG_EXECUTE_IF\ ("crashme",\ abort\ ());\fR
|
||||
.SP 1
|
||||
.LI DBUG_N\
|
||||
These macros, where N is in the range 2-5, are currently obsolete
|
||||
and will be removed in a future release.
|
||||
Use the new DBUG_PRINT macro.
|
||||
.LI DBUG_EVALUATE\
|
||||
The DBUG_EVALUATE macro is similar to DBUG_EXECUTE, but it can be used in
|
||||
the expression context. The first argument is the debug keyword that is used to
|
||||
choose whether the second (keyword is enabled) or the third (keyword is not
|
||||
enabled) argument is evaluated. When
|
||||
.B dbug
|
||||
is compiled off, the third argument is evaluated.
|
||||
.SP 1
|
||||
EX:\fC
|
||||
.br
|
||||
printf("Info-debug is %s",
|
||||
.br
|
||||
DBUG_EVALUATE\ ("info", "ON", "OFF"));\fR
|
||||
.SP 1
|
||||
.LI DBUG_EVALUATE_IF\
|
||||
Works like DBUG_EVALUATE macro, but the second argument is
|
||||
.B not
|
||||
evaluated, if the keyword is not explicitly listed in
|
||||
the 'd' flag. Like DBUG_EXECUTE_IF this could be used to conditionally execute
|
||||
"dangerous" actions.
|
||||
.SP 1
|
||||
EX:\fC
|
||||
.br
|
||||
if (prepare_transaction () ||
|
||||
.br
|
||||
DBUG_EVALUATE ("crashme", (abort (), 0), 0) ||
|
||||
.br
|
||||
commit_transaction () )\fR
|
||||
.SP 1
|
||||
.LI DBUG_PRINT\
|
||||
Used to do printing via the "fprintf" library function on the
|
||||
current debug stream,
|
||||
DBUG_FILE.
|
||||
The first argument is a debug keyword, the second is a format string
|
||||
and the corresponding argument list.
|
||||
Note that the format string and argument list are all one macro argument
|
||||
Used to do printing via the "fprintf" library function on the current
|
||||
debug stream, DBUG_FILE. The first argument is a debug keyword, the
|
||||
second is a format string and the corresponding argument list. Note
|
||||
that the format string and argument list are all one macro argument
|
||||
and
|
||||
.B must
|
||||
be enclosed in parentheses.
|
||||
@ -816,10 +815,10 @@ EX:\ \fCDBUG_PRINT\ ("type",\ ("type\ is\ %x", type));\fR
|
||||
EX:\ \fCDBUG_PRINT\ ("stp",\ ("%x\ ->\ %s", stp, stp\ ->\ name));\fR
|
||||
.SP 1
|
||||
.LI DBUG_DUMP\
|
||||
Used to dump a memory block in hex via the "fprintf" library function on the
|
||||
current debug stream, DBUG_FILE.
|
||||
The first argument is a debug keyword, the second is a pointer to
|
||||
a memory to dump, the third is a number of bytes to dump.
|
||||
Used to dump a memory block in hex via the "fprintf" library function
|
||||
on the current debug stream, DBUG_FILE. The first argument is a debug
|
||||
keyword, the second is a pointer to a memory to dump, the third is a
|
||||
number of bytes to dump.
|
||||
.SP 1
|
||||
EX: \fCDBUG_DBUG\ ("net",\ packet,\ len);\fR
|
||||
.SP 1
|
||||
@ -875,13 +874,28 @@ library. So there will be no need to disable asserts separately with NDEBUG.
|
||||
.SP 1
|
||||
EX:\ \fCDBUG_ASSERT(\ a\ >\ 0\ );\fR
|
||||
.SP 1
|
||||
.LI DBUG_OUTPUT\
|
||||
In multi-threaded environment disables (or enables) any
|
||||
.I dbug
|
||||
output from the current thread.
|
||||
.LI DBUG_EXPLAIN\
|
||||
Generates control string corresponding to the current debug state.
|
||||
The macro takes two arguments - a buffer to store the result string
|
||||
into and its length. The macro (which could be used as a function)
|
||||
returns 1 if the control string didn't fit into the buffer and was
|
||||
truncated and 0 otherwise.
|
||||
.SP 1
|
||||
EX:\ \fCDBUG_OUTPUT(\ 0\ );\fR
|
||||
EX:\fC
|
||||
.br
|
||||
char buf[256];
|
||||
.br
|
||||
DBUG_EXPLAIN( buf, sizeof(buf) );\fR
|
||||
.SP 1
|
||||
.LI DBUG_SET_INITIAL\
|
||||
.LI DBUG_EXPLAIN_INITIAL\
|
||||
.br
|
||||
These two macros are identical to DBUG_SET and DBUG_EXPLAIN, but they
|
||||
operate on the debug state that any new thread starts from.
|
||||
Modifying
|
||||
.I initial
|
||||
value does not affect threads that are already running. Obviously,
|
||||
these macros are only useful in the multi-threaded environment.
|
||||
.LE
|
||||
|
||||
.SK
|
||||
@ -893,42 +907,51 @@ DEBUG CONTROL STRING
|
||||
The debug control string is used to set the state of the debugger
|
||||
via the
|
||||
.B DBUG_PUSH
|
||||
macro.
|
||||
This section summarizes the currently available debugger options
|
||||
and the flag characters which enable or disable them.
|
||||
Argument lists enclosed in '[' and ']' are optional.
|
||||
or
|
||||
.B DBUG_SET
|
||||
macros. Control string consists of colon separate flags. Colons
|
||||
that are part of ':\\', ':/', or '::' are not considered flag
|
||||
separators. A flag may take an argument or a list of arguments.
|
||||
If a control string starts from a '+' sign it works
|
||||
.I incrementally,
|
||||
that is, it can modify existing state without overriding it. In such a
|
||||
string every flag may be preceded by a '+' or '-' to enable or disable
|
||||
a corresponding option in the debugger state. This section summarizes
|
||||
the currently available debugger options and the flag characters which
|
||||
enable or disable them. Argument lists enclosed in '[' and ']' are
|
||||
optional.
|
||||
.SP 2
|
||||
.BL 22
|
||||
.LI a[,file]
|
||||
Redirect the debugger output stream and append it to the specified file.
|
||||
The default output stream is stderr.
|
||||
A null argument list causes output to be redirected to stdout.
|
||||
Double the colon, if you want it in the path
|
||||
Redirect the debugger output stream and append it to the specified
|
||||
file. The default output stream is stderr. A null argument list
|
||||
causes output to be redirected to stdout.
|
||||
.SP 1
|
||||
EX: \fCa,C::\\tmp\\log\fR
|
||||
EX: \fCa,C:\\tmp\\log\fR
|
||||
.LI A[,file]
|
||||
Like 'a[,file]' but ensure that data are written after each write
|
||||
(this typically implies flush or close/reopen). It helps to get
|
||||
a complete log file in case of crashes. This mode is implied in
|
||||
a complete log file in case of crashes. This mode is implicit in
|
||||
multi-threaded environment.
|
||||
.LI d[,keywords]
|
||||
Enable output from macros with specified keywords.
|
||||
A null list of keywords implies that all keywords are selected.
|
||||
An empty list of keywords implies that all keywords are selected.
|
||||
.LI D[,time]
|
||||
Delay for specified time after each output line, to let output drain.
|
||||
Time is given in tenths of a second (value of 10 is one second).
|
||||
Default is zero.
|
||||
.LI f[,functions]
|
||||
Limit debugger actions to the specified list of functions.
|
||||
A null list of functions implies that all functions are selected.
|
||||
An empty list of functions implies that all functions are selected.
|
||||
.LI F
|
||||
Mark each debugger output line with the name of the source file
|
||||
containing the macro causing the output.
|
||||
.LI i
|
||||
Mark each debugger output line with the PID of the current process.
|
||||
Mark each debugger output line with the PID (or thread ID) of the
|
||||
current process.
|
||||
.LI g,[functions]
|
||||
Enable profiling for the specified list of functions.
|
||||
By default profiling is enabled for all functions.
|
||||
An empty list of functions enables profiling for all functions.
|
||||
See
|
||||
.B PROFILING\ WITH\ DBUG
|
||||
below.
|
||||
@ -946,20 +969,18 @@ Like 'a[,file]' but overwrite old file, do not append.
|
||||
.LI O[,file]
|
||||
Like 'A[,file]' but overwrite old file, do not append.
|
||||
.LI p[,processes]
|
||||
Limit debugger actions to the specified processes.
|
||||
A null list implies all processes.
|
||||
This is useful for processes which run child processes.
|
||||
Note that each debugger output line can be marked with the name of
|
||||
the current process via the 'P' flag.
|
||||
The process name must match the argument passed to the
|
||||
Limit debugger actions to the specified processes. An empty list
|
||||
implies all processes. This is useful for processes which run child
|
||||
processes. Note that each debugger output line can be marked with the
|
||||
name of the current process via the 'P' flag. The process name must
|
||||
match the argument passed to the
|
||||
.B DBUG_PROCESS
|
||||
macro.
|
||||
.LI P
|
||||
Mark each debugger output line with the name of the current process.
|
||||
Most useful when used with a process which runs child processes that
|
||||
are also being debugged.
|
||||
Note that the parent process must arrange for the debugger control
|
||||
string to be passed to the child processes.
|
||||
are also being debugged. Note that the parent process must arrange
|
||||
for the debugger control string to be passed to the child processes.
|
||||
.LI r
|
||||
Used in conjunction with the
|
||||
.B DBUG_PUSH
|
||||
@ -981,7 +1002,59 @@ and
|
||||
Enable function control flow tracing.
|
||||
The maximum nesting depth is specified by N, and defaults to
|
||||
200.
|
||||
.LI T
|
||||
Mark each debugger output line with the current timestamp.
|
||||
The value is printed with microsecond resolution, as returned by
|
||||
.I gettimeofday()
|
||||
system call. The actual resolution is OS- and hardware-dependent.
|
||||
.LE
|
||||
|
||||
.SK
|
||||
.B
|
||||
MULTI-THREADED DEBUGGING
|
||||
.R
|
||||
|
||||
.P
|
||||
When
|
||||
.I dbug
|
||||
is used in a multi-threaded environment there are few differences from a single-threaded
|
||||
case to keep in mind. This section tries to summarize them.
|
||||
.SP 2
|
||||
.BL 5
|
||||
.LI
|
||||
Every thread has its own stack of debugger states.
|
||||
.B DBUG_PUSH
|
||||
and
|
||||
.B DBUG_POP
|
||||
affect only the thread that executed them.
|
||||
.LI
|
||||
At the bottom of the stack for all threads there is the common
|
||||
.I initial
|
||||
state. Changes to this state (for example, with
|
||||
.B DBUG_SET_INITIAL
|
||||
macro) affect all new threads and all running threads that didn't
|
||||
.B DBUG_PUSH
|
||||
yet.
|
||||
.LI
|
||||
Every thread can have its own name, that can be set with
|
||||
.B DBUG_PROCESS
|
||||
macro. Thus, "-#p,name1,name2" can be used to limit the output to specific threads.
|
||||
.LI
|
||||
When printing directly to
|
||||
.B DBUG_FILE
|
||||
it may be necessary to prevent other threads from writing something between two parts
|
||||
of logically indivisible output. It is done with
|
||||
.B DBUG_LOCK_FILE
|
||||
and
|
||||
.B DBUG_UNLOCK_FILE
|
||||
macors. See the appropriate section for examples.
|
||||
.LI
|
||||
"-#o,file" and "-#O,file" are treated as "-#a,file" and "-#A,file" respectively. That is
|
||||
all writes to a file are always followed by a flush.
|
||||
.LI
|
||||
"-#i" prints not a PID but a thread id in the form of "T@nnn"
|
||||
.LE
|
||||
|
||||
.SK
|
||||
.B
|
||||
PROFILING WITH DBUG
|
||||
|
@ -20,15 +20,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, size_t len);
|
||||
extern int _db_explain_init_(char *buf, size_t 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 ***);
|
||||
@ -37,68 +40,73 @@ extern void _db_return_(uint _line_,const char **_sfunc_,const char **_sfile_,
|
||||
extern void _db_pargs_(uint _line_,const char *keyword);
|
||||
extern void _db_doprnt_ _VARARGS((const char *format,...))
|
||||
ATTRIBUTE_FORMAT(printf, 1, 2);
|
||||
extern void _db_dump_(uint _line_,const char *keyword,const char *memory,
|
||||
uint length);
|
||||
extern void _db_output_(uint flag);
|
||||
extern void _db_dump_(uint _line_,const char *keyword,
|
||||
const unsigned char *memory, size_t length);
|
||||
extern void _db_end_(void);
|
||||
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_DUMP(keyword,a1,a2) _db_dump_(__LINE__,keyword,a1,a2)
|
||||
#define DBUG_END() _db_end_ ()
|
||||
#define DBUG_LOCK_FILE { _db_lock_file(); }
|
||||
#define DBUG_UNLOCK_FILE { _db_unlock_file(); }
|
||||
#define DBUG_OUTPUT(A) { _db_output_(A); }
|
||||
#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))
|
||||
#define IF_DBUG(A) A
|
||||
#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_END()
|
||||
#define DBUG_LOCK_FILE
|
||||
#define DBUG_UNLOCK_FILE
|
||||
#define DBUG_OUTPUT(A)
|
||||
#define DBUG_ASSERT(A) {}
|
||||
#define DBUG_LEAVE
|
||||
#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)
|
||||
#define DBUG_SETJMP(a1) setjmp(a1)
|
||||
#define DBUG_LONGJMP(a1) longjmp(a1)
|
||||
#define DBUG_DUMP(keyword,a1,a2)
|
||||
#define DBUG_END()
|
||||
#define DBUG_ASSERT(A)
|
||||
#define DBUG_LOCK_FILE
|
||||
#define DBUG_FILE (stderr)
|
||||
#define DBUG_UNLOCK_FILE
|
||||
#define DBUG_EXPLAIN(buf,len)
|
||||
#define DBUG_EXPLAIN_INITIAL(buf,len)
|
||||
#define IF_DBUG(A)
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
|
@ -298,16 +298,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-------------------------------------------------------");
|
||||
|
@ -196,7 +196,7 @@ 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*)
|
||||
my_n_base_info_read((uchar*) disk_cache + base_pos, &share->base);
|
||||
|
@ -1088,7 +1088,7 @@ bool ha_federated::create_where_from_key(String *to,
|
||||
uint store_length= key_part->store_length;
|
||||
uint part_length= min(store_length, length);
|
||||
needs_quotes= 1;
|
||||
DBUG_DUMP("key, start of loop", (char *) ptr, length);
|
||||
DBUG_DUMP("key, start of loop", ptr, length);
|
||||
|
||||
if (key_part->null_bit)
|
||||
{
|
||||
|
@ -4250,7 +4250,7 @@ ha_innobase::rnd_pos(
|
||||
int error;
|
||||
uint keynr = active_index;
|
||||
DBUG_ENTER("rnd_pos");
|
||||
DBUG_DUMP("key", (char*) pos, ref_length);
|
||||
DBUG_DUMP("key", pos, ref_length);
|
||||
|
||||
statistic_increment(current_thd->status_var.ha_read_rnd_count,
|
||||
&LOCK_status);
|
||||
|
@ -126,7 +126,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))
|
||||
|
@ -4130,7 +4130,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);
|
||||
}
|
||||
|
@ -1071,12 +1071,9 @@ 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 %ld",
|
||||
sig, my_thread_id());
|
||||
}
|
||||
if (global_system_variables.log_warnings)
|
||||
sql_print_warning("Got signal %d from thread %ld",
|
||||
sig, my_thread_id());
|
||||
#ifdef DONT_REMEMBER_SIGNAL
|
||||
my_sigset(sig,print_signal_warning); /* int. thread system calls */
|
||||
#endif
|
||||
@ -1718,7 +1715,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);
|
||||
@ -3623,8 +3620,6 @@ int main(int argc, char **argv)
|
||||
MY_INIT(argv[0]); // init my_sys library & pthreads
|
||||
/* ^^^ Nothing should be before this line! */
|
||||
|
||||
DEBUGGER_OFF;
|
||||
|
||||
/* Set signal used to kill MySQL */
|
||||
#if defined(SIGUSR2)
|
||||
thr_kill_signal= thd_lib_detected == THD_LIB_LT ? SIGINT : SIGUSR2;
|
||||
|
@ -394,7 +394,7 @@ my_net_write(NET *net,const char *packet,ulong len)
|
||||
if (net_write_buff(net,(char*) buff,NET_HEADER_SIZE))
|
||||
return 1;
|
||||
#ifndef DEBUG_DATA_PACKETS
|
||||
DBUG_DUMP("packet_header",(char*) buff,NET_HEADER_SIZE);
|
||||
DBUG_DUMP("packet_header", buff, NET_HEADER_SIZE);
|
||||
#endif
|
||||
return test(net_write_buff(net,packet,len));
|
||||
}
|
||||
@ -892,7 +892,7 @@ my_real_read(NET *net, ulong *complen)
|
||||
if (i == 0)
|
||||
{ /* First parts is packet length */
|
||||
ulong helping;
|
||||
DBUG_DUMP("packet_header",(char*) net->buff+net->where_b,
|
||||
DBUG_DUMP("packet_header", net->buff+net->where_b,
|
||||
NET_HEADER_SIZE);
|
||||
if (net->buff[net->where_b + 3] != (uchar) net->pkt_nr)
|
||||
{
|
||||
|
@ -9570,8 +9570,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);
|
||||
@ -9601,8 +9599,6 @@ static void print_ror_scans_arr(TABLE *table, const char *msg,
|
||||
struct st_ror_scan_info **end)
|
||||
{
|
||||
DBUG_ENTER("print_ror_scans");
|
||||
if (! _db_on_)
|
||||
DBUG_VOID_RETURN;
|
||||
|
||||
char buff[1024];
|
||||
String tmp(buff,sizeof(buff),&my_charset_bin);
|
||||
@ -9665,7 +9661,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;
|
||||
|
||||
|
@ -1990,7 +1990,7 @@ void sys_var_thd_date_time_format::update2(THD *thd, enum_var_type type,
|
||||
{
|
||||
DATE_TIME_FORMAT *old;
|
||||
DBUG_ENTER("sys_var_date_time_format::update2");
|
||||
DBUG_DUMP("positions",(char*) new_value->positions,
|
||||
DBUG_DUMP("positions", new_value->positions,
|
||||
sizeof(new_value->positions));
|
||||
|
||||
if (type == OPT_GLOBAL)
|
||||
|
@ -3339,7 +3339,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
|
||||
}
|
||||
|
||||
DBUG_PRINT("info", ("thd->options: %s",
|
||||
(thd->options & OPTION_BEGIN) ? "OPTION_BEGIN" : ""))
|
||||
(thd->options & OPTION_BEGIN) ? "OPTION_BEGIN" : ""));
|
||||
|
||||
/*
|
||||
Protect against common user error of setting the counter to 1
|
||||
|
@ -315,13 +315,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"));}
|
||||
|
@ -14470,7 +14470,7 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array,
|
||||
ifield->db_name= iref->db_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);
|
||||
|
@ -16673,7 +16673,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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user