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 */
34
# if defined(__WIN__) || defined(__INTEL_COMPILER)
35
# undef UT_DBG_USE_ABORT
36
# elif defined(__GNUC__) && (__GNUC__ > 2)
37
# define UT_DBG_USE_ABORT
40
# ifndef UT_DBG_USE_ABORT
41
/* A null pointer that will be dereferenced to trigger a memory trap */
42
extern ulint* ut_dbg_null_ptr;
45
# if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT)
46
/* Flag for indicating that all threads should stop. This will be set
47
by ut_dbg_assertion_failed(). */
48
extern ibool ut_dbg_stop_threads;
50
/*****************************************************************
51
Stop a thread after assertion failure. */
60
# ifdef UT_DBG_USE_ABORT
61
/* Abort the execution. */
62
# define UT_DBG_PANIC abort()
63
/* Stop threads (null operation) */
64
# define UT_DBG_STOP while (0)
65
# else /* UT_DBG_USE_ABORT */
66
/* Abort the execution. */
67
# define UT_DBG_PANIC \
68
if (*(ut_dbg_null_ptr)) ut_dbg_null_ptr = NULL
69
/* Stop threads in ut_a(). */
70
# define UT_DBG_STOP do \
71
if (UNIV_UNLIKELY(ut_dbg_stop_threads)) { \
72
ut_dbg_stop_thread(__FILE__, (ulint) __LINE__); \
74
# endif /* UT_DBG_USE_ABORT */
76
/* Abort execution if EXPR does not evaluate to nonzero. */
77
#define ut_a(EXPR) do { \
78
if (UT_DBG_FAIL(EXPR)) { \
79
ut_dbg_assertion_failed(#EXPR, \
80
__FILE__, (ulint) __LINE__); \
86
/* Abort execution. */
87
#define ut_error do { \
88
ut_dbg_assertion_failed(0, __FILE__, (ulint) __LINE__); \
93
#define ut_ad(EXPR) ut_a(EXPR)
94
#define ut_d(EXPR) do {EXPR;} while (0)
100
#define UT_NOT_USED(A) A = A