Defines | |
#define | cu_dlog_def(name,...) cuP_dlog_def(static, name, __VA_ARGS__) |
#define | cu_dlog_edef(name,...) cuP_dlog_def(, name, __VA_ARGS__) |
#define | cu_dlog_edec(name) extern struct cu_log_facility name##_debug_log |
#define | cu_dlogf(name,...) cuP_dlogf(name, __VA_ARGS__, NULL) |
#define | cu_debug_error(...) cu_bugf_fl(__FILE__, __LINE__, __VA_ARGS__) |
#define | cu_debug_assert(test) ((test)? (void)0 : (void)cu_debug_error("assertion '%s' failed", #test)) |
#define | cu_debug_assert_once() |
#define | cu_debug_unreachable() cu_bug_unreachable() |
#define | cu_check_arg(argnum, argname, test) ((void)0) |
Enumerations | |
enum | cu_debug_flags_t { cu_debug_flag_info = 1 << 0, cu_debug_show_alloc_flag = 1 << 1, cu_debug_soft_exit_flag = 1 << 2, cu_debug_show_collect_flag = 1 << 3, cu_debug_expensive_typing = 1 << 4 } |
Functions | |
void | cu_dtag_enable (char const *dtag) |
void | cu_dtag_disable (char const *dtag) |
cu_bool_t | cu_dtag_get (char const *dtag) |
cu_debug_flags_t | cu_debug_enable (cu_debug_flags_t) |
cu_debug_flags_t | cu_debug_disable (cu_debug_flags_t) |
cu_debug_flags_t | cu_debug_select (cu_debug_flags_t) |
void | cu_findent (FILE *fp, int i) |
void | cu_debug_abort (void) CU_ATTR_NORETURN |
void | cu_debug_trap (void) |
Variables | |
void(* | cuP_debug_bug_report )(const char *, int, const char *,...) |
#define cu_debug_assert | ( | test | ) | ((test)? (void)0 : (void)cu_debug_error("assertion '%s' failed", #test)) |
If debugging is enabled, evaluates test and aborts if zero.
#define cu_debug_assert_once | ( | ) |
do { \ static int cuL_cnt = 0; \ if (cuL_cnt++ != 0) \ cu_debug_error("This point should only have been reached once."); \ } while (0)
If a lexical instance of this statement is called more than once during the program lifetime, it aborts with an error message.
#define cu_debug_error | ( | ... | ) | cu_bugf_fl(__FILE__, __LINE__, __VA_ARGS__) |
If debugging is enabled, prints an error and aborts. To exit with an error independent of CU_NDEBUG
, use cu_bugf.
#define cu_debug_unreachable | ( | ) | cu_bug_unreachable() |
Asserts that the current line is unreachable. This is the same as cu_bug_unreachable except for being disabled if CU_NDEBUG
is defined.
#define cu_dlog_def | ( | name, | |||
... | ) | cuP_dlog_def(static, name, __VA_ARGS__) |
Emits a definition of a debug logger identified by name using static linkage. The additional arguments are strings which are used to enable the logger at program startup. The default log binder looks for strings of the form "dtag=FOO"
where FOO by convention is a period-separated qualified name used to identify the current source file or topic for debugging. Logging is only enabled for dtags listed in the file pointed to by $CU_DTAGS_PATH
.
#define cu_dlog_edec | ( | name | ) | extern struct cu_log_facility name##_debug_log |
Emits an extern declaration corresponding to a cu_dlog_edef.
#define cu_dlog_edef | ( | name, | |||
... | ) | cuP_dlog_def(, name, __VA_ARGS__) |
Emits a definition of a debug logger identified by name using extern linkage. See cu_dlog_def for details.
#define cu_dlogf | ( | name, | |||
... | ) | cuP_dlogf(name, __VA_ARGS__, NULL) |
Logs a message to the debug logger identified by name. The variadic arguments are similar to printf
.
void cu_dtag_disable | ( | char const * | dtag | ) |
Disable the debug tag dtag. The same notice as for cu_dtag_enable applies.
void cu_dtag_enable | ( | char const * | dtag | ) |
Enable the debug tag dtag. This must be called at program initialisation, before the log facilities which triggers on dtag are used. It highly preferable to to let cu_init() load the tags automatically as described in cu_dlog_def.
cu_bool_t cu_dtag_get | ( | char const * | dtag | ) |
Queries whether the debug tag dtag is enabled. Also condition the code on #ifndef CU_NDEBUG for efficiency.