~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
/* Copyright (C) 2000 MySQL AB
2
3
   This program is free software; you can redistribute it and/or modify
4
   it under the terms of the GNU General Public License as published by
5
   the Free Software Foundation; version 2 of the License.
6
7
   This program is distributed in the hope that it will be useful,
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
   GNU General Public License for more details.
11
12
   You should have received a copy of the GNU General Public License
13
   along with this program; if not, write to the Free Software
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
16
#ifndef _dbug_h
17
#define _dbug_h
18
19
#ifdef	__cplusplus
20
extern "C" {
21
#endif
22
#if !defined(DBUG_OFF) && !defined(_lint)
23
struct _db_code_state_;
24
extern	int _db_keyword_(struct _db_code_state_ *cs, const char *keyword);
25
extern  int _db_strict_keyword_(const char *keyword);
26
extern  int _db_explain_(struct _db_code_state_ *cs, char *buf, size_t len);
27
extern  int _db_explain_init_(char *buf, size_t len);
28
extern	void _db_setjmp_(void);
29
extern	void _db_longjmp_(void);
30
extern  void _db_process_(const char *name);
31
extern	void _db_push_(const char *control);
32
extern	void _db_pop_(void);
33
extern  void _db_set_(struct _db_code_state_ *cs, const char *control);
34
extern  void _db_set_init_(const char *control);
35
extern	void _db_enter_(const char *_func_,const char *_file_,uint _line_,
36
			const char **_sfunc_,const char **_sfile_,
37
			uint *_slevel_, char ***);
38
extern	void _db_return_(uint _line_,const char **_sfunc_,const char **_sfile_,
39
			 uint *_slevel_);
40
extern	void _db_pargs_(uint _line_,const char *keyword);
41
extern	void _db_doprnt_ _VARARGS((const char *format,...))
42
  ATTRIBUTE_FORMAT(printf, 1, 2);
43
extern	void _db_dump_(uint _line_,const char *keyword,
44
                       const unsigned char *memory, size_t length);
45
extern	void _db_end_(void);
46
extern	void _db_lock_file_(void);
47
extern	void _db_unlock_file_(void);
48
extern FILE *_db_fp_(void);
49
50
#define DBUG_ENTER(a) const char *_db_func_, *_db_file_; uint _db_level_; \
51
	char **_db_framep_; \
52
	_db_enter_ (a,__FILE__,__LINE__,&_db_func_,&_db_file_,&_db_level_, \
53
		    &_db_framep_)
54
#define DBUG_LEAVE \
55
	_db_return_ (__LINE__, &_db_func_, &_db_file_, &_db_level_)
56
#define DBUG_RETURN(a1) do {DBUG_LEAVE; return(a1);} while(0)
57
#define DBUG_VOID_RETURN do {DBUG_LEAVE; return;} while(0)
58
#define DBUG_EXECUTE(keyword,a1) \
59
        do {if (_db_keyword_(0, (keyword))) { a1 }} while(0)
60
#define DBUG_EXECUTE_IF(keyword,a1) \
61
        do {if (_db_strict_keyword_ (keyword)) { a1 } } while(0)
62
#define DBUG_EVALUATE(keyword,a1,a2) \
63
        (_db_keyword_(0,(keyword)) ? (a1) : (a2))
64
#define DBUG_EVALUATE_IF(keyword,a1,a2) \
65
        (_db_strict_keyword_((keyword)) ? (a1) : (a2))
66
#define DBUG_PRINT(keyword,arglist) \
67
        do {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;} while(0)
68
#define DBUG_PUSH(a1) _db_push_ (a1)
69
#define DBUG_POP() _db_pop_ ()
70
#define DBUG_SET(a1) _db_set_ (0, (a1))
71
#define DBUG_SET_INITIAL(a1) _db_set_init_ (a1)
72
#define DBUG_PROCESS(a1) _db_process_(a1)
73
#define DBUG_FILE _db_fp_()
74
#define DBUG_SETJMP(a1) (_db_setjmp_ (), setjmp (a1))
75
#define DBUG_LONGJMP(a1,a2) (_db_longjmp_ (), longjmp (a1, a2))
76
#define DBUG_DUMP(keyword,a1,a2) _db_dump_(__LINE__,keyword,a1,a2)
77
#define DBUG_END()  _db_end_ ()
78
#define DBUG_LOCK_FILE _db_lock_file_()
79
#define DBUG_UNLOCK_FILE _db_unlock_file_()
80
#define DBUG_ASSERT(A) assert(A)
81
#define DBUG_EXPLAIN(buf,len) _db_explain_(0, (buf),(len))
82
#define DBUG_EXPLAIN_INITIAL(buf,len) _db_explain_init_((buf),(len))
83
#define IF_DBUG(A) A
84
#else						/* No debugger */
85
86
#define DBUG_ENTER(a1)
87
#define DBUG_LEAVE
88
#define DBUG_RETURN(a1)             do { return(a1); } while(0)
89
#define DBUG_VOID_RETURN            do { return; } while(0)
90
#define DBUG_EXECUTE(keyword,a1)    do { } while(0)
91
#define DBUG_EXECUTE_IF(keyword,a1) do { } while(0)
92
#define DBUG_EVALUATE(keyword,a1,a2) (a2)
93
#define DBUG_EVALUATE_IF(keyword,a1,a2) (a2)
94
#define DBUG_PRINT(keyword,arglist) do { } while(0)
95
#define DBUG_PUSH(a1)
96
#define DBUG_SET(a1)
97
#define DBUG_SET_INITIAL(a1)
98
#define DBUG_POP()
99
#define DBUG_PROCESS(a1)
100
#define DBUG_SETJMP(a1) setjmp(a1)
101
#define DBUG_LONGJMP(a1) longjmp(a1)
102
#define DBUG_DUMP(keyword,a1,a2)
103
#define DBUG_END()
104
#define DBUG_ASSERT(A)              do { } while(0)
105
#define DBUG_LOCK_FILE
106
#define DBUG_FILE (stderr)
107
#define DBUG_UNLOCK_FILE
108
#define DBUG_EXPLAIN(buf,len)
109
#define DBUG_EXPLAIN_INITIAL(buf,len)
110
#define IF_DBUG(A)
111
#endif
112
#ifdef	__cplusplus
113
}
114
#endif
115
#endif