Drizzled Public API Documentation

ut0dbg.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (C) 1994, 2009, Innobase Oy. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free Software
7 Foundation; version 2 of the License.
8 
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License along with
14 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15 St, Fifth Floor, Boston, MA 02110-1301 USA
16 
17 *****************************************************************************/
18 
19 /*****************************************************************/
26 #pragma once
27 #ifndef ut0dbg_h
28 #define ut0dbg_h
29 
30 #include "univ.i"
31 #include <stdlib.h>
32 #include "os0thread.h"
33 
34 #if defined(__GNUC__) && (__GNUC__ > 2)
35 
38 # define UT_DBG_FAIL(EXPR) UNIV_UNLIKELY(!((ulint)(EXPR)))
39 #else
40 
41 extern ulint ut_dbg_zero;
45 # define UT_DBG_FAIL(EXPR) !((ulint)(EXPR) + ut_dbg_zero)
46 #endif
47 
48 /*************************************************************/
50 #ifdef __cplusplus
51 extern "C"
52 #endif
53 UNIV_INTERN
54 void
56 /*====================*/
57  const char* expr,
58  const char* file,
59  ulint line);
61 #if defined(__WIN__) || defined(__INTEL_COMPILER)
62 # undef UT_DBG_USE_ABORT
63 #elif defined(__GNUC__) && (__GNUC__ > 2)
64 # define UT_DBG_USE_ABORT
65 #endif
66 
67 #ifndef UT_DBG_USE_ABORT
68 
69 extern ulint* ut_dbg_null_ptr;
70 #endif
71 
72 #if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT)
73 
75 extern ibool ut_dbg_stop_threads;
76 
77 /*************************************************************/
79 UNIV_INTERN
80 void
82 /*===============*/
83  const char* file,
84  ulint line);
85 #endif
86 
87 #ifdef UT_DBG_USE_ABORT
88 
89 # define UT_DBG_PANIC abort()
90 
91 # define UT_DBG_STOP do {} while (0)
92 #else /* UT_DBG_USE_ABORT */
93 
94 # define UT_DBG_PANIC \
95  if (*(ut_dbg_null_ptr)) ut_dbg_null_ptr = NULL
96 
97 # define UT_DBG_STOP do \
98  if (UNIV_UNLIKELY(ut_dbg_stop_threads)) { \
99  ut_dbg_stop_thread(__FILE__, (ulint) __LINE__); \
100  } while (0)
101 #endif /* UT_DBG_USE_ABORT */
102 
105 #define ut_a(EXPR) do { \
106  if (UT_DBG_FAIL(EXPR)) { \
107  ut_dbg_assertion_failed(#EXPR, \
108  __FILE__, (ulint) __LINE__); \
109  UT_DBG_PANIC; \
110  } \
111  UT_DBG_STOP; \
112 } while (0)
113 
115 #define ut_error do { \
116  ut_dbg_assertion_failed(0, __FILE__, (ulint) __LINE__); \
117  UT_DBG_PANIC; \
118 } while (0)
119 
120 #ifdef UNIV_DEBUG
121 
122 #define ut_ad(EXPR) ut_a(EXPR)
123 
124 #define ut_d(EXPR) do {EXPR;} while (0)
125 #else
126 
127 #define ut_ad(EXPR)
128 
129 #define ut_d(EXPR)
130 #endif
131 
134 #define UT_NOT_USED(A) A = A
135 
136 #ifdef UNIV_COMPILE_TEST_FUNCS
137 
138 #include <sys/types.h>
139 #include <sys/time.h>
140 #include <sys/resource.h>
141 
143 typedef struct speedo_struct {
144  struct rusage ru;
145  struct timeval tv;
146 } speedo_t;
147 
148 /*******************************************************************/
150 UNIV_INTERN
151 void
152 speedo_reset(
153 /*=========*/
154  speedo_t* speedo);
156 /*******************************************************************/
159 UNIV_INTERN
160 void
161 speedo_show(
162 /*========*/
163  const speedo_t* speedo);
165 #endif /* UNIV_COMPILE_TEST_FUNCS */
166 
167 #endif
ulint * ut_dbg_null_ptr
Definition: ut0dbg.cc:43
ibool ut_dbg_stop_threads
Definition: ut0dbg.cc:39
UNIV_INTERN void ut_dbg_stop_thread(const char *file, ulint line)
Definition: ut0dbg.cc:94
ulint ut_dbg_zero
Definition: ut0dbg.cc:33
UNIV_INTERN void ut_dbg_assertion_failed(const char *expr, const char *file, ulint line)
Definition: ut0dbg.cc:53