MySQL 8.0.39
Source Code Documentation
ut0dbg.h File Reference

Debug utilities for Innobase. More...

#include "my_compiler.h"
#include <cstdio>
#include <functional>
#include <sys/resource.h>
#include <sys/time.h>
#include <sys/types.h>

Go to the source code of this file.

Classes

class  ut_chrono_t
 A "chronometer" used to clock snippets of code. More...
 

Macros

#define ut_a(EXPR)
 Abort execution if EXPR does not evaluate to nonzero. More...
 
#define ut_error   ut_dbg_assertion_failed(0, __FILE__, __LINE__)
 Abort execution. More...
 
#define ut_ad(EXPR)   ut_a(EXPR)
 Debug assertion. More...
 
#define ut_d(EXPR)   EXPR
 Debug statement. More...
 
#define ut_o(EXPR)
 Opposite of ut_d(). More...
 
#define DBUG_INJECT_CRASH(prefix, count)
 Debug crash point. More...
 
#define DBUG_INJECT_CRASH_WITH_LOG_FLUSH(prefix, count)
 
#define UT_NOT_USED(A)   std::ignore = A
 Silence warnings about an unused variable by doing a null assignment. More...
 
#define HAVE_UT_CHRONO_T
 
#define timersub(a, b, r)
 
#define CHRONO_PRINT(type, tvp)
 

Functions

void ut_set_assert_callback (std::function< void()> &callback)
 Set a callback function to be called before exiting. More...
 
void ut_dbg_assertion_failed (const char *expr, const char *file, uint64_t line)
 Report a failed assertion. More...
 

Detailed Description

Debug utilities for Innobase.

Created 1/30/1994 Heikki Tuuri

Macro Definition Documentation

◆ CHRONO_PRINT

#define CHRONO_PRINT (   type,
  tvp 
)
Value:
fprintf(stderr, "%s: %s% 5ld.%06ld sec\n", m_name, type, \
static_cast<long>((tvp)->tv_sec), static_cast<long>((tvp)->tv_usec))
required string type
Definition: replication_group_member_actions.proto:34

◆ DBUG_INJECT_CRASH

#define DBUG_INJECT_CRASH (   prefix,
  count 
)
Value:
do { \
char buf[64]; \
snprintf(buf, sizeof buf, prefix "_%u", count); \
DBUG_EXECUTE_IF(buf, DBUG_SUICIDE();); \
} while (0)
#define DBUG_SUICIDE()
Definition: my_dbug.h:228
static int count
Definition: myisam_ftdump.cc:43
Definition: buf0block_hint.cc:30

Debug crash point.

◆ DBUG_INJECT_CRASH_WITH_LOG_FLUSH

#define DBUG_INJECT_CRASH_WITH_LOG_FLUSH (   prefix,
  count 
)
Value:
do { \
char buf[64]; \
snprintf(buf, sizeof buf, prefix "_%u", count); \
DBUG_EXECUTE_IF(buf, log_buffer_flush_to_disk(); DBUG_SUICIDE();); \
} while (0)
void log_buffer_flush_to_disk(log_t &log, bool sync=true)
Write to the log file up to the last log entry.
Definition: log0buf.cc:1193

◆ HAVE_UT_CHRONO_T

#define HAVE_UT_CHRONO_T

◆ timersub

#define timersub (   a,
  b,
  r 
)
Value:
do { \
(r)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
(r)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
if ((r)->tv_usec < 0) { \
(r)->tv_sec--; \
(r)->tv_usec += 1000000; \
} \
} while (0)
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:86

◆ ut_a

#define ut_a (   EXPR)
Value:
do { \
if (unlikely(false == (bool)(EXPR))) { \
ut_dbg_assertion_failed(#EXPR, __FILE__, __LINE__); \
} \
} while (0)
constexpr bool unlikely(bool expr)
Definition: my_compiler.h:56

Abort execution if EXPR does not evaluate to nonzero.

Parameters
EXPRassertion expression that should hold

◆ ut_ad

#define ut_ad (   EXPR)    ut_a(EXPR)

Debug assertion.

Does nothing unless UNIV_DEBUG is defined.

◆ ut_d

#define ut_d (   EXPR)    EXPR

Debug statement.

Does nothing unless UNIV_DEBUG is defined.

◆ ut_error

#define ut_error   ut_dbg_assertion_failed(0, __FILE__, __LINE__)

Abort execution.

◆ UT_NOT_USED

#define UT_NOT_USED (   A)    std::ignore = A

Silence warnings about an unused variable by doing a null assignment.

Parameters
Athe unused variable

◆ ut_o

#define ut_o (   EXPR)

Opposite of ut_d().

Does nothing if UNIV_DEBUG is defined.

Function Documentation

◆ ut_dbg_assertion_failed()

void ut_dbg_assertion_failed ( const char *  expr,
const char *  file,
uint64_t  line 
)

Report a failed assertion.

Parameters
[in]exprThe failed assertion
[in]fileSource file containing the assertion
[in]lineLine number of the assertion

◆ ut_set_assert_callback()

void ut_set_assert_callback ( std::function< void()> &  callback)

Set a callback function to be called before exiting.

Parameters
[in]callbackuser callback function