58 if (unlikely(false == (bool)(EXPR))) { \
59 ut_dbg_assertion_failed(#EXPR, __FILE__, __LINE__); \
64#define ut_error ut_dbg_assertion_failed(0, __FILE__, __LINE__)
68#define ut_ad(EXPR) ut_a(EXPR)
70#define ut_d(EXPR) EXPR
79#define ut_o(EXPR) EXPR
84#define DBUG_INJECT_CRASH(prefix, count) \
87 snprintf(buf, sizeof buf, prefix "_%u", count); \
88 DBUG_EXECUTE_IF(buf, DBUG_SUICIDE();); \
91#define DBUG_INJECT_CRASH_WITH_LOG_FLUSH(prefix, count) \
94 snprintf(buf, sizeof buf, prefix "_%u", count); \
95 DBUG_EXECUTE_IF(buf, log_buffer_flush_to_disk(); DBUG_SUICIDE();); \
99#define DBUG_INJECT_CRASH(prefix, count)
100#define DBUG_INJECT_CRASH_WITH_LOG_FLUSH(prefix, count)
105#define UT_NOT_USED(A) std::ignore = A
107#if defined(HAVE_SYS_TIME_H) && defined(HAVE_SYS_RESOURCE_H)
109#define HAVE_UT_CHRONO_T
111#include <sys/resource.h>
113#include <sys/types.h>
131 gettimeofday(&
m_tv,
nullptr);
133 getrusage(RUSAGE_SELF, &
m_ru);
138 struct rusage ru_now;
139 struct timeval tv_now;
140 struct timeval tv_diff;
142 getrusage(RUSAGE_SELF, &ru_now);
144 gettimeofday(&tv_now,
nullptr);
147#define timersub(a, b, r) \
149 (r)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
150 (r)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
151 if ((r)->tv_usec < 0) { \
153 (r)->tv_usec += 1000000; \
158#define CHRONO_PRINT(type, tvp) \
159 fprintf(stderr, "%s: %s% 5ld.%06ld sec\n", m_name, type, \
160 static_cast<long>((tvp)->tv_sec), static_cast<long>((tvp)->tv_usec))
A "chronometer" used to clock snippets of code.
Definition: ut0dbg.h:121
void show()
Shows the time elapsed and usage statistics since the last reset.
Definition: ut0dbg.h:137
bool m_show_from_destructor
True if the current timings should be printed by the destructor.
Definition: ut0dbg.h:187
struct rusage m_ru
getrusage() result as of the last reset().
Definition: ut0dbg.h:190
ut_chrono_t(const char *name)
Constructor.
Definition: ut0dbg.h:125
const char * m_name
Name of this chronometer.
Definition: ut0dbg.h:184
struct timeval m_tv
gettimeofday() result as of the last reset().
Definition: ut0dbg.h:193
void reset()
Resets the chrono (records the current time in it).
Definition: ut0dbg.h:130
void end()
Cause the timings not to be printed from the destructor.
Definition: ut0dbg.h:173
~ut_chrono_t()
Destructor.
Definition: ut0dbg.h:176
Header for compiler-dependent features.
case opt name
Definition: sslopt-case.h:32
Include file for Sun RPC to compile out of the box.
#define CHRONO_PRINT(type, tvp)
void ut_dbg_assertion_failed(const char *expr, const char *file, uint64_t line)
Report a failed assertion.
Definition: ut0dbg.cc:55
#define timersub(a, b, r)
void ut_set_assert_callback(std::function< void()> &callback)
Set a callback function to be called before exiting.
Definition: ut0dbg.cc:47