MySQL 9.1.0
Source Code Documentation
my_dbug.h File Reference
#include <stdlib.h>
#include "my_compiler.h"
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <sstream>
#include <string>

Go to the source code of this file.

Classes

struct  _db_stack_frame_
 
class  AutoDebugTrace
 A RAII helper to do DBUG_ENTER / DBUG_RETURN for you automatically. More...
 

Macros

#define DBUG_PRETTY_FUNCTION   __func__
 
#define DBUG_TRACE    const AutoDebugTrace _db_trace(DBUG_PRETTY_FUNCTION, __FILE__, __LINE__)
 
#define DBUG_ENTER(a)
 
#define DBUG_RETURN(a1)
 
#define DBUG_VOID_RETURN
 
#define DBUG_EXECUTE(keyword, a1)
 
#define DBUG_EXECUTE_IF(keyword, a1)
 
#define DBUG_EVALUATE(keyword, a1, a2)    (_db_keyword_(nullptr, (keyword), 0) ? (a1) : (a2))
 
#define DBUG_EVALUATE_IF(keyword, a1, a2)    (_db_keyword_(nullptr, (keyword), 1) ? (a1) : (a2))
 
#define DBUG_PRINT(keyword, arglist)
 
#define DBUG_PUSH(a1)   _db_push_(a1)
 
#define DBUG_POP()   _db_pop_()
 
#define DBUG_SET(a1)   _db_set_(a1)
 
#define DBUG_SET_INITIAL(a1)   _db_set_init_(a1)
 
#define DBUG_PROCESS(a1)   _db_process_(a1)
 
#define DBUG_FILE   _db_fp_()
 
#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_EXPLAIN(buf, len)   _db_explain_(nullptr, (buf), (len))
 
#define DBUG_EXPLAIN_INITIAL(buf, len)   _db_explain_init_((buf), (len))
 
#define DBUG_ABORT()   (_db_flush_(), my_abort())
 
#define DBUG_EXIT()   (_db_flush_(), exit(2))
 
#define DBUG_SUICIDE()   (_db_flush_(), _db_suicide_())
 
#define DBUG_LOG(keyword, v)
 
#define DBUG_VAR(v)   #v << "=[" << (v) << "]"
 Shortcut for printing a variable name and its value in DBUG_LOG output. More...
 

Functions

void my_abort ()
 Calls our own implementation of abort, if specified, or std's abort(). More...
 
void set_my_abort (void(*new_my_abort_func)())
 Sets a new function to be called on my_abort(). More...
 
int _db_keyword_ (struct CODE_STATE *, const char *, int)
 
int _db_explain_ (struct CODE_STATE *cs, char *buf, size_t len)
 
int _db_explain_init_ (char *buf, size_t len)
 
int _db_is_pushed_ (void)
 Returns true if session-local settings have been set. More...
 
void _db_process_ (const char *name)
 
void _db_push_ (const char *control)
 
void _db_pop_ (void)
 
void _db_set_ (const char *control)
 
void _db_set_init_ (const char *control)
 
void _db_enter_ (const char *_func_, int func_len, const char *_file_, unsigned int _line_, struct _db_stack_frame_ *_stack_frame_)
 
void _db_return_ (unsigned int _line_, struct _db_stack_frame_ *_stack_frame_)
 
void _db_pargs_ (unsigned int _line_, const char *keyword)
 
int _db_enabled_ ()
 
void _db_doprnt_ (const char *format,...)
 
void _db_dump_ (unsigned int _line_, const char *keyword, const unsigned char *memory, size_t length)
 
void _db_end_ (void)
 
void _db_lock_file_ (void)
 
void _db_unlock_file_ (void)
 
FILE * _db_fp_ (void)
 
void _db_flush_ ()
 
void _db_suicide_ ()
 
void _db_flush_gcov_ ()
 
template<class DBGCLOS >
void dbug (const char *keyword, DBGCLOS &&clos)
 A type-safe interface to DBUG_EXECUTE_IF, where the debug action to activate when the keyword is provided is given as a callable object (typically a lambda). More...
 

