Commit 518caf1d authored by unknown's avatar unknown

dbug/dbug.c

    dbug naming conventions
dbug/user.r
    unification, documenting DBUG_ABORT()
include/my_dbug.h
    DBUG_ABORT()
sql/mysqld.cc
    remove redundant option (--enable-debug and --disable-debug should be
    used instead)


dbug/dbug.c:
  dbug naming conventions
dbug/user.r:
  unification, documenting DBUG_ABORT()
include/my_dbug.h:
  DBUG_ABORT()
sql/mysqld.cc:
  remove redundant option (--enable-debug and --disable-debug should be
  used instead)
parent c04dd359
...@@ -310,7 +310,7 @@ static void DoPrefix(CODE_STATE *cs, uint line); ...@@ -310,7 +310,7 @@ static void DoPrefix(CODE_STATE *cs, uint line);
static char *DbugMalloc(size_t size); static char *DbugMalloc(size_t size);
static const char *BaseName(const char *pathname); static const char *BaseName(const char *pathname);
static void Indent(CODE_STATE *cs, int indent); static void Indent(CODE_STATE *cs, int indent);
static void dbug_flush(CODE_STATE *); static void DbugFlush(CODE_STATE *);
static void DbugExit(const char *why); static void DbugExit(const char *why);
static const char *DbugStrTok(const char *s); static const char *DbugStrTok(const char *s);
...@@ -1164,7 +1164,7 @@ void _db_enter_(const char *_func_, const char *_file_, ...@@ -1164,7 +1164,7 @@ void _db_enter_(const char *_func_, const char *_file_,
DoPrefix(cs, _line_); DoPrefix(cs, _line_);
Indent(cs, cs->level); Indent(cs, cs->level);
(void) fprintf(cs->stack->out_file, ">%s\n", cs->func); (void) fprintf(cs->stack->out_file, ">%s\n", cs->func);
dbug_flush(cs); /* This does a unlock */ DbugFlush(cs); /* This does a unlock */
break; break;
case DISABLE_TRACE: case DISABLE_TRACE:
cs->framep->level&= ~TRACE_ON; cs->framep->level&= ~TRACE_ON;
...@@ -1214,7 +1214,7 @@ void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_) ...@@ -1214,7 +1214,7 @@ void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_)
pthread_mutex_lock(&THR_LOCK_dbug); pthread_mutex_lock(&THR_LOCK_dbug);
(void) fprintf(cs->stack->out_file, ERR_MISSING_RETURN, cs->process, (void) fprintf(cs->stack->out_file, ERR_MISSING_RETURN, cs->process,
cs->func); cs->func);
dbug_flush(cs); DbugFlush(cs);
} }
else else
{ {
...@@ -1236,7 +1236,7 @@ void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_) ...@@ -1236,7 +1236,7 @@ void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_)
DoPrefix(cs, _line_); DoPrefix(cs, _line_);
Indent(cs, cs->level); Indent(cs, cs->level);
(void) fprintf(cs->stack->out_file, "<%s\n", cs->func); (void) fprintf(cs->stack->out_file, "<%s\n", cs->func);
dbug_flush(cs); DbugFlush(cs);
} }
} }
/* /*
...@@ -1328,7 +1328,7 @@ void _db_doprnt_(const char *format,...) ...@@ -1328,7 +1328,7 @@ void _db_doprnt_(const char *format,...)
(void) fprintf(cs->stack->out_file, "%s: ", cs->u_keyword); (void) fprintf(cs->stack->out_file, "%s: ", cs->u_keyword);
(void) vfprintf(cs->stack->out_file, format, args); (void) vfprintf(cs->stack->out_file, format, args);
(void) fputc('\n',cs->stack->out_file); (void) fputc('\n',cs->stack->out_file);
dbug_flush(cs); DbugFlush(cs);
errno=save_errno; errno=save_errno;
} }
va_end(args); va_end(args);
...@@ -1393,7 +1393,7 @@ void _db_dump_(uint _line_, const char *keyword, ...@@ -1393,7 +1393,7 @@ void _db_dump_(uint _line_, const char *keyword,
fputc(' ',cs->stack->out_file); fputc(' ',cs->stack->out_file);
} }
(void) fputc('\n',cs->stack->out_file); (void) fputc('\n',cs->stack->out_file);
dbug_flush(cs); DbugFlush(cs);
} }
} }
...@@ -2089,7 +2089,7 @@ static void DBUGCloseFile(CODE_STATE *cs, FILE *fp) ...@@ -2089,7 +2089,7 @@ static void DBUGCloseFile(CODE_STATE *cs, FILE *fp)
pthread_mutex_lock(&THR_LOCK_dbug); pthread_mutex_lock(&THR_LOCK_dbug);
(void) fprintf(cs->stack->out_file, ERR_CLOSE, cs->process); (void) fprintf(cs->stack->out_file, ERR_CLOSE, cs->process);
perror(""); perror("");
dbug_flush(cs); DbugFlush(cs);
} }
} }
...@@ -2384,7 +2384,7 @@ char *s; ...@@ -2384,7 +2384,7 @@ char *s;
/* This is because some systems (MSDOS!!) dosn't flush fileheader */ /* This is because some systems (MSDOS!!) dosn't flush fileheader */
/* and dbug-file isn't readable after a system crash !! */ /* and dbug-file isn't readable after a system crash !! */
static void dbug_flush(CODE_STATE *cs) static void DbugFlush(CODE_STATE *cs)
{ {
if (cs->stack->flags & FLUSH_ON_WRITE) if (cs->stack->flags & FLUSH_ON_WRITE)
{ {
...@@ -2394,12 +2394,12 @@ static void dbug_flush(CODE_STATE *cs) ...@@ -2394,12 +2394,12 @@ static void dbug_flush(CODE_STATE *cs)
} }
if (!cs->locked) if (!cs->locked)
pthread_mutex_unlock(&THR_LOCK_dbug); pthread_mutex_unlock(&THR_LOCK_dbug);
} /* dbug_flush */ } /* DbugFlush */
/* For debugging */ /* For debugging */
void _db_force_flush_() void _db_flush_()
{ {
CODE_STATE *cs; CODE_STATE *cs;
get_code_state_or_return; get_code_state_or_return;
......
...@@ -511,7 +511,7 @@ possible since all code preceding the first call to ...@@ -511,7 +511,7 @@ possible since all code preceding the first call to
.B DBUG_PUSH .B DBUG_PUSH
is is
essentially invisible to essentially invisible to
.B dbug .I dbug
(this can be worked around by (this can be worked around by
inserting a temporary inserting a temporary
.B DBUG_PUSH(argv[1]) .B DBUG_PUSH(argv[1])
...@@ -707,7 +707,7 @@ EX:\ \fCDBUG_PROCESS\ (argv[0]);\fR ...@@ -707,7 +707,7 @@ EX:\ \fCDBUG_PROCESS\ (argv[0]);\fR
.SP 1 .SP 1
.LI DBUG_PUSH\ .LI DBUG_PUSH\
Sets a new debugger state by pushing the current Sets a new debugger state by pushing the current
.B dbug .I dbug
state onto an internal stack and setting up the new state using the state onto an internal stack and setting up the new state using the
debug control string passed as the macro argument. The most common debug control string passed as the macro argument. The most common
usage is to set the state specified by a debug control string usage is to set the state specified by a debug control string
...@@ -767,14 +767,14 @@ the 'd' flag. Used to conditionally execute "dangerous" actions, e.g ...@@ -767,14 +767,14 @@ the 'd' flag. Used to conditionally execute "dangerous" actions, e.g
to crash the program testing how recovery works, or to introduce an to crash the program testing how recovery works, or to introduce an
artificial delay checking for race conditions. artificial delay checking for race conditions.
.SP 1 .SP 1
EX:\ \fCDBUG_EXECUTE_IF\ ("crashme",\ abort\ ());\fR EX:\ \fCDBUG_EXECUTE_IF\ ("crashme",\ DBUG_ABORT()\ ());\fR
.SP 1 .SP 1
.LI DBUG_EVALUATE\ .LI DBUG_EVALUATE\
The DBUG_EVALUATE macro is similar to DBUG_EXECUTE, but it can be used in 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 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 choose whether the second (keyword is enabled) or the third (keyword is not
enabled) argument is evaluated. When enabled) argument is evaluated. When
.B dbug .I dbug
is compiled off, the third argument is evaluated. is compiled off, the third argument is evaluated.
.SP 1 .SP 1
EX:\fC EX:\fC
...@@ -794,7 +794,7 @@ EX:\fC ...@@ -794,7 +794,7 @@ EX:\fC
.br .br
if (prepare_transaction () || if (prepare_transaction () ||
.br .br
DBUG_EVALUATE ("crashme", (abort (), 0), 0) || DBUG_EVALUATE ("crashme", (DBUG_ABORT(), 0), 0) ||
.br .br
commit_transaction () )\fR commit_transaction () )\fR
.SP 1 .SP 1
...@@ -873,6 +873,12 @@ library. So there will be no need to disable asserts separately with NDEBUG. ...@@ -873,6 +873,12 @@ library. So there will be no need to disable asserts separately with NDEBUG.
.SP 1 .SP 1
EX:\ \fCDBUG_ASSERT(\ a\ >\ 0\ );\fR EX:\ \fCDBUG_ASSERT(\ a\ >\ 0\ );\fR
.SP 1 .SP 1
.LI DBUG_ABORT\
This macro could be used instead of abort(). It flushes DBUG_FILE stream
to ensure that no
.I dbug
output is lost and then calls abort().
.SP 1
.LI DBUG_EXPLAIN\ .LI DBUG_EXPLAIN\
Generates control string corresponding to the current debug state. Generates control string corresponding to the current debug state.
The macro takes two arguments - a buffer to store the result string The macro takes two arguments - a buffer to store the result string
......
...@@ -52,6 +52,7 @@ extern void _db_end_(void); ...@@ -52,6 +52,7 @@ extern void _db_end_(void);
extern void _db_lock_file_(void); extern void _db_lock_file_(void);
extern void _db_unlock_file_(void); extern void _db_unlock_file_(void);
extern FILE *_db_fp_(void); extern FILE *_db_fp_(void);
extern void _db_flush_();
#define DBUG_ENTER(a) struct _db_stack_frame_ _db_stack_frame_; \ #define DBUG_ENTER(a) struct _db_stack_frame_ _db_stack_frame_; \
_db_enter_ (a,__FILE__,__LINE__,&_db_stack_frame_) _db_enter_ (a,__FILE__,__LINE__,&_db_stack_frame_)
...@@ -86,7 +87,7 @@ extern FILE *_db_fp_(void); ...@@ -86,7 +87,7 @@ extern FILE *_db_fp_(void);
#define DEBUGGER_OFF do { _dbug_on_= 0; } while(0) #define DEBUGGER_OFF do { _dbug_on_= 0; } while(0)
#define DEBUGGER_ON do { _dbug_on_= 1; } while(0) #define DEBUGGER_ON do { _dbug_on_= 1; } while(0)
#define IF_DBUG(A) A #define IF_DBUG(A) A
#define DBUG_ABORT() ((void)fflush(DBUG_FILE), abort()) #define DBUG_ABORT() (_db_flush_(), abort())
#else /* No debugger */ #else /* No debugger */
#define DBUG_ENTER(a1) #define DBUG_ENTER(a1)
......
...@@ -5470,11 +5470,6 @@ struct my_option my_long_options[] = ...@@ -5470,11 +5470,6 @@ struct my_option my_long_options[] =
"Call my_debug_put_break_here() if crc matches this number (for debug).", "Call my_debug_put_break_here() if crc matches this number (for debug).",
(uchar**) &opt_my_crc_dbug_check, (uchar**) &opt_my_crc_dbug_check, (uchar**) &opt_my_crc_dbug_check, (uchar**) &opt_my_crc_dbug_check,
0, GET_ULONG, REQUIRED_ARG, 0, 0, ~(ulong) 0L, 0, 0, 0}, 0, GET_ULONG, REQUIRED_ARG, 0, 0, ~(ulong) 0L, 0, 0, 0},
{"debug-on", OPT_DEBUG_ON,
"Enable all DBUG commands. Needed if you want to use DBUG_EXECUTE without "
"starting mysqld with --debug",
(uchar**) &_dbug_on_, (uchar**) 0, 0, GET_BOOL, NO_ARG, 1,
0, 0, 0, 0, 0},
#endif #endif
{"default-character-set", 'C', "Set the default character set (deprecated option, use --character-set-server instead).", {"default-character-set", 'C', "Set the default character set (deprecated option, use --character-set-server instead).",
(uchar**) &default_character_set_name, (uchar**) &default_character_set_name, (uchar**) &default_character_set_name, (uchar**) &default_character_set_name,
......
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