mirror of
https://github.com/ipxe/ipxe
synced 2026-02-12 21:29:39 +03:00
[compiler] Allow for selective disabling of debug levels at runtime
The usefulness of DBGLVL_IO is limited by the fact that many cards require large numbers of uninteresting I/O reads/writes at device probe time, typically when driving a bit-bashing I2C/SPI bus to read the MAC address. This patch adds the DBG_DISABLE() and DBG_ENABLE() macros, which can be used to temporarily disable and re-enable selected debug levels. Note that debug levels must still be enabled in the build in order to function at all: you can't use DBG_ENABLE(DBGLVL_IO) in an object built with DEBUG=object:1 and expect it to do anything.
This commit is contained in:
@@ -131,11 +131,26 @@ extern void dbg_decolourise ( void );
|
|||||||
extern void dbg_hex_dump_da ( unsigned long dispaddr,
|
extern void dbg_hex_dump_da ( unsigned long dispaddr,
|
||||||
const void *data, unsigned long len );
|
const void *data, unsigned long len );
|
||||||
|
|
||||||
/* Compatibility with existing Makefile */
|
|
||||||
#if DEBUG_SYMBOL
|
#if DEBUG_SYMBOL
|
||||||
#define DBGLVL DEBUG_SYMBOL
|
#define DBGLVL_MAX DEBUG_SYMBOL
|
||||||
|
#else
|
||||||
|
#define DBGLVL_MAX 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Allow for selective disabling of enabled debug levels */
|
||||||
|
#if DBGLVL_MAX
|
||||||
|
int __debug_disable;
|
||||||
|
#define DBGLVL ( DBGLVL_MAX & ~__debug_disable )
|
||||||
|
#define DBG_DISABLE( level ) do { \
|
||||||
|
__debug_disable |= ( (level) & DBGLVL_MAX ); \
|
||||||
|
} while ( 0 )
|
||||||
|
#define DBG_ENABLE( level ) do { \
|
||||||
|
__debug_disable &= ~( (level) & DBGLVL_MAX ); \
|
||||||
|
} while ( 0 )
|
||||||
#else
|
#else
|
||||||
#define DBGLVL 0
|
#define DBGLVL 0
|
||||||
|
#define DBG_DISABLE( level ) do { } while ( 0 )
|
||||||
|
#define DBG_ENABLE( level ) do { } while ( 0 )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DBGLVL_LOG 1
|
#define DBGLVL_LOG 1
|
||||||
|
|||||||
Reference in New Issue
Block a user