Helper Reference Manual  1.7.1
ODPH DEBUG

API Description

Debug logging.

Macros

#define ODPH_LOG(level, fmt, ...)
 Output a log with file, line and function information. More...
 
#define ODPH_ASSERT(cond)
 Runtime assertion macro. More...
 
#define ODPH_DBG(...)
 Debug log macro. More...
 
#define ODPH_ERR(...)
 Error log macro. More...
 
#define ODPH_ABORT(...)
 Abort macro. More...
 

Typedefs

typedef enum odph_log_level odph_log_level_e
 Log level.
 

Enumerations

enum  odph_log_level { ODPH_LOG_DBG , ODPH_LOG_ERR , ODPH_LOG_ABORT }
 Log level.
 

Macro Definition Documentation

◆ ODPH_LOG

#define ODPH_LOG (   level,
  fmt,
  ... 
)
Value:
do { \
if (level != ODPH_LOG_DBG || ODPH_DEBUG_PRINT == 1) { \
const odp_log_func_t fn = odp_log_fn_get(); \
if (fn) { \
const odp_log_level_t lv = level == ODPH_LOG_ABORT ? ODP_LOG_ABORT : \
level == ODPH_LOG_ERR ? ODP_LOG_ERR : \
ODP_LOG_DBG; \
fn(lv, "%s:%d:%s(): " fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
} else { \
fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, __LINE__, __func__, \
##__VA_ARGS__); \
} \
} \
if (level == ODPH_LOG_ABORT) { \
odp_abort_func_t fn = odp_abort_fn_get(); \
if (fn) \
fn(); \
else \
abort(); \
} \
} while (0)

Output a log with file, line and function information.

Outputs a log if level is not ODPH_LOG_DBG, or if ODPH_DEBUG_PRINT is enabled (–enable-helper-debug-print configure option). Calls odp_log_fn_get() to get the current log function. If no log function is set, prints to stderr.

Additionally, if level is ODPH_LOG_ABORT, calls odp_abort_fn_get() to get the current abort function and calls it to abort the application. If no abort function is set, calls abort().

Definition at line 57 of file debug.h.

◆ ODPH_ASSERT

#define ODPH_ASSERT (   cond)
Value:
do { \
if ((ODPH_DEBUG == 1) && (!(cond))) \
ODPH_LOG(ODPH_LOG_ABORT, "%s\n", #cond); \
} while (0)

Runtime assertion macro.

No code is generated when ODPH_DEBUG=0. Prints error message and aborts when ODPH_DEBUG=1 (–enable-helper-debug configure option) and 'cond' is false.

Definition at line 85 of file debug.h.

◆ ODPH_DBG

#define ODPH_DBG (   ...)
Value:
do { \
__extension__ ({ \
ODPH_LOG(ODPH_LOG_DBG, ##__VA_ARGS__); \
}); \
} while (0)

Debug log macro.

Outputs a log with level ODPH_LOG_DBG. See ODPH_LOG() for more information.

Definition at line 95 of file debug.h.

◆ ODPH_ERR

#define ODPH_ERR (   ...)
Value:
do { \
__extension__ ({ \
ODPH_LOG(ODPH_LOG_ERR, ##__VA_ARGS__); \
}); \
} while (0)

Error log macro.

Outputs a log with level ODPH_LOG_ERR. See ODPH_LOG() for more information.

Definition at line 106 of file debug.h.

◆ ODPH_ABORT

#define ODPH_ABORT (   ...)
Value:
do { \
__extension__ ({ \
ODPH_LOG(ODPH_LOG_ABORT, ##__VA_ARGS__); \
}); \
} while (0)

Abort macro.

Outputs a log with level ODPH_LOG_ABORT and aborts the application. See ODPH_LOG() for more information.

Definition at line 117 of file debug.h.