Macro Definition Documentation

◆ DBUG_ABORT

#define DBUG_ABORT ( )    (_db_flush_(), my_abort())

◆ DBUG_DUMP

#define DBUG_DUMP (   keyword,
  a1,
  a2 
)    _db_dump_(__LINE__, keyword, a1, a2)

◆ DBUG_END

#define DBUG_END ( )    _db_end_()

◆ DBUG_ENTER

#define DBUG_ENTER (   a)
Value:
_db_enter_(a, ::strlen(a), __FILE__, __LINE__, &_db_stack_frame_)
Definition: my_dbug.h:59

◆ DBUG_EVALUATE

#define DBUG_EVALUATE (   keyword,
  a1,
  a2 
)     (_db_keyword_(nullptr, (keyword), 0) ? (a1) : (a2))

◆ DBUG_EVALUATE_IF

#define DBUG_EVALUATE_IF (   keyword,
  a1,
  a2 
)     (_db_keyword_(nullptr, (keyword), 1) ? (a1) : (a2))

◆ DBUG_EXECUTE

#define DBUG_EXECUTE (   keyword,
  a1 
)
Value:
do { \
if (_db_keyword_(nullptr, (keyword), 0)) { \
a1 \
} \
} while (0)
int _db_keyword_(struct CODE_STATE *, const char *, int)
Definition: dbug.cc:1762

◆ DBUG_EXECUTE_IF

#define DBUG_EXECUTE_IF (   keyword,
  a1 
)
Value:
do { \
if (_db_keyword_(nullptr, (keyword), 1)) { \
a1 \
} \
} while (0)

◆ DBUG_EXIT

#define DBUG_EXIT ( )    (_db_flush_(), exit(2))

◆ DBUG_EXPLAIN

#define DBUG_EXPLAIN (   buf,
  len 
)    _db_explain_(nullptr, (buf), (len))

◆ DBUG_EXPLAIN_INITIAL

#define DBUG_EXPLAIN_INITIAL (   buf,
  len 
)    _db_explain_init_((buf), (len))

◆ DBUG_FILE

#define DBUG_FILE   _db_fp_()

◆ DBUG_LOCK_FILE

#define DBUG_LOCK_FILE   _db_lock_file_()

◆ DBUG_LOG

#define DBUG_LOG (   keyword,
 
)
Value:
do { \
_db_pargs_(__LINE__, keyword); \
if (_db_enabled_()) { \
sout << v; \
DBUG_PRINT(keyword, ("%s", sout.str().c_str())); \
} \
} while (0)
int _db_enabled_()
Definition: dbug.cc:1279
std::basic_ostringstream< char, std::char_traits< char >, ut::allocator< char > > ostringstream
Specialization of basic_ostringstream which uses ut::allocator.
Definition: ut0new.h:2872

◆ DBUG_POP

#define DBUG_POP ( )    _db_pop_()

◆ DBUG_PRETTY_FUNCTION

#define DBUG_PRETTY_FUNCTION   __func__

◆ DBUG_PRINT

#define DBUG_PRINT (   keyword,
  arglist 
)
Value:
do { \
_db_pargs_(__LINE__, keyword); \
if (_db_enabled_()) { \
_db_doprnt_ arglist; \
} \
} while (0)

◆ DBUG_PROCESS

#define DBUG_PROCESS (   a1)    _db_process_(a1)

◆ DBUG_PUSH

#define DBUG_PUSH (   a1)    _db_push_(a1)

◆ DBUG_RETURN

#define DBUG_RETURN (   a1)
Value:
do { \
_db_return_(__LINE__, &_db_stack_frame_); \
return (a1); \
} while (0)

◆ DBUG_SET

#define DBUG_SET (   a1)    _db_set_(a1)

◆ DBUG_SET_INITIAL

#define DBUG_SET_INITIAL (   a1)    _db_set_init_(a1)

