VAPOR3 3.9.4
Macros | Functions
debug.h File Reference
#include <signal.h>
#include <stdio.h>
#include <string>
#include <vector>
#include <libgen.h>
#include <sys/time.h>
#include <execinfo.h>

Go to the source code of this file.

Macros

#define DLOG_BASENAME_ONLY   1
 
#define dLog_pre()   fprintf(stderr, "[%s:%i:%s] ", basename(__FILE__), __LINE__, __func__)
 
#define dLog(...)
 
#define dBreak()
 
#define dBreakIf(x)
 
#define dBreakCount(x)
 
#define PERF_TIMER_START
 
#define PERF_TIMER_STOP   gettimeofday(&PERF_TIMER_T2, NULL);
 
#define PERF_TIMER_DELTA   ((PERF_TIMER_T2.tv_usec - PERF_TIMER_T1.tv_usec) / 1000000.0 + (double)(PERF_TIMER_T2.tv_sec - PERF_TIMER_T1.tv_sec))
 
#define PRINT_BACKTRACE(...)
 
#define VDC_LIBTRACE
 
#define NARG(...)   NARG_(__VA_ARGS__, RSEQ_N())
 
#define NARG_(...)   ARG_N(__VA_ARGS__)
 
#define ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, N, ...)   N
 
#define RSEQ_N()   9, 8, 7, 6, 5, 4, 3, 2, 1, 0
 
#define _CONCAT(a, b)   a##b
 
#define PRINTARGS_1(x, ...)
 
#define PRINTARGS_2(x, ...)
 
#define PRINTARGS_3(x, ...)
 
#define PRINTARGS_4(x, ...)
 
#define PRINTARGS_5(x, ...)
 
#define PRINTARGS_6(x, ...)
 
#define PRINTARGS_7(x, ...)
 
#define PRINTARGS_8(x, ...)
 
#define PRINTARGS_9(x, ...)
 
#define _PRINTARGS(n, ...)
 
#define PRINTARGS(...)   _PRINTARGS(NARG(__VA_ARGS__), __VA_ARGS__)
 
#define FTRACE_PRE()   printf("%s%s(", classScopeFromPrettyFunc(__PRETTY_FUNCTION__).c_str(), __func__)
 
#define FTRACE(...)
 

Functions

void PRINTARG ()
 
void PRINTARG (int x)
 
void PRINTARG (long x)
 
void PRINTARG (size_t x)
 
void PRINTARG (float x)
 
void PRINTARG (double x)
 
void PRINTARG (bool x)
 
void PRINTARG (const std::string x)
 
void PRINTARG (const char *x)
 
void PRINTARG (const int *i)
 
void PRINTARG (const float *f)
 
void PRINTARG (const double *d)
 
void PRINTARG (const size_t *li)
 
void PRINTARG (const long *li)
 
void PRINTARG (const void *x)
 
template<class T >
void PRINTARG (const std::vector< T > v)
 
std::string classScopeFromPrettyFunc (const std::string &pretty)
 

Macro Definition Documentation

◆ _CONCAT

#define _CONCAT (   a,
 
)    a##b

Definition at line 168 of file debug.h.

◆ _PRINTARGS

#define _PRINTARGS (   n,
  ... 
)
Value:
_CONCAT(PRINTARGS_, n) \
(__VA_ARGS__)
#define _CONCAT(a, b)
Definition: debug.h:168

Definition at line 221 of file debug.h.

◆ ARG_N

#define ARG_N (   _1,
  _2,
  _3,
  _4,
  _5,
  _6,
  _7,
  _8,
  _9,
  N,
  ... 
)    N

Definition at line 93 of file debug.h.

◆ dBreak

#define dBreak ( )
Value:
{ \
dLog("Breakpoint"); \
raise(SIGTRAP); \
}

Definition at line 39 of file debug.h.

◆ dBreakCount

