mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 22:31:28 +02:00
DEBUG: report BUG_ON() and WARN_ON() in the tainted flags
It can be useful to know from the "tainted" variable whether any WARN_ON() or BUG_ON() triggered. Both were now added.
This commit is contained in:
parent
4e0a8b1224
commit
897c861aea
@ -53,7 +53,9 @@
|
|||||||
/* This is the generic low-level macro dealing with conditional warnings and
|
/* This is the generic low-level macro dealing with conditional warnings and
|
||||||
* bugs. The caller decides whether to crash or not and what prefix and suffix
|
* bugs. The caller decides whether to crash or not and what prefix and suffix
|
||||||
* to pass. The macro returns the boolean value of the condition as an int for
|
* to pass. The macro returns the boolean value of the condition as an int for
|
||||||
* the case where it wouldn't die.
|
* the case where it wouldn't die. The <crash> flag is made of:
|
||||||
|
* - crash & 1: crash yes/no;
|
||||||
|
* - crash & 2: taint as bug instead of warn
|
||||||
*/
|
*/
|
||||||
#define _BUG_ON(cond, file, line, crash, pfx, sfx) \
|
#define _BUG_ON(cond, file, line, crash, pfx, sfx) \
|
||||||
__BUG_ON(cond, file, line, crash, pfx, sfx)
|
__BUG_ON(cond, file, line, crash, pfx, sfx)
|
||||||
@ -64,7 +66,11 @@
|
|||||||
if (unlikely(__bug_cond)) { \
|
if (unlikely(__bug_cond)) { \
|
||||||
const char msg[] = "\n" pfx "condition \"" #cond "\" matched at " file ":" #line "" sfx "\n"; \
|
const char msg[] = "\n" pfx "condition \"" #cond "\" matched at " file ":" #line "" sfx "\n"; \
|
||||||
DISGUISE(write(2, msg, __builtin_strlen(msg))); \
|
DISGUISE(write(2, msg, __builtin_strlen(msg))); \
|
||||||
if (crash) \
|
if (crash & 2) \
|
||||||
|
mark_tainted(TAINTED_BUG); \
|
||||||
|
else \
|
||||||
|
mark_tainted(TAINTED_WARN); \
|
||||||
|
if (crash & 1) \
|
||||||
ABORT_NOW(); \
|
ABORT_NOW(); \
|
||||||
else \
|
else \
|
||||||
DUMP_TRACE(); \
|
DUMP_TRACE(); \
|
||||||
@ -88,7 +94,11 @@
|
|||||||
!_HA_ATOMIC_FETCH_ADD(&__match_count_##line, 1)) { \
|
!_HA_ATOMIC_FETCH_ADD(&__match_count_##line, 1)) { \
|
||||||
const char msg[] = "\n" pfx "condition \"" #cond "\" matched at " file ":" #line "" sfx "\n"; \
|
const char msg[] = "\n" pfx "condition \"" #cond "\" matched at " file ":" #line "" sfx "\n"; \
|
||||||
DISGUISE(write(2, msg, __builtin_strlen(msg))); \
|
DISGUISE(write(2, msg, __builtin_strlen(msg))); \
|
||||||
if (crash) \
|
if (crash & 2) \
|
||||||
|
mark_tainted(TAINTED_BUG); \
|
||||||
|
else \
|
||||||
|
mark_tainted(TAINTED_WARN); \
|
||||||
|
if (crash & 1) \
|
||||||
ABORT_NOW(); \
|
ABORT_NOW(); \
|
||||||
else \
|
else \
|
||||||
DUMP_TRACE(); \
|
DUMP_TRACE(); \
|
||||||
@ -101,11 +111,11 @@
|
|||||||
* crashes using ABORT_NOW() above.
|
* crashes using ABORT_NOW() above.
|
||||||
*/
|
*/
|
||||||
#if defined(DEBUG_STRICT)
|
#if defined(DEBUG_STRICT)
|
||||||
#define BUG_ON(cond) _BUG_ON (cond, __FILE__, __LINE__, 1, "FATAL: bug ", "")
|
#define BUG_ON(cond) _BUG_ON (cond, __FILE__, __LINE__, 3, "FATAL: bug ", "")
|
||||||
#define WARN_ON(cond) _BUG_ON (cond, __FILE__, __LINE__, 0, "WARNING: ", " (please report to developers)")
|
#define WARN_ON(cond) _BUG_ON (cond, __FILE__, __LINE__, 0, "WARNING: ", " (please report to developers)")
|
||||||
#define WARN_ON_ONCE(cond) _BUG_ON_ONCE(cond, __FILE__, __LINE__, 0, "WARNING: ", " (please report to developers)")
|
#define WARN_ON_ONCE(cond) _BUG_ON_ONCE(cond, __FILE__, __LINE__, 0, "WARNING: ", " (please report to developers)")
|
||||||
#elif defined(DEBUG_STRICT_NOCRASH)
|
#elif defined(DEBUG_STRICT_NOCRASH)
|
||||||
#define BUG_ON(cond) _BUG_ON (cond, __FILE__, __LINE__, 0, "FATAL: bug ", " (not crashing but process is untrusted now)")
|
#define BUG_ON(cond) _BUG_ON (cond, __FILE__, __LINE__, 2, "FATAL: bug ", " (not crashing but process is untrusted now)")
|
||||||
#define WARN_ON(cond) _BUG_ON (cond, __FILE__, __LINE__, 0, "WARNING: ", " (please report to developers)")
|
#define WARN_ON(cond) _BUG_ON (cond, __FILE__, __LINE__, 0, "WARNING: ", " (please report to developers)")
|
||||||
#define WARN_ON_ONCE(cond) _BUG_ON_ONCE(cond, __FILE__, __LINE__, 0, "WARNING: ", " (please report to developers)")
|
#define WARN_ON_ONCE(cond) _BUG_ON_ONCE(cond, __FILE__, __LINE__, 0, "WARNING: ", " (please report to developers)")
|
||||||
#else
|
#else
|
||||||
@ -145,6 +155,8 @@ enum tainted_flags {
|
|||||||
TAINTED_ACTION_EXP_EXECUTED = 0x00000002,
|
TAINTED_ACTION_EXP_EXECUTED = 0x00000002,
|
||||||
TAINTED_CLI_EXPERT_MODE = 0x00000004,
|
TAINTED_CLI_EXPERT_MODE = 0x00000004,
|
||||||
TAINTED_CLI_EXPERIMENTAL_MODE = 0x00000008,
|
TAINTED_CLI_EXPERIMENTAL_MODE = 0x00000008,
|
||||||
|
TAINTED_WARN = 0x00000010, /* a WARN_ON triggered */
|
||||||
|
TAINTED_BUG = 0x00000020, /* a BUG_ON triggered */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* this is a bit field made of TAINTED_*, and is declared in haproxy.c */
|
/* this is a bit field made of TAINTED_*, and is declared in haproxy.c */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user