Browse Source

[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.
tags/v0.9.6
Michael Brown 15 years ago
parent
commit
afe1323c76
1 changed files with 17 additions and 2 deletions
  1. 17
    2
      src/include/compiler.h

+ 17
- 2
src/include/compiler.h View File

@@ -131,11 +131,26 @@ extern void dbg_decolourise ( void );
131 131
 extern void dbg_hex_dump_da ( unsigned long dispaddr,
132 132
 			      const void *data, unsigned long len );
133 133
 
134
-/* Compatibility with existing Makefile */
135 134
 #if DEBUG_SYMBOL
136
-#define DBGLVL DEBUG_SYMBOL
135
+#define DBGLVL_MAX DEBUG_SYMBOL
136
+#else
137
+#define DBGLVL_MAX 0
138
+#endif
139
+
140
+/* Allow for selective disabling of enabled debug levels */
141
+#if DBGLVL_MAX
142
+int __debug_disable;
143
+#define DBGLVL ( DBGLVL_MAX & ~__debug_disable )
144
+#define DBG_DISABLE( level ) do {				\
145
+	__debug_disable |= ( (level) & DBGLVL_MAX );		\
146
+	} while ( 0 )
147
+#define DBG_ENABLE( level ) do {				\
148
+	__debug_disable &= ~( (level) & DBGLVL_MAX );		\
149
+	} while ( 0 )
137 150
 #else
138 151
 #define DBGLVL 0
152
+#define DBG_DISABLE( level ) do { } while ( 0 )
153
+#define DBG_ENABLE( level ) do { } while ( 0 )
139 154
 #endif
140 155
 
141 156
 #define DBGLVL_LOG	1

Loading…
Cancel
Save