1
/*********************************************************************
2
Debug utilities for Innobase
4
(c) 1994, 1995 Innobase Oy
6
Created 1/30/1994 Heikki Tuuri
7
**********************************************************************/
14
#include "os0thread.h"
16
#if defined(__GNUC__) && (__GNUC__ > 2)
17
# define UT_DBG_FAIL(EXPR) UNIV_UNLIKELY(!((ulint)(EXPR)))
19
extern ulint ut_dbg_zero; /* This is used to eliminate
21
# define UT_DBG_FAIL(EXPR) !((ulint)(EXPR) + ut_dbg_zero)
24
/*****************************************************************
25
Report a failed assertion. */
28
ut_dbg_assertion_failed(
29
/*====================*/
30
const char* expr, /* in: the failed assertion */
31
const char* file, /* in: source file containing the assertion */
32
ulint line); /* in: line number of the assertion */
35
/* Flag for ignoring further assertion failures.
36
On NetWare, have a graceful exit rather than a segfault to avoid abends. */
37
extern ibool panic_shutdown;
38
/* Abort the execution. */
39
void ut_dbg_panic(void);
40
# define UT_DBG_PANIC ut_dbg_panic()
41
/* Stop threads in ut_a(). */
42
# define UT_DBG_STOP while (0) /* We do not do this on NetWare */
43
#else /* __NETWARE__ */
44
# if defined(__WIN__) || defined(__INTEL_COMPILER)
45
# undef UT_DBG_USE_ABORT
46
# elif defined(__GNUC__) && (__GNUC__ > 2)
47
# define UT_DBG_USE_ABORT
50
# ifndef UT_DBG_USE_ABORT
51
/* A null pointer that will be dereferenced to trigger a memory trap */
52
extern ulint* ut_dbg_null_ptr;
55
# if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT)
56
/* Flag for indicating that all threads should stop. This will be set
57
by ut_dbg_assertion_failed(). */
58
extern ibool ut_dbg_stop_threads;
60
/*****************************************************************
61
Stop a thread after assertion failure. */
70
# ifdef UT_DBG_USE_ABORT
71
/* Abort the execution. */
72
# define UT_DBG_PANIC abort()
73
/* Stop threads (null operation) */
74
# define UT_DBG_STOP while (0)
75
# else /* UT_DBG_USE_ABORT */
76
/* Abort the execution. */
77
# define UT_DBG_PANIC \
78
if (*(ut_dbg_null_ptr)) ut_dbg_null_ptr = NULL
79
/* Stop threads in ut_a(). */
80
# define UT_DBG_STOP do \
81
if (UNIV_UNLIKELY(ut_dbg_stop_threads)) { \
82
ut_dbg_stop_thread(__FILE__, (ulint) __LINE__); \
84
# endif /* UT_DBG_USE_ABORT */
85
#endif /* __NETWARE__ */
87
/* Abort execution if EXPR does not evaluate to nonzero. */
88
#define ut_a(EXPR) do { \
89
if (UT_DBG_FAIL(EXPR)) { \
90
ut_dbg_assertion_failed(#EXPR, \
91
__FILE__, (ulint) __LINE__); \
97
/* Abort execution. */
98
#define ut_error do { \
99
ut_dbg_assertion_failed(0, __FILE__, (ulint) __LINE__); \
104
#define ut_ad(EXPR) ut_a(EXPR)
105
#define ut_d(EXPR) do {EXPR;} while (0)
111
#define UT_NOT_USED(A) A = A