56template <
typename L, 
typename R>
 
   58    const char *lhs_expr, 
const L &lhs_value, 
const char *op,
 
   59    const char *rhs_expr, 
const R &rhs_value, 
const char *
file, uint64_t line) {
 
   61  text << lhs_expr << 
" == " << lhs_value << 
' ' << op << 
' ' << rhs_value
 
   62       << 
" == " << rhs_expr;
 
   73#define ut_a_op(LHS, OP, RHS)                                                  \ 
   75    const auto lhs{LHS};                                                       \ 
   76    const auto rhs{RHS};                                                       \ 
   77    if (unlikely(!(lhs OP rhs))) {                                             \ 
   78      ut_dbg_comparison_failed(#LHS, lhs, #OP, #RHS, rhs, __FILE__, __LINE__); \ 
   83#define ut_a_lt(LHS, RHS) ut_a_op(LHS, <, RHS) 
   85#define ut_a_le(LHS, RHS) ut_a_op(LHS, <=, RHS) 
   87#define ut_a_eq(LHS, RHS) ut_a_op(LHS, ==, RHS) 
   89#define ut_a_ne(LHS, RHS) ut_a_op(LHS, !=, RHS) 
   95    if (unlikely(false == (bool)(EXPR))) {                \ 
   96      ut_dbg_assertion_failed(#EXPR, __FILE__, __LINE__); \ 
  101#define ut_error ut_dbg_assertion_failed(nullptr, __FILE__, __LINE__) 
  105#define ut_ad(EXPR) ut_a(EXPR) 
  107#define ut_d(EXPR) EXPR 
  111#define ut_ad_lt(LHS, RHS) ut_a_lt(LHS, RHS) 
  113#define ut_ad_le(LHS, RHS) ut_a_le(LHS, RHS) 
  115#define ut_ad_eq(LHS, RHS) ut_a_eq(LHS, RHS) 
  117#define ut_ad_ne(LHS, RHS) ut_a_op(LHS, !=, RHS) 
  124#define ut_o(EXPR) EXPR 
  126#define ut_ad_lt(LHS, RHS) 
  128#define ut_ad_le(LHS, RHS) 
  130#define ut_ad_eq(LHS, RHS) 
  132#define ut_ad_ne(LHS, RHS) 
  137#define DBUG_INJECT_CRASH(prefix, count)            \ 
  140    snprintf(buf, sizeof buf, prefix "_%u", count); \
 
  141    DBUG_EXECUTE_IF(buf, DBUG_SUICIDE(););          \
 
  144#define DBUG_INJECT_CRASH_WITH_LOG_FLUSH(prefix, count)                \ 
  147    snprintf(buf, sizeof buf, prefix "_%u", count);                    \
 
  148    DBUG_EXECUTE_IF(buf, log_buffer_flush_to_disk(); DBUG_SUICIDE();); \
 
  152#define DBUG_INJECT_CRASH(prefix, count) 
  153#define DBUG_INJECT_CRASH_WITH_LOG_FLUSH(prefix, count) 
  158#define UT_NOT_USED(A) std::ignore = A 
  160#if defined(HAVE_SYS_TIME_H) && defined(HAVE_SYS_RESOURCE_H) 
  162#define HAVE_UT_CHRONO_T 
  164#include <sys/resource.h> 
  166#include <sys/types.h> 
  184    gettimeofday(&
m_tv, 
nullptr);
 
  186    getrusage(RUSAGE_SELF, &
m_ru);
 
  191    struct rusage ru_now;
 
  192    struct timeval tv_now;
 
  193    struct timeval tv_diff;
 
  195    getrusage(RUSAGE_SELF, &ru_now);
 
  197    gettimeofday(&tv_now, 
nullptr);
 
  200#define timersub(a, b, r)                       \ 
  202    (r)->tv_sec = (a)->tv_sec - (b)->tv_sec;    \ 
  203    (r)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ 
  204    if ((r)->tv_usec < 0) {                     \ 
  206      (r)->tv_usec += 1000000;                  \ 
  211#define CHRONO_PRINT(type, tvp)                            \ 
  212  fprintf(stderr, "%s: %s% 5ld.%06ld sec\n", m_name, type, \
 
  213          static_cast<long>((tvp)->tv_sec), static_cast<long>((tvp)->tv_usec))
 
A "chronometer" used to clock snippets of code.
Definition: ut0dbg.h:174
 
void show()
Shows the time elapsed and usage statistics since the last reset.
Definition: ut0dbg.h:190
 
bool m_show_from_destructor
True if the current timings should be printed by the destructor.
Definition: ut0dbg.h:240
 
struct rusage m_ru
getrusage() result as of the last reset().
Definition: ut0dbg.h:243
 
ut_chrono_t(const char *name)
Constructor.
Definition: ut0dbg.h:178
 
const char * m_name
Name of this chronometer.
Definition: ut0dbg.h:237
 
struct timeval m_tv
gettimeofday() result as of the last reset().
Definition: ut0dbg.h:246
 
void reset()
Resets the chrono (records the current time in it).
Definition: ut0dbg.h:183
 
void end()
Cause the timings not to be printed from the destructor.
Definition: ut0dbg.h:226
 
~ut_chrono_t()
Destructor.
Definition: ut0dbg.h:229
 
#define L
Definition: ctype-tis620.cc:74
 
Header for compiler-dependent features.
 
std::basic_ostringstream< char, std::char_traits< char >, ut::allocator< char > > ostringstream
Specialization of basic_ostringstream which uses ut::allocator.
Definition: ut0new.h:2876
 
case opt name
Definition: sslopt-case.h:29
 
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_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:57
 
void ut_set_assert_callback(std::function< void()> &callback)
Set a callback function to be called before exiting.
Definition: ut0dbg.cc:48