23#ifndef MY_DBUG_INCLUDED
24#define MY_DBUG_INCLUDED
73extern void _db_push_(
const char *control);
75extern void _db_set_(
const char *control);
82extern void _db_pargs_(
unsigned int _line_,
const char *keyword);
85 MY_ATTRIBUTE((format(printf, 1, 2)));
86extern
void _db_dump_(
unsigned int _line_, const
char *keyword,
98#define DBUG_PRETTY_FUNCTION __PRETTY_FUNCTION__
99#elif defined(__FUNCSIG__)
102#define DBUG_PRETTY_FUNCTION strchr(__FUNCSIG__, ' ') + 1
105#define DBUG_PRETTY_FUNCTION __func__
121 const char *
begin = strchr(
function,
' ');
122 if (
begin !=
nullptr) {
123 function =
begin + 1;
128 const char *
end = strchr(
function,
'(');
130 if (
end ==
nullptr) {
146 const AutoDebugTrace _db_trace(DBUG_PRETTY_FUNCTION, __FILE__, __LINE__)
150#define DBUG_ENTER(a) \
151 struct _db_stack_frame_ _db_stack_frame_; \
152 _db_enter_(a, ::strlen(a), __FILE__, __LINE__, &_db_stack_frame_)
154#define DBUG_RETURN(a1) \
156 _db_return_(__LINE__, &_db_stack_frame_); \
159#define DBUG_VOID_RETURN \
161 _db_return_(__LINE__, &_db_stack_frame_); \
164#define DBUG_EXECUTE(keyword, a1) \
166 if (_db_keyword_(nullptr, (keyword), 0)) { \
170#define DBUG_EXECUTE_IF(keyword, a1) \
172 if (_db_keyword_(nullptr, (keyword), 1)) { \
176#define DBUG_EVALUATE(keyword, a1, a2) \
177 (_db_keyword_(nullptr, (keyword), 0) ? (a1) : (a2))
178#define DBUG_EVALUATE_IF(keyword, a1, a2) \
179 (_db_keyword_(nullptr, (keyword), 1) ? (a1) : (a2))
180#define DBUG_PRINT(keyword, arglist) \
182 _db_pargs_(__LINE__, keyword); \
183 if (_db_enabled_()) { \
184 _db_doprnt_ arglist; \
188#define DBUG_PUSH(a1) _db_push_(a1)
189#define DBUG_POP() _db_pop_()
190#define DBUG_SET(a1) _db_set_(a1)
191#define DBUG_SET_INITIAL(a1) _db_set_init_(a1)
192#define DBUG_PROCESS(a1) _db_process_(a1)
193#define DBUG_FILE _db_fp_()
194#define DBUG_DUMP(keyword, a1, a2) _db_dump_(__LINE__, keyword, a1, a2)
195#define DBUG_END() _db_end_()
196#define DBUG_LOCK_FILE _db_lock_file_()
197#define DBUG_UNLOCK_FILE _db_unlock_file_()
198#define DBUG_EXPLAIN(buf, len) _db_explain_(nullptr, (buf), (len))
199#define DBUG_EXPLAIN_INITIAL(buf, len) _db_explain_init_((buf), (len))
201#define DBUG_ABORT() (_db_flush_(), my_abort())
202#define DBUG_EXIT() (_db_flush_(), exit(2))
206#define DBUG_ABORT() \
207 (_db_flush_(), (void)_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE), \
208 (void)_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR), my_abort())
210 (_db_flush_(), (void)_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE), \
211 (void)_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR), _exit(2))
223#define DBUG_SUICIDE() DBUG_EXIT()
227#define DBUG_SUICIDE() (_db_flush_(), _db_suicide_())
237#define DBUG_ENTER(a1)
238#define DBUG_RETURN(a1) \
242#define DBUG_VOID_RETURN \
246#define DBUG_EXECUTE(keyword, a1) \
249#define DBUG_EXECUTE_IF(keyword, a1) \
252#define DBUG_EVALUATE(keyword, a1, a2) (a2)
253#define DBUG_EVALUATE_IF(keyword, a1, a2) (a2)
254#define DBUG_PRINT(keyword, arglist) \
257#define DBUG_PUSH(a1) \
260#define DBUG_SET(a1) \
263#define DBUG_SET_INITIAL(a1) \
269#define DBUG_PROCESS(a1) \
272#define DBUG_DUMP(keyword, a1, a2) \
278#define DBUG_LOCK_FILE \
281#define DBUG_FILE (stderr)
282#define DBUG_UNLOCK_FILE \
285#define DBUG_EXPLAIN(buf, len)
286#define DBUG_EXPLAIN_INITIAL(buf, len)
287#define DBUG_ABORT() \
290#define DBUG_SUICIDE() \
314#define DBUG_LOG(keyword, v) \
316 _db_pargs_(__LINE__, keyword); \
317 if (_db_enabled_()) { \
318 std::ostringstream sout; \
320 DBUG_PRINT(keyword, ("%s", sout.str().c_str())); \
335#define DBUG_VAR(v) #v << "=[" << (v) << "]"
338#define DBUG_LOG(keyword, v) \
341#define DBUG_VAR(v) ""
356template <
class DBGCLOS>
357inline void dbug(
const char *keyword [[maybe_unused]],
358 DBGCLOS &&clos [[maybe_unused]]) {
A RAII helper to do DBUG_ENTER / DBUG_RETURN for you automatically.
Definition: my_dbug.h:117
AutoDebugTrace(const char *function, const char *filename, int line)
Definition: my_dbug.h:119
~AutoDebugTrace()
Definition: my_dbug.h:139
_db_stack_frame_ m_stack_frame
Definition: my_dbug.h:142
Header for compiler-dependent features.
void _db_dump_(unsigned int _line_, const char *keyword, const unsigned char *memory, size_t length)
int _db_keyword_(struct CODE_STATE *, const char *, int)
Definition: dbug.cc:1761
void _db_lock_file_(void)
Definition: dbug.cc:2176
void _db_return_(unsigned int _line_, struct _db_stack_frame_ *_stack_frame_)
void _db_flush_()
Definition: dbug.cc:2126
#define DBUG_EXECUTE_IF(keyword, a1)
Definition: my_dbug.h:170
void _db_unlock_file_(void)
Definition: dbug.cc:2183
void my_abort()
Calls our own implementation of abort, if specified, or std's abort().
Definition: my_init.cc:260
void _db_set_(const char *control)
Definition: dbug.cc:803
void _db_pop_(void)
Definition: dbug.cc:907
void _db_end_(void)
Definition: dbug.cc:1663
void _db_set_init_(const char *control)
Definition: dbug.cc:882
void _db_suicide_()
Definition: dbug.cc:2153
void _db_doprnt_(const char *format,...)
Definition: dbug.cc:1314
void _db_flush_gcov_()
Definition: dbug.cc:2144
void _db_enter_(const char *_func_, int func_len, const char *_file_, unsigned int _line_, struct _db_stack_frame_ *_stack_frame_)
void _db_process_(const char *name)
Definition: dbug.cc:400
FILE * _db_fp_(void)
Definition: dbug.cc:1735
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 prov...
Definition: my_dbug.h:357
int _db_explain_init_(char *buf, size_t len)
Definition: dbug.cc:1081
void _db_push_(const char *control)
Definition: dbug.cc:839
int _db_explain_(struct CODE_STATE *cs, char *buf, size_t len)
Definition: dbug.cc:1021
void _db_pargs_(unsigned int _line_, const char *keyword)
void set_my_abort(void(*new_my_abort_func)())
Sets a new function to be called on my_abort().
Definition: my_init.cc:269
int _db_enabled_()
Definition: dbug.cc:1278
int _db_is_pushed_(void)
Returns true if session-local settings have been set.
Definition: dbug.cc:861
void * begin(THD *thd, const TABLE *table, size_t data_size, size_t memory, size_t num_threads) noexcept
Definition: bulk_data_service.cc:1533
Definition: buf0block_hint.cc:29
const std::string FILE("FILE")
Definition: commit_order_queue.h:33
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:75
Definition: aligned_atomic.h:43
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:191
const char * filename
Definition: pfs_example_component_population.cc:66
case opt name
Definition: sslopt-case.h:32
int func_len
Definition: dbug.cc:223
struct _db_stack_frame_ * prev
Definition: my_dbug.h:63
const char * func
Definition: my_dbug.h:59
int func_len
Definition: my_dbug.h:60
unsigned int level
Definition: my_dbug.h:62
const char * file
Definition: my_dbug.h:61