~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/ut0dbg.h

Merged InnoDB Plugin 1.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
*****************************************************************************/
18
18
 
19
 
/*********************************************************************
 
19
/*****************************************************************//**
 
20
@file include/ut0dbg.h
20
21
Debug utilities for Innobase
21
22
 
22
23
Created 1/30/1994 Heikki Tuuri
30
31
#include "os0thread.h"
31
32
 
32
33
#if defined(__GNUC__) && (__GNUC__ > 2)
 
34
/** Test if an assertion fails.
 
35
@param EXPR     assertion expression
 
36
@return         nonzero if EXPR holds, zero if not */
33
37
# define UT_DBG_FAIL(EXPR) UNIV_UNLIKELY(!((ulint)(EXPR)))
34
38
#else
35
 
extern ulint    ut_dbg_zero; /* This is used to eliminate
36
 
                                compiler warnings */
 
39
/** This is used to eliminate compiler warnings */
 
40
extern ulint    ut_dbg_zero;
 
41
/** Test if an assertion fails.
 
42
@param EXPR     assertion expression
 
43
@return         nonzero if EXPR holds, zero if not */
37
44
# define UT_DBG_FAIL(EXPR) !((ulint)(EXPR) + ut_dbg_zero)
38
45
#endif
39
46
 
40
 
/*****************************************************************
 
47
/*************************************************************//**
41
48
Report a failed assertion. */
42
49
UNIV_INTERN
43
50
void
44
51
ut_dbg_assertion_failed(
45
52
/*====================*/
46
 
        const char* expr,       /* in: the failed assertion */
47
 
        const char* file,       /* in: source file containing the assertion */
48
 
        ulint line);            /* in: line number of the assertion */
 
53
        const char* expr,       /*!< in: the failed assertion */
 
54
        const char* file,       /*!< in: source file containing the assertion */
 
55
        ulint line);            /*!< in: line number of the assertion */
49
56
 
50
57
#ifdef __NETWARE__
51
 
/* Flag for ignoring further assertion failures.
52
 
On NetWare, have a graceful exit rather than a segfault to avoid abends. */
 
58
/** Flag for ignoring further assertion failures.  This is set to TRUE
 
59
when on NetWare there happens an InnoDB assertion failure or other
 
60
fatal error condition that requires an immediate shutdown. */
53
61
extern ibool    panic_shutdown;
54
62
/* Abort the execution. */
55
63
void ut_dbg_panic(void);
64
72
# endif
65
73
 
66
74
# ifndef UT_DBG_USE_ABORT
67
 
/* A null pointer that will be dereferenced to trigger a memory trap */
 
75
/** A null pointer that will be dereferenced to trigger a memory trap */
68
76
extern ulint*   ut_dbg_null_ptr;
69
77
# endif
70
78
 
71
79
# if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT)
72
 
/* Flag for indicating that all threads should stop.  This will be set
73
 
by ut_dbg_assertion_failed(). */
 
80
/** If this is set to TRUE by ut_dbg_assertion_failed(), all threads
 
81
will stop at the next ut_a() or ut_ad(). */
74
82
extern ibool    ut_dbg_stop_threads;
75
83
 
76
 
/*****************************************************************
 
84
/*************************************************************//**
77
85
Stop a thread after assertion failure. */
78
86
UNIV_INTERN
79
87
void
84
92
# endif
85
93
 
86
94
# ifdef UT_DBG_USE_ABORT
87
 
/* Abort the execution. */
 
95
/** Abort the execution. */
88
96
#  define UT_DBG_PANIC abort()
89
 
/* Stop threads (null operation) */
 
97
/** Stop threads (null operation) */
90
98
#  define UT_DBG_STOP do {} while (0)
91
99
# else /* UT_DBG_USE_ABORT */
92
 
/* Abort the execution. */
 
100
/** Abort the execution. */
93
101
#  define UT_DBG_PANIC                                  \
94
102
        if (*(ut_dbg_null_ptr)) ut_dbg_null_ptr = NULL
95
 
/* Stop threads in ut_a(). */
 
103
/** Stop threads in ut_a(). */
96
104
#  define UT_DBG_STOP do                                                \
97
105
        if (UNIV_UNLIKELY(ut_dbg_stop_threads)) {               \
98
106
                ut_dbg_stop_thread(__FILE__, (ulint) __LINE__); \
100
108
# endif /* UT_DBG_USE_ABORT */
101
109
#endif /* __NETWARE__ */
102
110
 
103
 
/* Abort execution if EXPR does not evaluate to nonzero. */
 
111
/** Abort execution if EXPR does not evaluate to nonzero.
 
112
@param EXPR     assertion expression that should hold */
104
113
#define ut_a(EXPR) do {                                         \
105
114
        if (UT_DBG_FAIL(EXPR)) {                                \
106
115
                ut_dbg_assertion_failed(#EXPR,                  \
110
119
        UT_DBG_STOP;                                            \
111
120
} while (0)
112
121
 
113
 
/* Abort execution. */
 
122
/** Abort execution. */
114
123
#define ut_error do {                                           \
115
124
        ut_dbg_assertion_failed(0, __FILE__, (ulint) __LINE__); \
116
125
        UT_DBG_PANIC;                                           \
117
126
} while (0)
118
127
 
119
128
#ifdef UNIV_DEBUG
 
129
/** Debug assertion. Does nothing unless UNIV_DEBUG is defined. */
120
130
#define ut_ad(EXPR)     ut_a(EXPR)
 
131
/** Debug statement. Does nothing unless UNIV_DEBUG is defined. */
121
132
#define ut_d(EXPR)      do {EXPR;} while (0)
122
133
#else
 
134
/** Debug assertion. Does nothing unless UNIV_DEBUG is defined. */
123
135
#define ut_ad(EXPR)
 
136
/** Debug statement. Does nothing unless UNIV_DEBUG is defined. */
124
137
#define ut_d(EXPR)
125
138
#endif
126
139
 
 
140
/** Silence warnings about an unused variable by doing a null assignment.
 
141
@param A        the unused variable */
127
142
#define UT_NOT_USED(A)  A = A
128
143
 
129
144
#ifdef UNIV_COMPILE_TEST_FUNCS
132
147
#include <sys/time.h>
133
148
#include <sys/resource.h>
134
149
 
135
 
/* structure used for recording usage statistics */
 
150
/** structure used for recording usage statistics */
136
151
typedef struct speedo_struct {
137
 
        struct rusage   ru;
138
 
        struct timeval  tv;
 
152
        struct rusage   ru;     /*!< getrusage() result */
 
153
        struct timeval  tv;     /*!< gettimeofday() result */
139
154
} speedo_t;
140
155
 
141
 
/***********************************************************************
 
156
/*******************************************************************//**
142
157
Resets a speedo (records the current time in it). */
143
158
UNIV_INTERN
144
159
void
145
160
speedo_reset(
146
161
/*=========*/
147
 
        speedo_t*       speedo);        /* out: speedo */
 
162
        speedo_t*       speedo);        /*!< out: speedo */
148
163
 
149
 
/***********************************************************************
 
164
/*******************************************************************//**
150
165
Shows the time elapsed and usage statistics since the last reset of a
151
166
speedo. */
152
167
UNIV_INTERN
153
168
void
154
169
speedo_show(
155
170
/*========*/
156
 
        const speedo_t* speedo);        /* in: speedo */
 
171
        const speedo_t* speedo);        /*!< in: speedo */
157
172
 
158
173
#endif /* UNIV_COMPILE_TEST_FUNCS */
159
174