mariadb/innobase/include/ut0dbg.h

96 lines
2.7 KiB
C
Raw Normal View History

2001-02-17 14:19:19 +02:00
/*********************************************************************
Debug utilities for Innobase
(c) 1994, 1995 Innobase Oy
Created 1/30/1994 Heikki Tuuri
**********************************************************************/
#ifndef ut0dbg_h
#define ut0dbg_h
2001-04-20 15:18:46 +03:00
#include "univ.i"
2001-02-17 14:19:19 +02:00
#include <stdlib.h>
#include "os0thread.h"
extern ulint ut_dbg_zero; /* This is used to eliminate
compiler warnings */
extern ibool ut_dbg_stop_threads;
extern ulint* ut_dbg_null_ptr;
extern const char* ut_dbg_msg_assert_fail;
extern const char* ut_dbg_msg_trap;
extern const char* ut_dbg_msg_stop;
/* Have a graceful exit on NetWare rather than a segfault to avoid abends */
#ifdef __NETWARE__
extern ibool panic_shutdown;
#define ut_a(EXPR) do {\
if (!((ulint)(EXPR) + ut_dbg_zero)) {\
ut_print_timestamp(stderr);\
fprintf(stderr, ut_dbg_msg_assert_fail,\
os_thread_pf(os_thread_get_curr_id()), __FILE__,\
(ulint)__LINE__);\
fputs("InnoDB: Failing assertion: " #EXPR "\n", stderr);\
fputs(ut_dbg_msg_trap, stderr);\
ut_dbg_stop_threads = TRUE;\
if (ut_dbg_stop_threads) {\
fprintf(stderr, ut_dbg_msg_stop,\
os_thread_pf(os_thread_get_curr_id()), __FILE__, (ulint)__LINE__);\
}\
if(!panic_shutdown){\
panic_shutdown = TRUE;\
innobase_shutdown_for_mysql();}\
exit(1);\
}\
} while (0)
#define ut_error do {\
ut_print_timestamp(stderr);\
fprintf(stderr, ut_dbg_msg_assert_fail,\
os_thread_pf(os_thread_get_curr_id()), __FILE__, (ulint)__LINE__);\
fprintf(stderr, ut_dbg_msg_trap);\
ut_dbg_stop_threads = TRUE;\
if(!panic_shutdown){panic_shutdown = TRUE;\
innobase_shutdown_for_mysql();}\
} while (0)
#else
2004-03-12 13:46:26 +02:00
#define ut_a(EXPR) do {\
2001-02-17 14:19:19 +02:00
if (!((ulint)(EXPR) + ut_dbg_zero)) {\
2002-08-06 22:59:13 +03:00
ut_print_timestamp(stderr);\
fprintf(stderr, ut_dbg_msg_assert_fail,\
2004-05-14 16:06:21 +03:00
os_thread_pf(os_thread_get_curr_id()), __FILE__,\
2002-08-06 22:59:13 +03:00
(ulint)__LINE__);\
fputs("InnoDB: Failing assertion: " #EXPR "\n", stderr);\
fputs(ut_dbg_msg_trap, stderr);\
2001-02-17 14:19:19 +02:00
ut_dbg_stop_threads = TRUE;\
2004-03-12 13:46:26 +02:00
if (*(ut_dbg_null_ptr)) ut_dbg_null_ptr = NULL;\
2001-02-17 14:19:19 +02:00
}\
if (ut_dbg_stop_threads) {\
fprintf(stderr, ut_dbg_msg_stop,\
2004-05-14 16:06:21 +03:00
os_thread_pf(os_thread_get_curr_id()), __FILE__, (ulint)__LINE__);\
2001-02-17 14:19:19 +02:00
os_thread_sleep(1000000000);\
}\
2004-03-12 13:46:26 +02:00
} while (0)
2004-03-12 13:46:26 +02:00
#define ut_error do {\
ut_print_timestamp(stderr);\
fprintf(stderr, ut_dbg_msg_assert_fail,\
2004-05-14 16:06:21 +03:00
os_thread_pf(os_thread_get_curr_id()), __FILE__, (ulint)__LINE__);\
fprintf(stderr, ut_dbg_msg_trap);\
ut_dbg_stop_threads = TRUE;\
2004-03-12 13:46:26 +02:00
if (*(ut_dbg_null_ptr)) ut_dbg_null_ptr = NULL;\
} while (0)
#endif
2001-02-17 14:19:19 +02:00
#ifdef UNIV_DEBUG
#define ut_ad(EXPR) ut_a(EXPR)
2004-03-16 22:41:30 +02:00
#define ut_d(EXPR) do {EXPR;} while (0)
2001-02-17 14:19:19 +02:00
#else
#define ut_ad(EXPR)
#define ut_d(EXPR)
#endif
#define UT_NOT_USED(A) A = A
#endif