]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: debug: add match counters for BUG_ON/WARN_ON/CHECK_IF
authorWilly Tarreau <w@1wt.eu>
Mon, 21 Oct 2024 16:29:00 +0000 (18:29 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 21 Oct 2024 17:14:07 +0000 (19:14 +0200)
commit776fd03509cec5b8fe5a54aeac0370aabc15d313
tree984d952c5ef0361ff9eb1f329d47c9c67d52c53a
parent8844ed2009563d5976c42b6b2b7eb8f097344f25
MEDIUM: debug: add match counters for BUG_ON/WARN_ON/CHECK_IF

These macros do not always kill the process, and sometimes it would be
nice to know if some match or not, and how many times (especially for the
CHECK_IF one).

This commit adds a new section "dbg_cnt" made of structs that contain
function name, file name, line number, check type, condition and match
count. A newe macro __DBG_COUNT() adds one to the counter, and is placed
inside _BUG_ON() and _BUG_ON_ONCE(). It's worth noting that the exact
type of the check is not very precise but in practice we don't care,
as most checks will cause the process to die anyway unless they're of
type _BUG_ON_ONCE() (used by CHECK_IF by default).

All of this is limited to !defined(USE_OBSOLETE_LINKER) because we're
creating a section, thus we need a modern linker to be able to scan
this section later. Doing so adds ~50kB to the executable due to the
~1266 BUG_ON() and others placed there. That's not huge in comparison
to the visibility it can provide.
include/haproxy/bug.h