60template <
typename L,
typename R>
62 const char *lhs_expr,
const L &lhs_value,
const char *op,
63 const char *rhs_expr,
const R &rhs_value,
const char *
file, uint64_t line) {
65 text << lhs_expr <<
" == " << lhs_value <<
' ' << op <<
' ' << rhs_value
66 <<
" == " << rhs_expr;
77#define ut_a_op(LHS, OP, RHS) \
79 const auto lhs{LHS}; \
80 const auto rhs{RHS}; \
81 if (unlikely(!(lhs OP rhs))) { \
82 ut_dbg_comparison_failed(#LHS, lhs, #OP, #RHS, rhs, __FILE__, __LINE__); \
87#define ut_a_lt(LHS, RHS) ut_a_op(LHS, <, RHS)
89#define ut_a_le(LHS, RHS) ut_a_op(LHS, <=, RHS)
91#define ut_a_eq(LHS, RHS) ut_a_op(LHS, ==, RHS)
93#define ut_a_ne(LHS, RHS) ut_a_op(LHS, !=, RHS)
99 if (unlikely(false == (bool)(EXPR))) { \
100 ut_dbg_assertion_failed(#EXPR, __FILE__, __LINE__); \
105#define ut_error ut_dbg_assertion_failed(nullptr, __FILE__, __LINE__)
109#define ut_ad(EXPR) ut_a(EXPR)
111#define ut_d(EXPR) EXPR
115#define ut_ad_lt(LHS, RHS) ut_a_lt(LHS, RHS)
117#define ut_ad_le(LHS, RHS) ut_a_le(LHS, RHS)
119#define ut_ad_eq(LHS, RHS) ut_a_eq(LHS, RHS)
121#define ut_ad_ne(LHS, RHS) ut_a_op(LHS, !=, RHS)
128#define ut_o(EXPR) EXPR
130#define ut_ad_lt(LHS, RHS)
132#define ut_ad_le(LHS, RHS)
134#define ut_ad_eq(LHS, RHS)
136#define ut_ad_ne(LHS, RHS)
148#define DBUG_INJECT_CRASH(prefix, count)
153#define UT_NOT_USED(A) std::ignore = A
155#if defined(HAVE_SYS_TIME_H) && defined(HAVE_SYS_RESOURCE_H)
157#define HAVE_UT_CHRONO_T
159#include <sys/resource.h>
161#include <sys/types.h>
179 gettimeofday(&
m_tv,
nullptr);
181 getrusage(RUSAGE_SELF, &
m_ru);
186 struct rusage ru_now;
187 struct timeval tv_now;
188 struct timeval tv_diff;
190 getrusage(RUSAGE_SELF, &ru_now);
192 gettimeofday(&tv_now,
nullptr);
195#define timersub(a, b, r) \
197 (r)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
198 (r)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
199 if ((r)->tv_usec < 0) { \
201 (r)->tv_usec += 1000000; \
206#define CHRONO_PRINT(type, tvp) \
207 fprintf(stderr, "%s: %s% 5ld.%06ld sec\n", m_name, type, \
208 static_cast<long>((tvp)->tv_sec), static_cast<long>((tvp)->tv_usec))
A "chronometer" used to clock snippets of code.
Definition: ut0dbg.h:169
void show()
Shows the time elapsed and usage statistics since the last reset.
Definition: ut0dbg.h:185
bool m_show_from_destructor
True if the current timings should be printed by the destructor.
Definition: ut0dbg.h:235
struct rusage m_ru
getrusage() result as of the last reset().
Definition: ut0dbg.h:238
ut_chrono_t(const char *name)
Constructor.
Definition: ut0dbg.h:173
const char * m_name
Name of this chronometer.
Definition: ut0dbg.h:232
struct timeval m_tv
gettimeofday() result as of the last reset().
Definition: ut0dbg.h:241
void reset()
Resets the chrono (records the current time in it).
Definition: ut0dbg.h:178
void end()
Cause the timings not to be printed from the destructor.
Definition: ut0dbg.h:221
~ut_chrono_t()
Destructor.
Definition: ut0dbg.h:224
#define L
Definition: ctype-tis620.cc:74
Header for compiler-dependent features.
#define DBUG_EXECUTE_IF(keyword, a1)
Definition: my_dbug.h:171
#define DBUG_SUICIDE()
Definition: my_dbug.h:228
static int count
Definition: myisam_ftdump.cc:45
Definition: buf0block_hint.cc:30
std::basic_ostringstream< char, std::char_traits< char >, ut::allocator< char > > ostringstream
Specialization of basic_ostringstream which uses ut::allocator.
Definition: ut0new.h:2720
Include file for Sun RPC to compile out of the box.
case opt name
Definition: sslopt-case.h:29
#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_fatal_error()
Terminates execution of the current process.
Definition: ut0dbg.cc:99
void DBUG_INJECT_CRASH(const char *prefix, unsigned count)
Debug crash point.
Definition: ut0dbg.h:142
void ut_dbg_comparison_failed(const char *lhs_expr, const L &lhs_value, const char *op, const char *rhs_expr, const R &rhs_value, const char *file, uint64_t line)
Definition: ut0dbg.h:61
void ut_set_assert_callback(std::function< void()> &callback)
Set a callback function to be called before exiting.
Definition: ut0dbg.cc:48