# DEBUG_NO_POOLS, DEBUG_FAIL_ALLOC, DEBUG_STRICT_ACTION=[0-3], DEBUG_HPACK,
# DEBUG_AUTH, DEBUG_SPOE, DEBUG_UAF, DEBUG_THREAD, DEBUG_STRICT, DEBUG_DEV,
# DEBUG_TASK, DEBUG_MEMORY_POOLS, DEBUG_POOL_TRACING, DEBUG_QPACK, DEBUG_LIST,
-# DEBUG_COUNTERS, DEBUG_STRESS, DEBUG_UNIT.
+# DEBUG_COUNTERS=[0-1], DEBUG_STRESS, DEBUG_UNIT.
DEBUG =
#### Trace options
_HA_ATOMIC_INC(&__dbg_cnt_##_line.count); \
} while (0)
+
+/* Matrix for DEBUG_COUNTERS:
+ * 0 : only BUG_ON() and CHECK_IF() are reported (super rare)
+ * 1 : COUNT_GLITCH() and COUNT_IF() are also reported (rare)
+ */
+
/* Core of the COUNT_IF() macro, checks the condition and counts one hit if
- * true.
+ * true. It's only enabled at DEBUG_COUNTERS >= 1.
*/
-#define _COUNT_IF(cond, file, line, ...) \
+# if defined(DEBUG_COUNTERS) && (DEBUG_COUNTERS >= 1)
+# define _COUNT_IF(cond, file, line, ...) \
(unlikely(cond) ? ({ \
__DBG_COUNT(cond, file, line, DBG_COUNT_IF, __VA_ARGS__); \
1; /* let's return the true condition */ \
}) : 0)
+# else
+# define _COUNT_IF(cond, file, line, ...) DISGUISE(unlikely(cond) ? 1 : 0)
+# endif
/* DEBUG_COUNTERS enables counting the number of glitches per line of code. The
* condition is empty (nothing to write there), except maybe __VA_ARGS at the
#else /* USE_OBSOLETE_LINKER not defined below */
# define __DBG_COUNT(cond, file, line, type, ...) do { } while (0)
-# define _COUNT_IF(cond, file, line, ...) DISGUISE(cond)
+# define _COUNT_IF(cond, file, line, ...) DISGUISE(unlikely(cond) ? 1 : 0)
# define _COUNT_GLITCH(file, line, ...) do { } while (0)
#endif