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.
This commit is contained in:
Willy Tarreau 2025-04-14 17:32:10 +02:00
parent a8148c313a
commit 61d633a3ac
5 changed files with 11 additions and 6 deletions

View File

@ -263,7 +263,7 @@ endif
# DEBUG_NO_POOLS, DEBUG_FAIL_ALLOC, DEBUG_STRICT_ACTION=[0-3], DEBUG_HPACK, # 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_AUTH, DEBUG_SPOE, DEBUG_UAF, DEBUG_THREAD, DEBUG_STRICT, DEBUG_DEV,
# DEBUG_TASK, DEBUG_MEMORY_POOLS, DEBUG_POOL_TRACING, DEBUG_QPACK, DEBUG_LIST, # 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 = DEBUG =
#### Trace options #### Trace options

View File

@ -2001,7 +2001,7 @@ commit ssl crl-file <crlfile>
debug counters [reset|show|all|bug|chk|cnt|glt|?]* debug counters [reset|show|all|bug|chk|cnt|glt|?]*
List internal counters placed in the code, which may vary depending on some 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 The command takes a combination of multiple arguments, some defining actions
and others defining filters: and others defining filters:
- bug enables listing the counters for BUG_ON() statements - bug enables listing the counters for BUG_ON() statements

View File

@ -231,17 +231,17 @@ extern __attribute__((__weak__)) struct debug_count __stop_dbg_cnt HA_SECTION_S
1; /* let's return the true condition */ \ 1; /* let's return the true condition */ \
}) : 0) }) : 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 * condition is empty (nothing to write there), except maybe __VA_ARGS at the
* end. * end.
*/ */
# if !defined(DEBUG_GLITCHES) # if !defined(DEBUG_COUNTERS) || (DEBUG_COUNTERS == 0)
# define _COUNT_GLITCH(file, line, ...) do { } while (0) # define _COUNT_GLITCH(file, line, ...) do { } while (0)
# else # else
# define _COUNT_GLITCH(file, line, ...) do { \ # define _COUNT_GLITCH(file, line, ...) do { \
__DBG_COUNT(, file, line, DBG_GLITCH, __VA_ARGS__); \ __DBG_COUNT(, file, line, DBG_GLITCH, __VA_ARGS__); \
} while (0) } while (0)
# endif # endif
#else /* USE_OBSOLETE_LINKER not defined below */ #else /* USE_OBSOLETE_LINKER not defined below */
# define __DBG_COUNT(cond, file, line, type, ...) do { } while (0) # define __DBG_COUNT(cond, file, line, type, ...) do { } while (0)

View File

@ -594,6 +594,11 @@
# define DEBUG_STRICT 1 # define DEBUG_STRICT 1
#endif #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) #if !defined(DEBUG_MEMORY_POOLS)
# define DEBUG_MEMORY_POOLS 1 # define DEBUG_MEMORY_POOLS 1
#endif #endif

View File

@ -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"); 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->start = &__start_dbg_cnt;
ctx->stop = &__stop_dbg_cnt; ctx->stop = &__stop_dbg_cnt;
#endif #endif