diff options
author | Michael Brown <mcb30@ipxe.org> | 2016-07-05 10:10:35 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2016-07-05 10:27:22 +0100 |
commit | e2c0a20d60cac7e29f8aa6ed8231338eb34e9736 (patch) | |
tree | 26f8d1b51b52f50e023a7b61b30a98d41844dd13 /src | |
parent | 55f7a675d61f8b83478e71d4f9efb3a1b789eb08 (diff) | |
download | ipxe-e2c0a20d60cac7e29f8aa6ed8231338eb34e9736.tar.gz |
[debug] Allow per-object runtime enabling/disabling of debug messages
The DBG_ENABLE() and DBG_DISABLE() macros currently affect the debug
level of all objects that were built with debugging enabled. This is
undesirable, since it is common to use different debug levels in each
object.
Make the debug level mask a per-object variable. DBG_ENABLE() and
DBG_DISABLE() now control only the debug level for the containing
object (which is consistent with the intended usage across the
existing codebase). DBG_ENABLE_OBJECT() and DBG_DISABLE_OBJECT() may
be used to control the debug level for a specified object. For
example:
// Enable DBG() messages from tcpip.c
DBG_ENABLE_OBJECT ( tcpip, DBGLVL_LOG );
Note that the existence of debug messages continues to be gated by the
DEBUG=... list specified on the build command line. If an object was
built without the relevant debug level, then DBG_ENABLE_OBJECT() will
have no effect on that object at runtime (other than to explicitly
drag in the object via a symbol reference).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/include/compiler.h | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/include/compiler.h b/src/include/compiler.h index 32afb64cf..eae62c518 100644 --- a/src/include/compiler.h +++ b/src/include/compiler.h @@ -285,14 +285,23 @@ extern void dbg_pause ( void ); extern void dbg_more ( void ); /* Allow for selective disabling of enabled debug levels */ +#define __debug_disable( object ) _C2 ( __debug_disable_, object ) +char __debug_disable(OBJECT); +#define DBG_DISABLE_OBJECT( object, level ) do { \ + extern char __debug_disable(object); \ + __debug_disable(object) |= (level); \ + } while ( 0 ) +#define DBG_ENABLE_OBJECT( object, level ) do { \ + extern char __debug_disable(object); \ + __debug_disable(object) &= ~(level); \ + } while ( 0 ) #if DBGLVL_MAX -int __debug_disable; -#define DBGLVL ( DBGLVL_MAX & ~__debug_disable ) +#define DBGLVL ( DBGLVL_MAX & ~__debug_disable(OBJECT) ) #define DBG_DISABLE( level ) do { \ - __debug_disable |= (level); \ + __debug_disable(OBJECT) |= ( (level) & DBGLVL_MAX ); \ } while ( 0 ) #define DBG_ENABLE( level ) do { \ - __debug_disable &= ~(level); \ + __debug_disable(OBJECT) &= ~( (level) & DBGLVL_MAX ); \ } while ( 0 ) #else #define DBGLVL 0 |