16 #ifndef MY_DBUG_INCLUDED
17 #define MY_DBUG_INCLUDED
20 #ifdef HAVE_SYS_TYPES_H
21 #include <sys/types.h>
32 #if !defined(DBUG_OFF) && !defined(_lint)
42 extern MYSQL_PLUGIN_IMPORT my_bool _dbug_on_;
43 extern my_bool _db_keyword_(
struct _db_code_state_ *,
const char *,
int);
45 extern int _db_explain_init_(
char *
buf,
size_t len);
46 extern int _db_is_pushed_(
void);
47 extern void _db_setjmp_(
void);
48 extern void _db_longjmp_(
void);
49 extern void _db_process_(
const char *
name);
50 extern void _db_push_(
const char *control);
51 extern void _db_pop_(
void);
52 extern void _db_set_(
const char *control);
53 extern void _db_set_init_(
const char *control);
54 extern void _db_enter_(
const char *_func_,
const char *_file_, uint _line_,
56 extern void _db_return_(uint _line_,
struct _db_stack_frame_ *_stack_frame_);
57 extern void _db_pargs_(uint _line_,
const char *keyword);
58 extern int _db_enabled_();
59 extern void _db_doprnt_(
const char *format,...)
60 ATTRIBUTE_FORMAT(printf, 1, 2);
61 extern
void _db_dump_(uint _line_,const
char *keyword,
62 const
unsigned char *memory,
size_t length);
63 extern
void _db_end_(
void);
64 extern
void _db_lock_file_(
void);
65 extern
void _db_unlock_file_(
void);
66 extern FILE *_db_fp_(
void);
67 extern
void _db_flush_();
68 extern const
char* _db_get_func_(
void);
70 #define DBUG_ENTER(a) struct _db_stack_frame_ _db_stack_frame_; \
71 _db_enter_ (a,__FILE__,__LINE__,&_db_stack_frame_)
72 #define DBUG_LEAVE _db_return_ (__LINE__, &_db_stack_frame_)
73 #define DBUG_RETURN(a1) do {DBUG_LEAVE; return(a1);} while(0)
74 #define DBUG_VOID_RETURN do {DBUG_LEAVE; return;} while(0)
75 #define DBUG_EXECUTE(keyword,a1) \
76 do {if (_db_keyword_(0, (keyword), 0)) { a1 }} while(0)
77 #define DBUG_EXECUTE_IF(keyword,a1) \
78 do {if (_db_keyword_(0, (keyword), 1)) { a1 }} while(0)
79 #define DBUG_EVALUATE(keyword,a1,a2) \
80 (_db_keyword_(0,(keyword), 0) ? (a1) : (a2))
81 #define DBUG_EVALUATE_IF(keyword,a1,a2) \
82 (_db_keyword_(0,(keyword), 1) ? (a1) : (a2))
83 #define DBUG_PRINT(keyword,arglist) \
88 _db_pargs_(__LINE__,keyword); \
91 _db_doprnt_ arglist; \
95 #define DBUG_PUSH(a1) _db_push_ (a1)
96 #define DBUG_POP() _db_pop_ ()
97 #define DBUG_SET(a1) _db_set_ (a1)
98 #define DBUG_SET_INITIAL(a1) _db_set_init_ (a1)
99 #define DBUG_PROCESS(a1) _db_process_(a1)
100 #define DBUG_FILE _db_fp_()
101 #define DBUG_SETJMP(a1) (_db_setjmp_ (), setjmp (a1))
102 #define DBUG_LONGJMP(a1,a2) (_db_longjmp_ (), longjmp (a1, a2))
103 #define DBUG_DUMP(keyword,a1,a2) _db_dump_(__LINE__,keyword,a1,a2)
104 #define DBUG_END() _db_end_ ()
105 #define DBUG_LOCK_FILE _db_lock_file_()
106 #define DBUG_UNLOCK_FILE _db_unlock_file_()
107 #define DBUG_ASSERT(A) assert(A)
108 #define DBUG_EXPLAIN(buf,len) _db_explain_(0, (buf),(len))
109 #define DBUG_EXPLAIN_INITIAL(buf,len) _db_explain_init_((buf),(len))
110 #define DEBUGGER_OFF do { _dbug_on_= 0; } while(0)
111 #define DEBUGGER_ON do { _dbug_on_= 1; } while(0)
113 #define DBUG_ABORT() (_db_flush_(), abort())
120 #define DBUG_ABORT() (_db_flush_(),\
121 (void)_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE),\
122 (void)_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR),\
125 #define DBUG_CHECK_CRASH(func, op) \
126 do { char _dbuf_[255]; strxnmov(_dbuf_, sizeof(_dbuf_)-1, (func), (op)); \
127 DBUG_EXECUTE_IF(_dbuf_, DBUG_ABORT()); } while(0)
128 #define DBUG_CRASH_ENTER(func) \
129 DBUG_ENTER(func); DBUG_CHECK_CRASH(func, "_crash_enter")
130 #define DBUG_CRASH_RETURN(val) \
131 DBUG_CHECK_CRASH(_db_get_func_(), "_crash_return")
132 #define DBUG_CRASH_VOID_RETURN \
133 DBUG_CHECK_CRASH (_db_get_func_(), "_crash_return")
144 #define DBUG_SUICIDE() DBUG_ABORT()
146 extern void _db_suicide_();
147 extern void _db_flush_gcov_();
148 #define DBUG_SUICIDE() (_db_flush_(), _db_suicide_())
153 #define DBUG_ENTER(a1)
155 #define DBUG_RETURN(a1) do { return(a1); } while(0)
156 #define DBUG_VOID_RETURN do { return; } while(0)
157 #define DBUG_EXECUTE(keyword,a1) do { } while(0)
158 #define DBUG_EXECUTE_IF(keyword,a1) do { } while(0)
159 #define DBUG_EVALUATE(keyword,a1,a2) (a2)
160 #define DBUG_EVALUATE_IF(keyword,a1,a2) (a2)
161 #define DBUG_PRINT(keyword,arglist) do { } while(0)
162 #define DBUG_PUSH(a1) do { } while(0)
163 #define DBUG_SET(a1) do { } while(0)
164 #define DBUG_SET_INITIAL(a1) do { } while(0)
165 #define DBUG_POP() do { } while(0)
166 #define DBUG_PROCESS(a1) do { } while(0)
167 #define DBUG_SETJMP(a1) setjmp(a1)
168 #define DBUG_LONGJMP(a1) longjmp(a1)
169 #define DBUG_DUMP(keyword,a1,a2) do { } while(0)
170 #define DBUG_END() do { } while(0)
171 #define DBUG_ASSERT(A) do { } while(0)
172 #define DBUG_LOCK_FILE do { } while(0)
173 #define DBUG_FILE (stderr)
174 #define DBUG_UNLOCK_FILE do { } while(0)
175 #define DBUG_EXPLAIN(buf,len)
176 #define DBUG_EXPLAIN_INITIAL(buf,len)
177 #define DEBUGGER_OFF do { } while(0)
178 #define DEBUGGER_ON do { } while(0)
179 #define DBUG_ABORT() do { } while(0)
180 #define DBUG_CRASH_ENTER(func)
181 #define DBUG_CRASH_RETURN(val) do { return(val); } while(0)
182 #define DBUG_CRASH_VOID_RETURN do { return; } while(0)
183 #define DBUG_SUICIDE() do { } while(0)
195 #define DBUG_SYNC_POINT(lock_name,lock_timeout) \
196 debug_sync_point(lock_name,lock_timeout)
197 void debug_sync_point(
const char* lock_name, uint lock_timeout);
199 #define DBUG_SYNC_POINT(lock_name,lock_timeout)