24#ifndef MY_DBUG_INCLUDED
25#define MY_DBUG_INCLUDED
74extern void _db_push_(
const char *control);
76extern void _db_set_(
const char *control);
83extern void _db_pargs_(
unsigned int _line_,
const char *keyword);
86 MY_ATTRIBUTE((format(printf, 1, 2)));
87extern
void _db_dump_(
unsigned int _line_, const
char *keyword,
99#define DBUG_PRETTY_FUNCTION __PRETTY_FUNCTION__
100#elif defined(__FUNCSIG__)
103#define DBUG_PRETTY_FUNCTION strchr(__FUNCSIG__, ' ') + 1
106#define DBUG_PRETTY_FUNCTION __func__
122 const char *
begin = strchr(
function,
' ');
123 if (
begin !=
nullptr) {
124 function =
begin + 1;
129 const char *
end = strchr(
function,
'(');
131 if (
end ==
nullptr) {
147 const AutoDebugTrace _db_trace(DBUG_PRETTY_FUNCTION, __FILE__, __LINE__)
151#define DBUG_ENTER(a) \
152 struct _db_stack_frame_ _db_stack_frame_; \
153 _db_enter_(a, ::strlen(a), __FILE__, __LINE__, &_db_stack_frame_)
155#define DBUG_RETURN(a1) \
157 _db_return_(__LINE__, &_db_stack_frame_); \
160#define DBUG_VOID_RETURN \
162 _db_return_(__LINE__, &_db_stack_frame_); \
165#define DBUG_EXECUTE(keyword, a1) \
167 if (_db_keyword_(nullptr, (keyword), 0)) { \
171#define DBUG_EXECUTE_IF(keyword, a1) \
173 if (_db_keyword_(nullptr, (keyword), 1)) { \
177#define DBUG_EVALUATE(keyword, a1, a2) \
178 (_db_keyword_(nullptr, (keyword), 0) ? (a1) : (a2))
179#define DBUG_EVALUATE_IF(keyword, a1, a2) \
180 (_db_keyword_(nullptr, (keyword), 1) ? (a1) : (a2))
181#define DBUG_PRINT(keyword, arglist) \
183 _db_pargs_(__LINE__, keyword); \
184 if (_db_enabled_()) { \
185 _db_doprnt_ arglist; \
189#define DBUG_PUSH(a1) _db_push_(a1)
190#define DBUG_POP() _db_pop_()
191#define DBUG_SET(a1) _db_set_(a1)
192#define DBUG_SET_INITIAL(a1) _db_set_init_(a1)
193#define DBUG_PROCESS(a1) _db_process_(a1)
194#define DBUG_FILE _db_fp_()
195#define DBUG_DUMP(keyword, a1, a2) _db_dump_(__LINE__, keyword, a1, a2)
196#define DBUG_END() _db_end_()
197#define DBUG_LOCK_FILE _db_lock_file_()
198#define DBUG_UNLOCK_FILE _db_unlock_file_()
199#define DBUG_EXPLAIN(buf, len) _db_explain_(nullptr, (buf), (len))
200#define DBUG_EXPLAIN_INITIAL(buf, len) _db_explain_init_((buf), (len))
202#define DBUG_ABORT() (_db_flush_(), my_abort())
203#define DBUG_EXIT() (_db_flush_(), exit(2))
207#define DBUG_ABORT() \
208 (_db_flush_(), (void)_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE), \
209 (void)_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR), my_abort())
211 (_db_flush_(), (void)_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE), \
212 (void)_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR), _exit(2))
224#define DBUG_SUICIDE() DBUG_EXIT()
228#define DBUG_SUICIDE() (_db_flush_(), _db_suicide_())
238#define DBUG_ENTER(a1)
239#define DBUG_RETURN(a1) \
243#define DBUG_VOID_RETURN \
247#define DBUG_EXECUTE(keyword, a1) \
250#define DBUG_EXECUTE_IF(keyword, a1) \
253#define DBUG_EVALUATE(keyword, a1, a2) (a2)
254#define DBUG_EVALUATE_IF(keyword, a1, a2) (a2)
255#define DBUG_PRINT(keyword, arglist) \
258#define DBUG_PUSH(a1) \
261#define DBUG_SET(a1) \
264#define DBUG_SET_INITIAL(a1) \
270#define DBUG_PROCESS(a1) \
273#define DBUG_DUMP(keyword, a1, a2) \
279#define DBUG_LOCK_FILE \
282#define DBUG_FILE (stderr)
283#define DBUG_UNLOCK_FILE \
286#define DBUG_EXPLAIN(buf, len)
287#define DBUG_EXPLAIN_INITIAL(buf, len)
288#define DBUG_ABORT() \
291#define DBUG_SUICIDE() \
315#define DBUG_LOG(keyword, v) \
317 _db_pargs_(__LINE__, keyword); \
318 if (_db_enabled_()) { \
319 std::ostringstream sout; \
321 DBUG_PRINT(keyword, ("%s", sout.str().c_str())); \
336#define DBUG_VAR(v) #v << "=[" << (v) << "]"
339#define DBUG_LOG(keyword, v) \
342#define DBUG_VAR(v) ""
357template <
class DBGCLOS>
358inline void dbug(
const char *keyword [[maybe_unused]],
359 DBGCLOS &&clos [[maybe_unused]]) {
A RAII helper to do DBUG_ENTER / DBUG_RETURN for you automatically.
Definition: my_dbug.h:118
AutoDebugTrace(const char *function, const char *filename, int line)
Definition: my_dbug.h:120
~AutoDebugTrace()
Definition: my_dbug.h:140
_db_stack_frame_ m_stack_frame
Definition: my_dbug.h:143
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:1762
void _db_lock_file_(void)
Definition: dbug.cc:2177
void _db_return_(unsigned int _line_, struct _db_stack_frame_ *_stack_frame_)
void _db_flush_()
Definition: dbug.cc:2127
#define DBUG_EXECUTE_IF(keyword, a1)
Definition: my_dbug.h:171
void _db_unlock_file_(void)
Definition: dbug.cc:2184
void my_abort()
Calls our own implementation of abort, if specified, or std's abort().
Definition: my_init.cc:261
void _db_set_(const char *control)
Definition: dbug.cc:804
void _db_pop_(void)
Definition: dbug.cc:908
void _db_end_(void)
Definition: dbug.cc:1664
void _db_set_init_(const char *control)
Definition: dbug.cc:883
void _db_suicide_()
Definition: dbug.cc:2154
void _db_doprnt_(const char *format,...)
Definition: dbug.cc:1315
void _db_flush_gcov_()
Definition: dbug.cc:2145
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:1736
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:358
int _db_explain_init_(char *buf, size_t len)
Definition: dbug.cc:1082
void _db_push_(const char *control)
Definition: dbug.cc:840
int _db_explain_(struct CODE_STATE *cs, char *buf, size_t len)
Definition: dbug.cc:1022
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:270
int _db_enabled_()
Definition: dbug.cc:1279
int _db_is_pushed_(void)
Returns true if session-local settings have been set.
Definition: dbug.cc:862
Definition: buf0block_hint.cc:30
const std::string FILE("FILE")
Definition: commit_order_queue.h:34
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:76
Definition: aligned_atomic.h:44
const char * begin(const char *const c)
Definition: base64.h:44
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:192
const char * filename
Definition: pfs_example_component_population.cc:67
case opt name
Definition: sslopt-case.h:29
int func_len
Definition: dbug.cc:223
struct _db_stack_frame_ * prev
Definition: my_dbug.h:64
const char * func
Definition: my_dbug.h:60
int func_len
Definition: my_dbug.h:61
unsigned int level
Definition: my_dbug.h:63
const char * file
Definition: my_dbug.h:62