◆ DBUG_SUICIDE

#define DBUG_SUICIDE ( )    (_db_flush_(), _db_suicide_())

◆ DBUG_TRACE

#define DBUG_TRACE    const AutoDebugTrace _db_trace(DBUG_PRETTY_FUNCTION, __FILE__, __LINE__)

◆ DBUG_UNLOCK_FILE

#define DBUG_UNLOCK_FILE   _db_unlock_file_()

◆ DBUG_VAR

#define DBUG_VAR (   v)    #v << "=[" << (v) << "]"

Shortcut for printing a variable name and its value in DBUG_LOG output.

Use like:

DBUG_LOG("info", DBUG_VAR(i) << " " << DBUG_VAR(thd->query));

Example output for the above might be:

i=[4711] thd->query=[INSERT INTO t VALUES (1)]

◆ DBUG_VOID_RETURN

#define DBUG_VOID_RETURN
Value:
do { \
_db_return_(__LINE__, &_db_stack_frame_); \
return; \
} while (0)

Function Documentation

◆ _db_doprnt_()

void _db_doprnt_ ( const char *  format,
  ... 
)

◆ _db_dump_()

void _db_dump_ ( unsigned int  _line_,
const char *  keyword,
const unsigned char *  memory,
size_t  length 
)

◆ _db_enabled_()

int _db_enabled_ ( )

◆ _db_end_()

void _db_end_ ( void  )

◆ _db_enter_()

void _db_enter_ ( const char *  _func_,
int  func_len,
const char *  _file_,
unsigned int  _line_,
struct _db_stack_frame_ _stack_frame_ 
)

◆ _db_explain_()

int _db_explain_ ( struct CODE_STATE cs,
char *  buf,
size_t  len 
)

◆ _db_explain_init_()

int _db_explain_init_ ( char *  buf,
size_t  len 
)

◆ _db_flush_()

void _db_flush_ ( )

◆ _db_flush_gcov_()

void _db_flush_gcov_ ( )

◆ _db_fp_()

FILE * _db_fp_ ( void  )

◆ _db_is_pushed_()

int _db_is_pushed_ ( void  )

Returns true if session-local settings have been set.

◆ _db_keyword_()

int _db_keyword_ ( struct CODE_STATE cs,
const char *  keyword,
int  strict 
)

◆ _db_lock_file_()

void _db_lock_file_ ( void  )

◆ _db_pargs_()

void _db_pargs_ ( unsigned int  _line_,
const char *  keyword 
)

◆ _db_pop_()

void _db_pop_ ( void  )

◆ _db_process_()

void _db_process_ ( const char *  name)

◆ _db_push_()

void _db_push_ ( const char *  control)

◆ _db_return_()

void _db_return_ ( unsigned int  _line_,
struct _db_stack_frame_ _stack_frame_ 
)

◆ _db_set_()

void _db_set_ ( const char *  control)

◆ _db_set_init_()

void _db_set_init_ ( const char *  control)

◆ _db_suicide_()

void _db_suicide_ ( )

◆ _db_unlock_file_()

void _db_unlock_file_ ( void  )

◆ dbug()

template<class DBGCLOS >
void dbug ( const char *  keyword,
DBGCLOS &&  clos 
)
inline

A type-safe interface to DBUG_EXECUTE_IF, where the debug action to activate when the keyword is provided is given as a callable object (typically a lambda).

Note
The body of the callable will be checked by the compiler even in optimized mode.
Parameters
keywordString literal which will enable this debug action.
closCallable object taking no arguments which will be called in debug mode if the keyword is enabled.

◆ my_abort()

void my_abort ( )

Calls our own implementation of abort, if specified, or std's abort().

◆ set_my_abort()

void set_my_abort ( void(*)()  new_my_abort_func)

Sets a new function to be called on my_abort().

Parameters
new_my_abort_funcpointer to a new my_abort function. It can't be [[noreturn]] as pointers to methods can't have attributes.