mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-17 00:44:33 +00:00
REORG: include: move the BUG_ON() code to haproxy/bug.h
This one used to be stored into debug.h but the debug tools got larger and require a lot of other includes, which can't use BUG_ON() anymore because of this. It does not make sense and instead this macro should be placed into the lower includes and given its omnipresence, the best solution is to create a new bug.h with the few surrounding macros needed to trigger bugs and place assertions anywhere. Another benefit is that it won't be required to add include <debug.h> anymore to use BUG_ON, it will automatically be covered by api.h. No less than 32 occurrences were dropped. The FSM_PRINTF macro was dropped since not used at all anymore (probably since 1.6 or so).
This commit is contained in:
parent
eb6f701b99
commit
58017eef3f
@ -28,11 +28,9 @@
|
||||
#ifndef _COMMON_BUF_H
|
||||
#define _COMMON_BUF_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <common/debug.h>
|
||||
#include <haproxy/api.h>
|
||||
|
||||
/* Structure defining a buffer's head */
|
||||
struct buffer {
|
||||
|
@ -25,49 +25,6 @@
|
||||
#include <haproxy/api.h>
|
||||
#include <common/memory.h>
|
||||
|
||||
#ifdef DEBUG_FULL
|
||||
#define DPRINTF(x...) fprintf(x)
|
||||
#else
|
||||
#define DPRINTF(x...)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_FSM
|
||||
#define FSM_PRINTF(x...) fprintf(x)
|
||||
#else
|
||||
#define FSM_PRINTF(x...)
|
||||
#endif
|
||||
|
||||
/* This abort is 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)
|
||||
|
||||
/* BUG_ON: complains if <cond> is true when DEBUG_STRICT or DEBUG_STRICT_NOCRASH
|
||||
* are set, does nothing otherwise. With DEBUG_STRICT in addition it immediately
|
||||
* crashes using ABORT_NOW() above.
|
||||
*/
|
||||
#if defined(DEBUG_STRICT) || defined(DEBUG_STRICT_NOCRASH)
|
||||
#if defined(DEBUG_STRICT)
|
||||
#define CRASH_NOW() ABORT_NOW()
|
||||
#else
|
||||
#define CRASH_NOW()
|
||||
#endif
|
||||
|
||||
#define BUG_ON(cond) _BUG_ON(cond, __FILE__, __LINE__)
|
||||
#define _BUG_ON(cond, file, line) __BUG_ON(cond, file, line)
|
||||
#define __BUG_ON(cond, file, line) \
|
||||
do { \
|
||||
if (unlikely(cond)) { \
|
||||
const char msg[] = "\nFATAL: bug condition \"" #cond "\" matched at " file ":" #line "\n"; \
|
||||
DISGUISE(write(2, msg, strlen(msg))); \
|
||||
CRASH_NOW(); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#undef CRASH_NOW
|
||||
#define BUG_ON(cond)
|
||||
#endif
|
||||
|
||||
struct task;
|
||||
struct buffer;
|
||||
extern volatile unsigned long threads_to_dump;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#ifndef _HAPROXY_BASE_H
|
||||
#define _HAPROXY_BASE_H
|
||||
|
||||
#include <haproxy/bug.h>
|
||||
#include <haproxy/initcall.h>
|
||||
#include <haproxy/api-t.h>
|
||||
|
||||
|
78
include/haproxy/bug.h
Normal file
78
include/haproxy/bug.h
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* include/haproxy/bug.h
|
||||
* Assertions and instant crash macros needed everywhere.
|
||||
*
|
||||
* Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _HAPROXY_BUG_H
|
||||
#define _HAPROXY_BUG_H
|
||||
|
||||
#include <haproxy/compiler.h>
|
||||
|
||||
/* quick debugging hack, should really be removed ASAP */
|
||||
#ifdef DEBUG_FULL
|
||||
#define DPRINTF(x...) fprintf(x)
|
||||
#else
|
||||
#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.
|
||||
*/
|
||||
#define ABORT_NOW() (*(volatile int*)1=0)
|
||||
|
||||
/* BUG_ON: complains if <cond> is true when DEBUG_STRICT or DEBUG_STRICT_NOCRASH
|
||||
* are set, does nothing otherwise. With DEBUG_STRICT in addition it immediately
|
||||
* crashes using ABORT_NOW() above.
|
||||
*/
|
||||
#if defined(DEBUG_STRICT) || defined(DEBUG_STRICT_NOCRASH)
|
||||
#if defined(DEBUG_STRICT)
|
||||
#define CRASH_NOW() ABORT_NOW()
|
||||
#else
|
||||
#define CRASH_NOW()
|
||||
#endif
|
||||
|
||||
#define BUG_ON(cond) _BUG_ON(cond, __FILE__, __LINE__)
|
||||
#define _BUG_ON(cond, file, line) __BUG_ON(cond, file, line)
|
||||
#define __BUG_ON(cond, file, line) \
|
||||
do { \
|
||||
if (unlikely(cond)) { \
|
||||
const char msg[] = "\nFATAL: bug condition \"" #cond "\" matched at " file ":" #line "\n"; \
|
||||
DISGUISE(write(2, msg, __builtin_strlen(msg))); \
|
||||
CRASH_NOW(); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#undef CRASH_NOW
|
||||
#define BUG_ON(cond)
|
||||
#endif
|
||||
|
||||
#endif /* _HAPROXY_BUG_H */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* End:
|
||||
*/
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <common/buffer.h>
|
||||
#include <common/debug.h>
|
||||
#include <common/memory.h>
|
||||
|
||||
#include <types/global.h>
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <common/buffer.h>
|
||||
#include <common/debug.h>
|
||||
#include <haproxy/hash.h>
|
||||
#include <common/htx.h>
|
||||
#include <common/ticks.h>
|
||||
|
@ -28,7 +28,6 @@
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <common/cfgparse.h>
|
||||
#include <common/debug.h>
|
||||
#include <common/memory.h>
|
||||
#include <common/mini-clist.h>
|
||||
#include <common/standard.h>
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include <proto/sample.h>
|
||||
#include <proto/ssl_sock.h>
|
||||
|
||||
#include <common/debug.h>
|
||||
|
||||
DECLARE_POOL(pool_head_connection, "connection", sizeof(struct connection));
|
||||
DECLARE_POOL(pool_head_connstream, "conn_stream", sizeof(struct conn_stream));
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <common/debug.h>
|
||||
#include <common/hathreads.h>
|
||||
#include <common/standard.h>
|
||||
#include <common/ticks.h>
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <common/buffer.h>
|
||||
#include <common/debug.h>
|
||||
#include <common/cfgparse.h>
|
||||
#include <haproxy/errors.h>
|
||||
#include <common/htx.h>
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <common/cfgparse.h>
|
||||
#include <common/debug.h>
|
||||
#include <common/hathreads.h>
|
||||
#include <common/memory.h>
|
||||
#include <common/time.h>
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <common/chunk.h>
|
||||
#include <common/debug.h>
|
||||
#include <common/standard.h>
|
||||
#include <common/time.h>
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
*/
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <common/debug.h>
|
||||
#include <common/cfgparse.h>
|
||||
#include <common/h1.h>
|
||||
#include <common/http.h>
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <common/chunk.h>
|
||||
#include <common/debug.h>
|
||||
#include <common/http.h>
|
||||
#include <common/memory.h>
|
||||
#include <common/standard.h>
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include <haproxy/api.h>
|
||||
#include <common/cfgparse.h>
|
||||
#include <common/chunk.h>
|
||||
#include <common/debug.h>
|
||||
#include <common/http.h>
|
||||
#include <common/memory.h>
|
||||
#include <common/standard.h>
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <haproxy/base64.h>
|
||||
#include <common/debug.h>
|
||||
#include <common/htx.h>
|
||||
#include <common/net_helper.h>
|
||||
#include <common/uri_auth.h>
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <common/chunk.h>
|
||||
#include <common/debug.h>
|
||||
#include <common/http.h>
|
||||
#include <common/memory.h>
|
||||
#include <common/standard.h>
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include <haproxy/api.h>
|
||||
#include <haproxy/base64.h>
|
||||
#include <common/chunk.h>
|
||||
#include <common/debug.h>
|
||||
#include <common/h1.h>
|
||||
#include <common/http.h>
|
||||
#include <common/htx.h>
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include <haproxy/api.h>
|
||||
#include <types/global.h>
|
||||
|
||||
#include <common/debug.h>
|
||||
#include <common/cfgparse.h>
|
||||
#include <common/h1.h>
|
||||
#include <common/http.h>
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include <haproxy/api.h>
|
||||
#include <common/cfgparse.h>
|
||||
#include <common/chunk.h>
|
||||
#include <common/debug.h>
|
||||
#include <common/http.h>
|
||||
#include <common/memory.h>
|
||||
#include <common/standard.h>
|
||||
|
@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <common/debug.h>
|
||||
#include <common/standard.h>
|
||||
#include <import/eb32tree.h>
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <common/debug.h>
|
||||
#include <import/eb32tree.h>
|
||||
|
||||
#include <types/global.h>
|
||||
|
@ -11,7 +11,6 @@
|
||||
*/
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <common/debug.h>
|
||||
#include <import/eb32tree.h>
|
||||
|
||||
#include <types/global.h>
|
||||
|
@ -11,7 +11,6 @@
|
||||
*/
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <common/debug.h>
|
||||
#include <import/eb32tree.h>
|
||||
|
||||
#include <types/global.h>
|
||||
|
@ -11,7 +11,6 @@
|
||||
*/
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <common/debug.h>
|
||||
#include <import/eb32tree.h>
|
||||
|
||||
#include <types/global.h>
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include <types/stats.h>
|
||||
|
||||
#include <common/cfgparse.h>
|
||||
#include <common/debug.h>
|
||||
#include <common/hathreads.h>
|
||||
#include <common/memory.h>
|
||||
#include <common/mini-clist.h>
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <common/debug.h>
|
||||
#include <haproxy/errors.h>
|
||||
#include <common/mini-clist.h>
|
||||
#include <common/standard.h>
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <common/debug.h>
|
||||
#include <haproxy/errors.h>
|
||||
#include <common/mini-clist.h>
|
||||
#include <common/standard.h>
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <common/debug.h>
|
||||
#include <haproxy/errors.h>
|
||||
#include <common/mini-clist.h>
|
||||
#include <common/standard.h>
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <common/buffer.h>
|
||||
#include <common/debug.h>
|
||||
#include <common/standard.h>
|
||||
#include <common/ticks.h>
|
||||
#include <common/time.h>
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <common/buffer.h>
|
||||
#include <common/debug.h>
|
||||
#include <common/http.h>
|
||||
#include <common/memory.h>
|
||||
|
||||
|
@ -46,7 +46,6 @@
|
||||
|
||||
#include <common/buffer.h>
|
||||
#include <common/chunk.h>
|
||||
#include <common/debug.h>
|
||||
#include <haproxy/errors.h>
|
||||
#include <haproxy/openssl-compat.h>
|
||||
#include <common/standard.h>
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include <haproxy/api.h>
|
||||
#include <common/cfgparse.h>
|
||||
#include <common/buffer.h>
|
||||
#include <common/debug.h>
|
||||
#include <common/hathreads.h>
|
||||
#include <common/htx.h>
|
||||
#include <common/memory.h>
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <common/buffer.h>
|
||||
#include <common/debug.h>
|
||||
#include <common/standard.h>
|
||||
#include <common/ticks.h>
|
||||
#include <common/time.h>
|
||||
|
@ -11,7 +11,6 @@
|
||||
*/
|
||||
#include <haproxy/api.h>
|
||||
#include <common/cfgparse.h>
|
||||
#include <common/debug.h>
|
||||
#include <common/mini-clist.h>
|
||||
#include <common/standard.h>
|
||||
#include <common/ticks.h>
|
||||
|
Loading…
Reference in New Issue
Block a user