From: Willy Tarreau Date: Mon, 14 Apr 2025 15:32:10 +0000 (+0200) Subject: DEBUG: rename DEBUG_GLITCHES to DEBUG_COUNTERS and enable it by default X-Git-Tag: v3.2-dev11~69 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=61d633a3ac821ee81bc2089b981508162be816ea;p=thirdparty%2Fhaproxy.git DEBUG: rename DEBUG_GLITCHES to DEBUG_COUNTERS and enable it by default Till now the per-line glitches counters were only enabled with the confusingly named DEBUG_GLITCHES (which would not turn glitches off when disabled). Let's instead change it to DEBUG_COUNTERS and make sure it's enabled by default (though it can still be disabled with -DDEBUG_GLITCHES=0 just like for DEBUG_STRICT). It will later be expanded to cover more counters. --- diff --git a/Makefile b/Makefile index 4b87a6a09..fee5a8952 100644 --- a/Makefile +++ b/Makefile @@ -263,7 +263,7 @@ endif # 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_GLITCHES, DEBUG_STRESS, DEBUG_UNIT. +# DEBUG_COUNTERS, DEBUG_STRESS, DEBUG_UNIT. DEBUG = #### Trace options diff --git a/doc/management.txt b/doc/management.txt index 56d6a882c..191c0c499 100644 --- a/doc/management.txt +++ b/doc/management.txt @@ -2001,7 +2001,7 @@ commit ssl crl-file debug counters [reset|show|all|bug|chk|cnt|glt|?]* List internal counters placed in the code, which may vary depending on some - build options. Some of them depend on DEBUG_STRICT, others on DEBUG_GLITCHES. + build options. Some of them depend on DEBUG_STRICT, others on DEBUG_COUNTERS. The command takes a combination of multiple arguments, some defining actions and others defining filters: - bug enables listing the counters for BUG_ON() statements diff --git a/include/haproxy/bug.h b/include/haproxy/bug.h index 47ac02565..a2c543826 100644 --- a/include/haproxy/bug.h +++ b/include/haproxy/bug.h @@ -231,17 +231,17 @@ extern __attribute__((__weak__)) struct debug_count __stop_dbg_cnt HA_SECTION_S 1; /* let's return the true condition */ \ }) : 0) -/* DEBUG_GLITCHES enables counting the number of glitches per line of code. The +/* 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 * end. */ -# if !defined(DEBUG_GLITCHES) +# if !defined(DEBUG_COUNTERS) || (DEBUG_COUNTERS == 0) # define _COUNT_GLITCH(file, line, ...) do { } while (0) # else # define _COUNT_GLITCH(file, line, ...) do { \ __DBG_COUNT(, file, line, DBG_GLITCH, __VA_ARGS__); \ } while (0) -# endif +# endif #else /* USE_OBSOLETE_LINKER not defined below */ # define __DBG_COUNT(cond, file, line, type, ...) do { } while (0) diff --git a/include/haproxy/defaults.h b/include/haproxy/defaults.h index eec78132b..c08b48e1d 100644 --- a/include/haproxy/defaults.h +++ b/include/haproxy/defaults.h @@ -594,6 +594,11 @@ # define DEBUG_STRICT 1 #endif +/* Let's make DEBUG_COUNTERS default to 1 to have glitches counters by default */ +#ifndef DEBUG_COUNTERS +# define DEBUG_COUNTERS 1 +#endif + #if !defined(DEBUG_MEMORY_POOLS) # define DEBUG_MEMORY_POOLS 1 #endif diff --git a/src/debug.c b/src/debug.c index c991f96cb..d3229e6b9 100644 --- a/src/debug.c +++ b/src/debug.c @@ -2282,7 +2282,7 @@ static int debug_parse_cli_counters(char **args, char *payload, struct appctx *a return cli_err(appctx, "Expects an optional action ('reset','show'), optional types ('bug','chk','cnt','glt') and optionally 'all' to even dump null counters.\n"); } -#if DEBUG_STRICT > 0 || defined(DEBUG_GLITCHES) +#if (DEBUG_STRICT > 0) || (DEBUG_COUNTERS > 0) ctx->start = &__start_dbg_cnt; ctx->stop = &__stop_dbg_cnt; #endif