From 4a034f22123a378763a15fe0374bebfdcb9e7d53 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Sat, 12 Sep 2020 11:24:48 +0500 Subject: [PATCH] BUILD: introduce possibility to define ABORT_NOW() conditionally code analysis tools recognize abort() better, so let us introduce such possibility --- Makefile | 1 + include/haproxy/bug.h | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 48c595511..c0645093c 100644 --- a/Makefile +++ b/Makefile @@ -106,6 +106,7 @@ # SUBVERS : add a sub-version (eg: platform, model, ...). # VERDATE : force haproxy's release date. # VTEST_PROGRAM : location of the vtest program to run reg-tests. +# DEBUG_USE_ABORT: use abort() for program termination, see include/haproxy/bug.h for details # verbosity: pass V=1 for verbose shell invocation V = 0 diff --git a/include/haproxy/bug.h b/include/haproxy/bug.h index a008126f5..ad2018b13 100644 --- a/include/haproxy/bug.h +++ b/include/haproxy/bug.h @@ -37,10 +37,15 @@ #define DPRINTF(x...) #endif -/* This abort is more efficient than abort() because it does not mangle the - * stack and stops at the exact location we need. - */ +#ifdef DEBUG_USE_ABORT +/* abort() is better recognized by code analysis tools */ +#define ABORT_NOW() abort() +#else +/* More efficient than abort() because it does not mangle the + * stack and stops at the exact location we need. + */ #define ABORT_NOW() (*(volatile int*)1=0) +#endif /* BUG_ON: complains if is true when DEBUG_STRICT or DEBUG_STRICT_NOCRASH * are set, does nothing otherwise. With DEBUG_STRICT in addition it immediately