#define dBreakCount (   x)
Value:
{ \
static int count = 0; \
if (++count == (x)) dBreak(); \
}
#define dBreak()
Definition: debug.h:39

Definition at line 48 of file debug.h.

◆ dBreakIf

#define dBreakIf (   x)
Value:
{ \
if (x) { dBreak(); } \
}

Definition at line 44 of file debug.h.

◆ dLog

#define dLog (   ...)
Value:
{ \
dLog_pre(); \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, "\n"); \
}

Definition at line 33 of file debug.h.

◆ DLOG_BASENAME_ONLY

#define DLOG_BASENAME_ONLY   1

Definition at line 20 of file debug.h.

◆ dLog_pre

#define dLog_pre ( )    fprintf(stderr, "[%s:%i:%s] ", basename(__FILE__), __LINE__, __func__)

Definition at line 28 of file debug.h.

◆ FTRACE

#define FTRACE (   ...)
Value:
do { \
FTRACE_PRE(); \
PRINTARGS(__VA_ARGS__); \
printf(");\n"); \
} while (0)

Definition at line 226 of file debug.h.

◆ FTRACE_PRE

#define FTRACE_PRE ( )    printf("%s%s(", classScopeFromPrettyFunc(__PRETTY_FUNCTION__).c_str(), __func__)

Definition at line 225 of file debug.h.

◆ NARG

#define NARG (   ...)    NARG_(__VA_ARGS__, RSEQ_N())

Definition at line 91 of file debug.h.

◆ NARG_

#define NARG_ (   ...)    ARG_N(__VA_ARGS__)

Definition at line 92 of file debug.h.

◆ PERF_TIMER_DELTA

#define PERF_TIMER_DELTA   ((PERF_TIMER_T2.tv_usec - PERF_TIMER_T1.tv_usec) / 1000000.0 + (double)(PERF_TIMER_T2.tv_sec - PERF_TIMER_T1.tv_sec))

Definition at line 64 of file debug.h.

◆ PERF_TIMER_START

#define PERF_TIMER_START
Value:
struct timeval PERF_TIMER_T1, PERF_TIMER_T2; \
gettimeofday(&PERF_TIMER_T1, NULL);

Definition at line 60 of file debug.h.

◆ PERF_TIMER_STOP

#define PERF_TIMER_STOP   gettimeofday(&PERF_TIMER_T2, NULL);

Definition at line 63 of file debug.h.

◆ PRINT_BACKTRACE

#define PRINT_BACKTRACE (   ...)
Value:
{ \
printf("------------------ %s", __func__); \
printf(__VA_ARGS__); \
printf(" ------------------\n"); \
void **buffer = (void **)malloc(sizeof(void *) * 32); \
int depth = backtrace(buffer, 32); \
fflush(stdout); \
backtrace_symbols_fd(buffer, depth, fileno(stdout)); \
free(buffer); \
}

Definition at line 71 of file debug.h.

◆ PRINTARGS

#define PRINTARGS (   ...)    _PRINTARGS(NARG(__VA_ARGS__), __VA_ARGS__)

Definition at line 224 of file debug.h.

◆ PRINTARGS_1

#define PRINTARGS_1 (   x,
  ... 
)
Value:
{ \
PRINTARG(x); \
}

Definition at line 169 of file debug.h.

◆ PRINTARGS_2

#define PRINTARGS_2 (   x,
  ... 
)
Value:
{ \
PRINTARG(x); \
printf(", "); \
PRINTARGS_1(__VA_ARGS__); \
}

Definition at line 173 of file debug.h.

◆ PRINTARGS_3

#define PRINTARGS_3 (   x,
  ... 
)
Value:
{ \
PRINTARG(x); \
printf(", "); \
PRINTARGS_2(__VA_ARGS__); \
}

Definition at line 179 of file debug.h.

◆ PRINTARGS_4

#define PRINTARGS_4 (   x,
  ... 
)
Value:
{ \
PRINTARG(x); \
printf(", "); \
PRINTARGS_3(__VA_ARGS__); \
}

