|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH] lib/ukdebug: print DLVL_EXTRA messages only in debug build
At this point enabling LIBUKDEBUG_PRINTD_EXTRA does not help. You will
be drowned with the output.
Basically this became a real debug-level of message explicitness. So
let's use it for debug purposes.
With this patch, messages of DLVL_EXTRA will be printed ONLY if
UK_DEBUG is defined. Now a developer can chose for which parts of
Unikraft he wants an extra verbosity of the output, by adding a single
line into the Makefile.uk.
For example:
/* Enable for one lib */
LIBNAME_CFLAGS-y += -DUK_DEBUG
/* Enable globally in Unikraft (brace yourself) */
CFLAGS-y += -DUK_DEBUG
Signed-off-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx>
---
lib/ukdebug/Config.uk | 2 +-
lib/ukdebug/include/uk/hexdump.h | 2 +-
lib/ukdebug/include/uk/print.h | 16 ++++++++++++++--
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/lib/ukdebug/Config.uk b/lib/ukdebug/Config.uk
index dcaeb3a..ff6279c 100644
--- a/lib/ukdebug/Config.uk
+++ b/lib/ukdebug/Config.uk
@@ -24,7 +24,7 @@ choice
Set the level of detail of debug messages
config LIBUKDEBUG_PRINTD_EXTRA
- bool "Show all types of debug messages"
+ bool "Same as info + debug level messages (UK_DEBUG needs to be
defined)"
config LIBUKDEBUG_PRINTD_INFO
bool "Show critical, error, warning, and information messages"
diff --git a/lib/ukdebug/include/uk/hexdump.h b/lib/ukdebug/include/uk/hexdump.h
index 4d32647..927769d 100644
--- a/lib/ukdebug/include/uk/hexdump.h
+++ b/lib/ukdebug/include/uk/hexdump.h
@@ -92,7 +92,7 @@ void _uk_hexdumpd(int lvl, const char *libname, const char
*srcname,
*/
#define uk_hexdumpd(lvl, data, len, flags, grps_per_line)
\
do { \
- if ((lvl) <= DLVL_MAX) \
+ if (__ukdebug_is_printable_lvl(lvl)) \
_uk_hexdumpd((lvl), __STR_LIBNAME__, __STR_BASENAME__, \
__LINE__, (data), (len), \
((size_t)(data)), (flags), \
diff --git a/lib/ukdebug/include/uk/print.h b/lib/ukdebug/include/uk/print.h
index c5c5557..61e6bf6 100644
--- a/lib/ukdebug/include/uk/print.h
+++ b/lib/ukdebug/include/uk/print.h
@@ -120,16 +120,28 @@ void _uk_printd(int lvl, const char *libname, const char
*srcname,
#define __STR_BASENAME__ (NULL)
#endif
+#ifdef UK_DEBUG
+#define __uk_is_debug_lvl(lvl) (lvl <= DLVL_EXTRA)
+#else
+#define __uk_is_debug_lvl(lvl) (0)
+#endif
+
+#if defined(UK_DEBUG) && DLVL_MAX == DLVL_EXTRA
+#define __ukdebug_is_printable_lvl(lvl) (lvl <= DLVL_MAX)
+#else
+#define __ukdebug_is_printable_lvl(lvl) (lvl <= MIN(DLVL_MAX, DLVL_INFO))
+#endif
+
#define uk_vprintd(lvl, fmt, ap)
\
do { \
- if ((lvl) <= DLVL_MAX) \
+ if (__ukdebug_is_printable_lvl(lvl)) \
_uk_vprintd((lvl), __STR_LIBNAME__, __STR_BASENAME__, \
__LINE__, (fmt), ap); \
} while (0)
#define uk_printd(lvl, fmt, ...)
\
do { \
- if ((lvl) <= DLVL_MAX) \
+ if (__ukdebug_is_printable_lvl(lvl)) \
_uk_printd((lvl), __STR_LIBNAME__, __STR_BASENAME__, \
__LINE__, (fmt), ##__VA_ARGS__); \
} while (0)
--
2.17.1
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |