diff options
author | Brian Behlendorf <[email protected]> | 2012-01-20 16:39:12 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2012-02-02 11:27:54 -0800 |
commit | 4b2220f0b937018b79154ac368c845e6176a8a66 (patch) | |
tree | 07877c960d2d94a913e8d38c0421e21bacb3592c /include | |
parent | 3c6ed5410beb7a4f9e0c042229eb63c4c11a5fc9 (diff) |
Add --enable-debug-log configure option
Until now the notion of an internal debug logging infrastructure
was conflated with enabling ASSERT()s. This patch clarifies things
by cleanly breaking the two subsystem apart. The result of this
is the following behavior.
--enable-debug - Enable/disable code wrapped in ASSERT()s.
--disable-debug ASSERT()s are used to check invariants and
are never required for correct operation.
They are disabled by default because they
may impact performance.
--enable-debug-log - Enable/disable the debug log infrastructure.
--disable-debug-log This infrastructure allows the spl code and
its consumer to log messages to an in-kernel
log. The granularity of the logging can be
controlled by a debug mask. By default the
mask disables most debug messages resulting
in a negligible performance impact. Because
of this the debug log is enabled by default.
Signed-off-by: Brian Behlendorf <[email protected]>
Diffstat (limited to 'include')
-rw-r--r-- | include/spl-debug.h | 56 | ||||
-rw-r--r-- | include/sys/debug.h | 7 |
2 files changed, 41 insertions, 22 deletions
diff --git a/include/spl-debug.h b/include/spl-debug.h index 1e08e77bc..98164966c 100644 --- a/include/spl-debug.h +++ b/include/spl-debug.h @@ -43,6 +43,7 @@ #define _SPL_DEBUG_INTERNAL_H #include <linux/limits.h> +#include <linux/sched.h> #define SS_UNDEFINED 0x00000001 #define SS_ATOMIC 0x00000002 @@ -86,21 +87,8 @@ #define SD_OTHER 0x00000100 #define SD_CANTMASK (SD_ERROR | SD_EMERG | SD_WARNING | SD_CONSOLE) -#ifdef NDEBUG /* Debugging Disabled */ - -#define SDEBUG(mask, fmt, a...) ((void)0) -#define SDEBUG_LIMIT(x, y, fmt, a...) ((void)0) -#define SWARN(fmt, a...) ((void)0) -#define SERROR(fmt, a...) ((void)0) -#define SEMERG(fmt, a...) ((void)0) -#define SCONSOLE(mask, fmt, a...) ((void)0) - -#define SENTRY ((void)0) -#define SEXIT ((void)0) -#define SRETURN(x) return (x) -#define SGOTO(x, y) { ((void)(y)); goto x; } - -#else /* Debugging Enabled */ +/* Debug log support enabled */ +#ifdef DEBUG_LOG #define __SDEBUG(cdls, subsys, mask, format, a...) \ do { \ @@ -149,8 +137,6 @@ do { \ goto label; \ } while (0) -#endif /* NDEBUG */ - typedef struct { unsigned long cdls_next; int cdls_count; @@ -183,10 +169,46 @@ extern int spl_debug_set_mb(int mb); extern int spl_debug_get_mb(void); extern int spl_debug_dumplog(int flags); extern void spl_debug_dumpstack(struct task_struct *tsk); +extern void spl_debug_bug(char *file, const char *fn, const int line, int fl); +extern int spl_debug_msg(void *arg, int subsys, int mask, const char *file, + const char *fn, const int line, const char *format, ...); extern int spl_debug_clear_buffer(void); extern int spl_debug_mark_buffer(char *text); int spl_debug_init(void); void spl_debug_fini(void); +/* Debug log support disabled */ +#else /* DEBUG_LOG */ + +#define SDEBUG(mask, fmt, a...) ((void)0) +#define SDEBUG_LIMIT(x, y, fmt, a...) ((void)0) +#define SWARN(fmt, a...) ((void)0) +#define SERROR(fmt, a...) ((void)0) +#define SEMERG(fmt, a...) ((void)0) +#define SCONSOLE(mask, fmt, a...) ((void)0) + +#define SENTRY ((void)0) +#define SEXIT ((void)0) +#define SRETURN(x) return (x) +#define SGOTO(x, y) { ((void)(y)); goto x; } + +static inline int spl_debug_init(void) { return (0); } +static inline void spl_debug_fini(void) { return; } + +static inline void +spl_debug_bug(char *file, const char *fn, const int line, int fl) +{ + return; +} + +static inline int +spl_debug_msg(void *arg, int subsys, int mask, const char *file, + const char *fn, const int line, const char *format, ...) +{ + return (0); +} + +#endif /* DEBUG_LOG */ + #endif /* SPL_DEBUG_INTERNAL_H */ diff --git a/include/sys/debug.h b/include/sys/debug.h index fbf15143f..271dbc210 100644 --- a/include/sys/debug.h +++ b/include/sys/debug.h @@ -44,6 +44,8 @@ #ifndef _SPL_DEBUG_H #define _SPL_DEBUG_H +#include <spl-debug.h> + #ifdef NDEBUG /* Debugging Disabled */ /* Define SPL_DEBUG_STR to make clear which ASSERT definitions are used */ @@ -137,9 +139,4 @@ do { \ #define VERIFY(x) ASSERT(x) #endif /* NDEBUG */ - -extern void spl_debug_bug(char *file, const char *fn, const int line, int fl); -extern int spl_debug_msg(void *arg, int subsys, int mask, const char *file, - const char *fn, const int line, const char *format, ...); - #endif /* SPL_DEBUG_H */ |