Definition at line 185 of file debug.h.

◆ PRINTARGS_5

#define PRINTARGS_5 (   x,
  ... 
)
Value:
{ \
PRINTARG(x); \
printf(", "); \
PRINTARGS_4(__VA_ARGS__); \
}

Definition at line 191 of file debug.h.

◆ PRINTARGS_6

#define PRINTARGS_6 (   x,
  ... 
)
Value:
{ \
PRINTARG(x); \
printf(", "); \
PRINTARGS_5(__VA_ARGS__); \
}

Definition at line 197 of file debug.h.

◆ PRINTARGS_7

#define PRINTARGS_7 (   x,
  ... 
)
Value:
{ \
PRINTARG(x); \
printf(", "); \
PRINTARGS_6(__VA_ARGS__); \
}

Definition at line 203 of file debug.h.

◆ PRINTARGS_8

#define PRINTARGS_8 (   x,
  ... 
)
Value:
{ \
PRINTARG(x); \
printf(", "); \
PRINTARGS_7(__VA_ARGS__); \
}

Definition at line 209 of file debug.h.

◆ PRINTARGS_9

#define PRINTARGS_9 (   x,
  ... 
)
Value:
{ \
PRINTARG(x); \
printf(", "); \
PRINTARGS_8(__VA_ARGS__); \
}

Definition at line 215 of file debug.h.

◆ RSEQ_N

#define RSEQ_N ( )    9, 8, 7, 6, 5, 4, 3, 2, 1, 0

Definition at line 94 of file debug.h.

◆ VDC_LIBTRACE

#define VDC_LIBTRACE

Definition at line 87 of file debug.h.

Function Documentation

◆ classScopeFromPrettyFunc()

std::string classScopeFromPrettyFunc ( const std::string &  pretty)
inline

Definition at line 157 of file debug.h.

◆ PRINTARG() [1/16]

void PRINTARG ( )
inline

Definition at line 96 of file debug.h.

Referenced by PRINTARG().

◆ PRINTARG() [2/16]

void PRINTARG ( bool  x)
inline

Definition at line 102 of file debug.h.

◆ PRINTARG() [3/16]

void PRINTARG ( const char *  x)
inline

Definition at line 104 of file debug.h.

◆ PRINTARG() [4/16]

void PRINTARG ( const double *  d)
inline

Definition at line 114 of file debug.h.

◆ PRINTARG() [5/16]

void PRINTARG ( const float *  f)
inline

Definition at line 113 of file debug.h.

◆ PRINTARG() [6/16]

void PRINTARG ( const int *  i)
inline

Definition at line 112 of file debug.h.

◆ PRINTARG() [7/16]

void PRINTARG ( const long *  li)
inline

Definition at line 116 of file debug.h.

◆ PRINTARG() [8/16]

void PRINTARG ( const size_t *  li)
inline

Definition at line 115 of file debug.h.

◆ PRINTARG() [9/16]

void PRINTARG ( const std::string  x)
inline

Definition at line 103 of file debug.h.

◆ PRINTARG() [10/16]

template<class T >
void PRINTARG ( const std::vector< T >  v)

Definition at line 133 of file debug.h.

References PRINTARG().

◆ PRINTARG() [11/16]

void PRINTARG ( const void *  x)
inline

Definition at line 118 of file debug.h.

◆ PRINTARG() [12/16]

void PRINTARG ( double  x)
inline

Definition at line 101 of file debug.h.

◆ PRINTARG() [13/16]

void PRINTARG ( float  x)
inline

Definition at line 100 of file debug.h.

◆ PRINTARG() [14/16]

void PRINTARG ( int  x)
inline

Definition at line 97 of file debug.h.

◆ PRINTARG() [15/16]

void PRINTARG ( long  x)
inline

Definition at line 98 of file debug.h.

◆ PRINTARG() [16/16]

void PRINTARG ( size_t  x)
inline

Definition at line 99 of file debug.h.