59 if (unlikely(false == (bool)(EXPR))) { \
60 ut_dbg_assertion_failed(#EXPR, __FILE__, __LINE__); \
65#define ut_error ut_dbg_assertion_failed(0, __FILE__, __LINE__)
69#define ut_ad(EXPR) ut_a(EXPR)
71#define ut_d(EXPR) EXPR
80#define ut_o(EXPR) EXPR
85#define DBUG_INJECT_CRASH(prefix, count) \
88 snprintf(buf, sizeof buf, prefix "_%u", count); \
89 DBUG_EXECUTE_IF(buf, DBUG_SUICIDE();); \
92#define DBUG_INJECT_CRASH_WITH_LOG_FLUSH(prefix, count) \
95 snprintf(buf, sizeof buf, prefix "_%u", count); \
96 DBUG_EXECUTE_IF(buf, log_buffer_flush_to_disk(); DBUG_SUICIDE();); \
100#define DBUG_INJECT_CRASH(prefix, count)
101#define DBUG_INJECT_CRASH_WITH_LOG_FLUSH(prefix, count)
106#define UT_NOT_USED(A) std::ignore = A
108#if defined(HAVE_SYS_TIME_H) && defined(HAVE_SYS_RESOURCE_H)
110#define HAVE_UT_CHRONO_T
112#include <sys/resource.h>
114#include <sys/types.h>
132 gettimeofday(&
m_tv,
nullptr);
134 getrusage(RUSAGE_SELF, &
m_ru);
139 struct rusage ru_now;
140 struct timeval tv_now;
141 struct timeval tv_diff;
143 getrusage(RUSAGE_SELF, &ru_now);
145 gettimeofday(&tv_now,
nullptr);
148#define timersub(a, b, r) \
150 (r)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
151 (r)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
152 if ((r)->tv_usec < 0) { \
154 (r)->tv_usec += 1000000; \
159#define CHRONO_PRINT(type, tvp) \
160 fprintf(stderr, "%s: %s% 5ld.%06ld sec\n", m_name, type, \
161 static_cast<long>((tvp)->tv_sec), static_cast<long>((tvp)->tv_usec))
A "chronometer" used to clock snippets of code.
Definition: ut0dbg.h:122
void show()
Shows the time elapsed and usage statistics since the last reset.
Definition: ut0dbg.h:138
bool m_show_from_destructor
True if the current timings should be printed by the destructor.
Definition: ut0dbg.h:188
struct rusage m_ru
getrusage() result as of the last reset().
Definition: ut0dbg.h:191
ut_chrono_t(const char *name)
Constructor.
Definition: ut0dbg.h:126
const char * m_name
Name of this chronometer.
Definition: ut0dbg.h:185
struct timeval m_tv
gettimeofday() result as of the last reset().
Definition: ut0dbg.h:194
void reset()
Resets the chrono (records the current time in it).
Definition: ut0dbg.h:131
void end()
Cause the timings not to be printed from the destructor.
Definition: ut0dbg.h:174
~ut_chrono_t()
Destructor.
Definition: ut0dbg.h:177
Header for compiler-dependent features.
case opt name
Definition: sslopt-case.h:33
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:56
#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:48