[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCH v2 08/10] lib/ukdebug: Swap uk_printk() and uk_printd()
Hi Sharan, Simon I think it does not make any difference if we use #if or #ifdef. From https://gcc.gnu.org/onlinedocs/cpp/If.html: "Identifiers that are not macros, which are all considered to be the number zero. This allows you to write #if MACRO instead of #ifdef MACRO, if you know that MACRO, when defined, will always have a nonzero value. Function-like macros used without their function call parentheses are also treated as zero." Even if we want to use ifdefs instead, that belongs to a separate patch, because this one is a mere swaping printk with printd. So I suggest we upstream this version if you don't mind. Reviewed-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx> Kind regards, Yuri. Sharan Santhanam <sharan.santhanam@xxxxxxxxx> writes: > Hello Simon, > > I am fine with this patch but there are minor comments inline. > > On 09/27/2018 02:41 PM, Simon Kuenzer wrote: >> Exchanges uk_printk() with uk_printd(). uk_printk gets a lvl parameter: >> uk_printk(lvl, fmt, ...) >> with having KLVL_INFO (former DLVL_INFO), KLVL_WARN (former >> DLVL_WARN), KLVL_ERR (KLVL_ERR), DLVL_CRIT (former KLVL_CRIT) as >> value for parameter `lvl`. >> >> uk_printd() implements former uk_printk(). Its purpose is to replace >> the previous DLVL_EXTRA level. Whenever `UK_DEBUG` is defined as macro >> while compiling a source file, uk_printd() statements are >> effective. libukdebug additionally provides a global flag to enable >> debug messages in all source files. >> uk_printd(fmt, ...) >> >> It seems to be more meaningful to redirect all messages to >> ukplat_coutk() as default configuration. The uk_pr_*() shortcut >> macros are updated to reflect this new scheme. >> >> Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx> >> --- >> lib/ukdebug/Config.uk | 52 ++++++++-------- >> lib/ukdebug/exportsyms.uk | 12 ++-- >> lib/ukdebug/hexdump.c | 43 ++++++------- >> lib/ukdebug/include/uk/hexdump.h | 40 ++++++------- >> lib/ukdebug/include/uk/print.h | 116 ++++++++++++++++------------------- >> lib/ukdebug/print.c | 126 >> +++++++++++++++++++-------------------- >> 6 files changed, 184 insertions(+), 205 deletions(-) >> >> diff --git a/lib/ukdebug/Config.uk b/lib/ukdebug/Config.uk >> index dcaeb3a..86e33e5 100644 >> --- a/lib/ukdebug/Config.uk >> +++ b/lib/ukdebug/Config.uk >> @@ -8,50 +8,49 @@ config LIBUKDEBUG_PRINTK >> bool "Enable kernel messages (uk_printk)" >> default y >> help >> - Build with debugging symbols enabled. >> - >> -config LIBUKDEBUG_PRINTD >> - bool "Enable debug messages (uk_printd)" >> - default y >> - help >> - Build with debugging symbols enabled. >> + Enables kernel message console. >> >> choice >> - prompt "Debug message level" >> - default LIBUKDEBUG_PRINTD_ERR >> - depends on LIBUKDEBUG_PRINTD >> + prompt "Kernel message level" >> + default LIBUKDEBUG_PRINTK_ERR >> + depends on LIBUKDEBUG_PRINTK >> help >> Set the level of detail of debug messages >> >> -config LIBUKDEBUG_PRINTD_EXTRA >> +config LIBUKDEBUG_PRINTK_INFO >> bool "Show all types of debug messages" >> >> -config LIBUKDEBUG_PRINTD_INFO >> - bool "Show critical, error, warning, and information messages" >> - >> -config LIBUKDEBUG_PRINTD_WARN >> +config LIBUKDEBUG_PRINTK_WARN >> bool "Show critical, error, and warning messages" >> >> -config LIBUKDEBUG_PRINTD_ERR >> - bool "Show critical, and error messages (default)" >> +config LIBUKDEBUG_PRINTK_ERR >> + bool "Show critical and error messages (default)" >> >> -config LIBUKDEBUG_PRINTD_CRIT >> +config LIBUKDEBUG_PRINTK_CRIT >> bool "Show critical messages only" >> endchoice >> >> -config LIBUKDEBUG_PRINTD_TIME >> - bool "Show timestamp in debug messages" >> +config LIBUKDEBUG_PRINTK_TIME >> + bool "Show timestamp in kernel messages" >> default y >> - depends on LIBUKDEBUG_PRINTD >> + depends on LIBUKDEBUG_PRINTK >> + >> +config LIBUKDEBUG_PRINTK_STACK >> + bool "Print bottom address of stack in kernel messages" >> + default n >> + depends on LIBUKDEBUG_PRINTK >> >> -config LIBUKDEBUG_PRINTD_STACK >> - bool "Print bottom address of stack in debug messages" >> +config LIBUKDEBUG_PRINTD >> + bool "Enable debug messages globally (uk_printd)" >> default n >> - depends on LIBUKDEBUG_PRINTD >> + help >> + Enables debug messages globally. Without this configuration, >> + debug messages can still be enabled for each compilation unit >> + individually. This happens as soon the UK_DEBUG macro is defined. >> >> choice >> prompt "Message redirection" >> - default LIBUKDEBUG_NOREDIR >> + default LIBUKDEBUG_REDIR_PRINTD >> depends on LIBUKDEBUG_PRINTD || LIBUKDEBUG_PRINTK >> help >> Output for uk_printk() and uk_printd() >> @@ -62,8 +61,7 @@ config LIBUKDEBUG_NOREDIR >> Keep debug and kernel output separated >> >> config LIBUKDEBUG_REDIR_PRINTD >> - bool "Debug messages on kernel output" >> - depends on LIBUKDEBUG_PRINTD >> + bool "Debug messages on kernel output (default)" >> help >> Debug message are redirected to standard kernel output >> >> diff --git a/lib/ukdebug/exportsyms.uk b/lib/ukdebug/exportsyms.uk >> index 27187d2..75a4869 100644 >> --- a/lib/ukdebug/exportsyms.uk >> +++ b/lib/ukdebug/exportsyms.uk >> @@ -1,8 +1,8 @@ >> -uk_vprintk >> -uk_printk >> -_uk_vprintd >> -_uk_printd >> +uk_vprintd >> +uk_printd >> +_uk_vprintk >> +_uk_printk >> uk_hexdumpsn >> uk_hexdumpf >> -uk_hexdumpk >> -_uk_hexdumpd >> +uk_hexdumpd >> +_uk_hexdumdk >> diff --git a/lib/ukdebug/hexdump.c b/lib/ukdebug/hexdump.c >> index a3d8e5f..cd70c73 100644 >> --- a/lib/ukdebug/hexdump.c >> +++ b/lib/ukdebug/hexdump.c >> @@ -54,22 +54,20 @@ enum _hxd_output_type { >> #if CONFIG_LIBUKDEBUG_PRINTK >> UK_HXDOUT_KERN, >> #endif >> -#if CONFIG_LIBUKDEBUG_PRINTD >> UK_HXDOUT_DEBUG, >> -#endif >> }; >> >> struct _hxd_output { >> enum _hxd_output_type type; >> >> union { > > Do we intend to use #ifdef instead of #if >> -#if CONFIG_LIBUKDEBUG_PRINTD >> +#if CONFIG_LIBUKDEBUG_PRINTK >> struct { >> int lvl; >> const char *libname; >> const char *srcname; >> unsigned int srcline; >> - } debug; >> + } kern; >> #endif >> struct { >> FILE *fp; >> @@ -106,15 +104,13 @@ static int _hxd_outf(struct _hxd_output *o, const char >> *fmt, ...) >> o->buffer.left -= (ret - 1); >> } >> break; >> + case UK_HXDOUT_DEBUG: >> + uk_vprintd(fmt, ap); >> + break; >> #if CONFIG_LIBUKDEBUG_PRINTK >> case UK_HXDOUT_KERN: >> - uk_vprintk(fmt, ap); >> - break; >> -#endif >> -#if CONFIG_LIBUKDEBUG_PRINTD >> - case UK_HXDOUT_DEBUG: >> - _uk_vprintd(o->debug.lvl, o->debug.libname, o->debug.srcname, >> - o->debug.srcline, fmt, ap); >> + _uk_vprintk(o->kern.lvl, o->kern.libname, o->kern.srcname, >> + o->kern.srcline, fmt, ap); >> break; >> #endif >> default: >> @@ -323,11 +319,11 @@ int uk_hexdumpf(FILE *fp, const void *data, size_t >> len, size_t addr0, int flags, >> return _hxd(&o, data, len, addr0, flags, grps_per_line, line_prefix); >> } >> >> -void uk_hexdumpk(const void *data, size_t len, int flags, >> +void uk_hexdumpd(const void *data, size_t len, int flags, >> unsigned int grps_per_line) >> { > > Do we intend to use #ifdef instead of #if >> -#if CONFIG_LIBUKDEBUG_PRINTK >> - struct _hxd_output o = {.type = UK_HXDOUT_KERN}; >> +#if CONFIG_LIBUKDEBUG_PRINTD >> + struct _hxd_output o = {.type = UK_HXDOUT_DEBUG}; >> >> _hxd(&o, data, len, (size_t)data, flags, grps_per_line, ""); >> #else >> @@ -335,19 +331,18 @@ void uk_hexdumpk(const void *data, size_t len, int >> flags, >> #endif >> } >> >> -void _uk_hexdumpd(int lvl, const char *libname, const char *srcname, > > Do we intend to use #ifdef instead of #if >> +#if CONFIG_LIBUKDEBUG_PRINTK >> +void _uk_hexdumpk(int lvl, const char *libname, const char *srcname, >> unsigned int srcline, const void *data, size_t len, >> size_t addr0, int flags, unsigned int grps_per_line, >> const char *line_prefix) >> { >> -#if CONFIG_LIBUKDEBUG_PRINTD >> - struct _hxd_output o = {.type = UK_HXDOUT_DEBUG, >> - .debug.lvl = lvl, >> - .debug.libname = libname, >> - .debug.srcname = srcname, >> - .debug.srcline = srcline}; >> + struct _hxd_output o = {.type = UK_HXDOUT_KERN, >> + .kern.lvl = lvl, >> + .kern.libname = libname, >> + .kern.srcname = srcname, >> + .kern.srcline = srcline}; >> + >> _hxd(&o, data, len, addr0, flags, grps_per_line, line_prefix); >> -#else >> - return; >> -#endif >> } >> +#endif >> diff --git a/lib/ukdebug/include/uk/hexdump.h >> b/lib/ukdebug/include/uk/hexdump.h >> index 5539eed..c77742c 100644 >> --- a/lib/ukdebug/include/uk/hexdump.h >> +++ b/lib/ukdebug/include/uk/hexdump.h >> @@ -55,9 +55,9 @@ extern "C" { >> >> #define UK_HXDF_COMPRESS (64) /* suppress repeated lines */ >> > > Do we intend to use #ifdef instead of #if >> -#if CONFIG_LIBUKDEBUG_PRINTK >> +#if defined c || CONFIG_LIBUKDEBUG_PRINTD >> /** >> - * Plots an hexdump for a given data region to kernel output >> + * Plots an hexdump for a given data region to debug output >> * The absolute address is plotted when UK_HXDF_ADDR is set >> * >> * @param data Start of data region to plot >> @@ -67,23 +67,23 @@ extern "C" { >> * Number of groups (UK_HXDF_GRP*) shown per line >> * @return Returns the number of printed characters to output fp >> */ >> -void uk_hexdumpk(const void *data, size_t len, int flags, >> +void uk_hexdumpd(const void *data, size_t len, int flags, >> unsigned int grps_per_line); >> #else >> -static inline void uk_hexdumpk(const void *data, size_t len, int flags, >> - unsigned int grps_per_line) >> -{ >> -} >> +static inline void uk_hexdumpd(const void *data __unused, size_t len >> __unused, >> + int flags __unused, >> + unsigned int grps_per_line __unused) >> +{} >> #endif >> > > Do we intend to use #ifdef instead of #if >> -#if CONFIG_LIBUKDEBUG_PRINTD >> -void _uk_hexdumpd(int lvl, const char *libname, const char *srcname, >> +#if CONFIG_LIBUKDEBUG_PRINTK >> +void _uk_hexdumpk(int lvl, const char *libname, const char *srcname, >> unsigned int srcline, const void *data, size_t len, >> size_t addr0, int flags, unsigned int grps_per_line, >> const char *line_prefix); >> >> /** >> - * Plots an hexdump for a given data region to debug output >> + * Plots an hexdump for a given data region to kernel output >> * The absolute address is plotted when UK_HXDF_ADDR is set >> * >> * @param lvl Debug level >> @@ -94,19 +94,19 @@ void _uk_hexdumpd(int lvl, const char *libname, const >> char *srcname, >> * Number of groups (UK_HXDF_GRP*) shown per line >> * @return Returns the number of printed characters to output fp >> */ >> -#define uk_hexdumpd(lvl, data, len, flags, grps_per_line) >> \ >> +#define uk_hexdumpk(lvl, data, len, flags, grps_per_line) >> \ >> do { \ >> - if ((lvl) <= DLVL_MAX) \ >> + if ((lvl) <= KLVL_MAX) \ >> _uk_hexdumpd((lvl), __STR_LIBNAME__, __STR_BASENAME__, \ >> __LINE__, (data), (len), \ >> ((size_t)(data)), (flags), \ >> (grps_per_line), STRINGIFY(data) ": "); \ >> } while (0) >> #else >> -static inline void uk_hexdumpd(int lvl, const void *data, size_t len, int >> flags, >> - unsigned int grps_per_line) >> -{ >> -} >> +static inline void uk_hexdumpk(int lvl __unused, const void *data __unused, >> + size_t len __unused, int flags __unused, >> + unsigned int grps_per_line __unused) >> +{} >> #endif >> >> /** >> @@ -184,13 +184,13 @@ int uk_hexdumpsn(char *str, size_t size, const void >> *data, size_t len, >> * Shortcuts for all hexdump variants ahead. The shortcuts use a similar >> style >> * as the hexdump Unix command using -C parameter: hexdump -C >> */ >> -#define uk_hexdumpCk(data, len) >> \ >> - uk_hexdumpk((data), (len), (UK_HXDF_ADDR | UK_HXDF_ASCIISEC \ >> +#define uk_hexdumpCd(data, len) >> \ >> + uk_hexdumpd((data), (len), (UK_HXDF_ADDR | UK_HXDF_ASCIISEC \ >> | UK_HXDF_GRPQWORD | UK_HXDF_COMPRESS), \ >> 2) >> >> -#define uk_hexdumpCd(lvl, data, len) >> \ >> - uk_hexdumpd((lvl), (data), (len), \ >> +#define uk_hexdumpCk(lvl, data, len) >> \ >> + uk_hexdumpk((lvl), (data), (len), \ >> (UK_HXDF_ADDR | UK_HXDF_ASCIISEC | UK_HXDF_GRPQWORD \ >> | UK_HXDF_COMPRESS), \ >> 2) >> diff --git a/lib/ukdebug/include/uk/print.h b/lib/ukdebug/include/uk/print.h >> index fe3730b..a8c6c96 100644 >> --- a/lib/ukdebug/include/uk/print.h >> +++ b/lib/ukdebug/include/uk/print.h >> @@ -46,70 +46,61 @@ >> extern "C" { >> #endif >> >> +/* >> + * DEBUG PRINTING >> + */ >> #ifdef __IN_LIBUKDEBUG__ >> /* >> - * These defines are doing the trick to compile the functions >> - * in print.c always in although printing was disabled >> - * in the configuration. This is required for linking with >> - * pre-compiled objects that built by using a different configuration. >> + * This redefinition of CONFIG_LIBUKDEBUG_PRINTD is doing the trick to avoid >> + * multiple declarations of uk_{v}printd() when we are compiling this >> library >> + * and have the global debug switch CONFIG_LIBUKDEBUG_PRINTD not enabled. >> */ >> -#if !CONFIG_LIBUKDEBUG_PRINTK >> -#undef CONFIG_LIBUKDEBUG_PRINTK >> -#define CONFIG_LIBUKDEBUG_PRINTK 1 >> -#endif >> -#if !CONFIG_LIBUKDEBUG_PRINTD > > Do we intend to use #if defined instead of #if >> +#if !defined CONFIG_LIBUKDEBUG_PRINTD || !CONFIG_LIBUKDEBUG_PRINTD >> #undef CONFIG_LIBUKDEBUG_PRINTD >> #define CONFIG_LIBUKDEBUG_PRINTD 1 >> #endif >> #endif /* __IN_LIBUKDEBUG__ */ >> >> -/* >> - * KERNEL CONSOLE >> - */ >> -#if CONFIG_LIBUKDEBUG_PRINTK >> -void uk_vprintk(const char *fmt, va_list ap); >> -void uk_printk(const char *fmt, ...) __printf(1, 2); >> +#if defined UK_DEBUG || CONFIG_LIBUKDEBUG_PRINTD >> +void uk_vprintd(const char *fmt, va_list ap); >> +void uk_printd(const char *fmt, ...) __printf(1, 2); >> #else >> -static inline void uk_vprintk(const char *fmt, va_list ap) >> -{ >> -} >> -static inline void uk_printk(const char *fmt, ...) __printf(1, 2); >> -static inline void uk_printk(const char *fmt, ...) >> -{ >> -} >> +static inline void uk_vprintd(const char *fmt __unused, va_list ap __unused) >> +{} >> + >> +static inline void uk_printd(const char *fmt, ...) __printf(1, 2); >> +static inline void uk_printd(const char *fmt __unused, ...) >> +{} >> #endif >> >> /* >> - * DEBUG CONSOLE >> + * KERNEL CONSOLE >> */ >> -#define DLVL_EXTRA (4) >> -#define DLVL_INFO (3) >> -#define DLVL_WARN (2) >> -#define DLVL_ERR (1) >> -#define DLVL_CRIT (0) >> - >> -#if CONFIG_LIBUKDEBUG_PRINTD_CRIT >> -#define DLVL_MAX DLVL_CRIT >> -#elif CONFIG_LIBUKDEBUG_PRINTD_ERR >> -#define DLVL_MAX DLVL_ERR >> -#elif CONFIG_LIBUKDEBUG_PRINTD_WARN >> -#define DLVL_MAX DLVL_WARN >> -#elif CONFIG_LIBUKDEBUG_PRINTD_INFO >> -#define DLVL_MAX DLVL_INFO >> -#elif CONFIG_LIBUKDEBUG_PRINTD_EXTRA >> -#define DLVL_MAX DLVL_EXTRA >> +#define KLVL_INFO (3) >> +#define KLVL_WARN (2) >> +#define KLVL_ERR (1) >> +#define KLVL_CRIT (0) >> + >> +#if CONFIG_LIBUKDEBUG_PRINTK_CRIT >> +#define KLVL_MAX KLVL_CRIT >> +#elif CONFIG_LIBUKDEBUG_PRINTK_ERR >> +#define KLVL_MAX KLVL_ERR >> +#elif CONFIG_LIBUKDEBUG_PRINTK_WARN >> +#define KLVL_MAX KLVL_WARN >> +#elif CONFIG_LIBUKDEBUG_PRINTK_INFO >> +#define KLVL_MAX KLVL_INFO >> #else >> -#define DLVL_MAX DLVL_ERR /* default level */ >> +#define KLVL_MAX KLVL_ERR /* default level */ >> #endif >> >> -#if CONFIG_LIBUKDEBUG_PRINTD >> +#if CONFIG_LIBUKDEBUG_PRINTK >> /* please use the uk_printd(), uk_vprintd() macros because >> * they compile in the function calls only if the configured >> * debug level requires it >> */ >> -void _uk_vprintd(int lvl, const char *libname, const char *srcname, >> +void _uk_vprintk(int lvl, const char *libname, const char *srcname, >> unsigned int srcline, const char *fmt, va_list ap); >> -void _uk_printd(int lvl, const char *libname, const char *srcname, >> +void _uk_printk(int lvl, const char *libname, const char *srcname, >> unsigned int srcline, const char *fmt, ...) __printf(5, 6); >> >> #ifdef __LIBNAME__ >> @@ -124,39 +115,38 @@ void _uk_printd(int lvl, const char *libname, const >> char *srcname, >> #define __STR_BASENAME__ (NULL) >> #endif >> >> -#define uk_vprintd(lvl, fmt, ap) >> \ >> +#define uk_vprintk(lvl, fmt, ap) >> \ >> do { \ >> - if ((lvl) <= DLVL_MAX) \ >> - _uk_vprintd((lvl), __STR_LIBNAME__, __STR_BASENAME__, \ >> + if ((lvl) <= KLVL_MAX) \ >> + _uk_vprintk((lvl), __STR_LIBNAME__, __STR_BASENAME__, \ >> __LINE__, (fmt), ap); \ >> } while (0) >> >> -#define uk_printd(lvl, fmt, ...) >> \ >> +#define uk_printk(lvl, fmt, ...) >> \ >> do { \ >> - if ((lvl) <= DLVL_MAX) \ >> - _uk_printd((lvl), __STR_LIBNAME__, __STR_BASENAME__, \ >> + if ((lvl) <= KLVL_MAX) \ >> + _uk_printk((lvl), __STR_LIBNAME__, __STR_BASENAME__, \ >> __LINE__, (fmt), ##__VA_ARGS__); \ >> } while (0) >> #else >> -static inline void uk_vprintd(int lvl __unused, const char *fmt __unused, >> +static inline void uk_vprintk(int lvl __unused, const char *fmt __unused, >> va_list ap __unused) >> -{ >> -} >> -static inline void uk_printd(int lvl, const char *fmt, ...) __printf(2, 3); >> -static inline void uk_printd(int lvl __unused, const char *fmt __unused, >> ...) >> -{ >> -} >> -#endif /* CONFIG_LIBUKDEBUG_PRINTD */ >> +{} >> + >> +static inline void uk_printk(int lvl, const char *fmt, ...) __printf(2, 3); >> +static inline void uk_printk(int lvl __unused, const char *fmt __unused, >> ...) >> +{} >> +#endif /* CONFIG_LIBUKDEBUG_PRINTK */ >> >> /* >> - * Convenience wrapper for uk_printd() >> + * Convenience wrapper for uk_printk() and uk_printd() >> * This is similar to the pr_* variants that you find in the Linux kernel >> */ >> -#define uk_pr_debug(fmt, ...) uk_printd(DLVL_EXTRA, (fmt), ##__VA_ARGS__) >> -#define uk_pr_info(fmt, ...) uk_printd(DLVL_INFO, (fmt), ##__VA_ARGS__) >> -#define uk_pr_warn(fmt, ...) uk_printd(DLVL_WARN, (fmt), ##__VA_ARGS__) >> -#define uk_pr_err(fmt, ...) uk_printd(DLVL_ERR, (fmt), ##__VA_ARGS__) >> -#define uk_pr_crit(fmt, ...) uk_printd(DLVL_CRIT, (fmt), ##__VA_ARGS__) >> +#define uk_pr_debug(fmt, ...) uk_printd((fmt), ##__VA_ARGS__) >> +#define uk_pr_info(fmt, ...) uk_printk(KLVL_INFO, (fmt), ##__VA_ARGS__) >> +#define uk_pr_warn(fmt, ...) uk_printk(KLVL_WARN, (fmt), ##__VA_ARGS__) >> +#define uk_pr_err(fmt, ...) uk_printk(KLVL_ERR, (fmt), ##__VA_ARGS__) >> +#define uk_pr_crit(fmt, ...) uk_printk(KLVL_CRIT, (fmt), ##__VA_ARGS__) >> >> #ifdef __cplusplus >> } >> diff --git a/lib/ukdebug/print.c b/lib/ukdebug/print.c >> index 6f98d28..0c3904c 100644 >> --- a/lib/ukdebug/print.c >> +++ b/lib/ukdebug/print.c >> @@ -57,10 +57,10 @@ >> >> #define BUFLEN 192 >> /* special level for printk redirection, used internally only */ >> -#define DLVL_CONS (-1) >> +#define KLVL_DEBUG (-1) >> >> -#if !CONFIG_LIBUKDEBUG_REDIR_PRINTK >> -static inline void _vprintk(const char *fmt, va_list ap) > > Do we intend to use #ifdef instead of #if >> +#if !CONFIG_LIBUKDEBUG_REDIR_PRINTD >> +static inline void _vprintd(const char *fmt, va_list ap) >> { >> char lbuf[BUFLEN]; >> int len; >> @@ -71,14 +71,14 @@ static inline void _vprintk(const char *fmt, va_list ap) >> } >> #endif >> >> -#if CONFIG_LIBUKDEBUG_REDIR_PRINTD >> -#define _ukplat_coutd(lbuf, len) ukplat_coutk((lbuf), (len)) >> +#if CONFIG_LIBUKDEBUG_REDIR_PRINTK >> +#define _ukplat_coutk(lbuf, len) ukplat_coutd((lbuf), (len)) >> #else >> -#define _ukplat_coutd(lbuf, len) ukplat_coutd((lbuf), (len)) >> +#define _ukplat_coutk(lbuf, len) ukplat_coutk((lbuf), (len)) >> #endif >> >> -#if CONFIG_LIBUKDEBUG_PRINTD_TIME >> -static void _printd_timestamp(void) >> +#if CONFIG_LIBUKDEBUG_PRINTK_TIME >> +static void _printk_timestamp(void) >> { >> char buf[BUFLEN]; >> int len; >> @@ -89,12 +89,12 @@ static void _printd_timestamp(void) >> rem_usec = ukarch_time_nsec_to_usec(rem_usec); >> len = snprintf(buf, BUFLEN, "[%5" __PRInsec ".%06" __PRInsec "] ", >> sec, rem_usec); >> - _ukplat_coutd((char *)buf, len); >> + _ukplat_coutk((char *)buf, len); >> } >> #endif >> >> -#if CONFIG_LIBUKDEBUG_PRINTD_STACK >> -static void _printd_stack(void) >> +#if CONFIG_LIBUKDEBUG_PRINTK_STACK >> +static void _printk_stack(void) >> { >> unsigned long stackb; >> char buf[BUFLEN]; >> @@ -103,12 +103,13 @@ static void _printd_stack(void) >> stackb = (ukarch_read_sp() & ~(__STACK_SIZE - 1)) + __STACK_SIZE; >> >> len = snprintf(buf, BUFLEN, "<%p> ", (void *) stackb); >> - _ukplat_coutd((char *)buf, len); >> + _ukplat_coutk((char *)buf, len); >> } >> #endif >> >> -static inline void _vprintd(int lvl, const char *libname, const char >> *srcname, >> - unsigned int srcline, const char *fmt, va_list ap) >> +#if CONFIG_LIBUKDEBUG_REDIR_PRINTD || CONFIG_LIBUKDEBUG_PRINTK >> +static void _vprintk(int lvl, const char *libname, const char *srcname, >> + unsigned int srcline, const char *fmt, va_list ap) >> { >> static int newline = 1; >> static int prevlvl = INT_MIN; >> @@ -120,26 +121,23 @@ static inline void _vprintd(int lvl, const char >> *libname, const char *srcname, >> const char *nlptr = NULL; >> >> switch (lvl) { >> -#if CONFIG_LIBUKDEBUG_REDIR_PRINTK >> - case DLVL_CONS: >> - msghdr = "Kern: "; >> +#if CONFIG_LIBUKDEBUG_REDIR_PRINTD >> + case KLVL_DEBUG: >> + msghdr = "dbg: "; >> break; >> #endif >> - case DLVL_CRIT: >> + case KLVL_CRIT: >> msghdr = "CRIT: "; >> break; >> - case DLVL_ERR: >> + case KLVL_ERR: >> msghdr = "ERR: "; >> break; >> - case DLVL_WARN: >> + case KLVL_WARN: >> msghdr = "Warn: "; >> break; >> - case DLVL_INFO: >> + case KLVL_INFO: >> msghdr = "Info: "; >> break; >> - case DLVL_EXTRA: >> - msghdr = "EInf: "; >> - break; >> default: >> /* unknown type: ignore */ >> return; >> @@ -151,7 +149,7 @@ static inline void _vprintd(int lvl, const char >> *libname, const char *srcname, >> /* level changed without closing with '\n', >> * enforce printing '\n', before the new message header >> */ >> - _ukplat_coutd("\n", 1); >> + _ukplat_coutk("\n", 1); >> } >> prevlvl = lvl; >> newline = 1; /* enforce printing the message header */ >> @@ -161,29 +159,29 @@ static inline void _vprintd(int lvl, const char >> *libname, const char *srcname, >> lptr = lbuf; >> while (len > 0) { >> if (newline) { >> -#if CONFIG_LIBUKDEBUG_PRINTD_TIME >> - _printd_timestamp(); >> +#if CONFIG_LIBUKDEBUG_PRINTK_TIME >> + _printk_timestamp(); >> #endif >> - _ukplat_coutd(DECONST(char *, msghdr), 6); >> -#if CONFIG_LIBUKDEBUG_PRINTD_STACK >> - _printd_stack(); >> + _ukplat_coutk(DECONST(char *, msghdr), 6); >> +#if CONFIG_LIBUKDEBUG_PRINTK_STACK >> + _printk_stack(); >> #endif >> if (libname) { >> - _ukplat_coutd("[", 1); >> - _ukplat_coutd(DECONST(char *, libname), >> + _ukplat_coutk("[", 1); >> + _ukplat_coutk(DECONST(char *, libname), >> strlen(libname)); >> - _ukplat_coutd("] ", 2); >> + _ukplat_coutk("] ", 2); >> } >> if (srcname) { >> char lnobuf[6]; >> >> - _ukplat_coutd(DECONST(char *, srcname), >> + _ukplat_coutk(DECONST(char *, srcname), >> strlen(srcname)); >> - _ukplat_coutd(" @ ", 3); >> - _ukplat_coutd(lnobuf, >> + _ukplat_coutk(" @ ", 3); >> + _ukplat_coutk(lnobuf, >> snprintf(lnobuf, sizeof(lnobuf), >> "%-5u", srcline)); >> - _ukplat_coutd(": ", 2); >> + _ukplat_coutk(": ", 2); >> } >> newline = 0; >> } >> @@ -195,59 +193,57 @@ static inline void _vprintd(int lvl, const char >> *libname, const char *srcname, >> } else { >> llen = len; >> } >> - _ukplat_coutd((char *)lptr, llen); >> + _ukplat_coutk((char *)lptr, llen); >> len -= llen; >> lptr = nlptr + 1; >> } >> } >> +#endif /* CONFIG_LIBUKDEBUG_REDIR_PRINTD || CONFIG_LIBUKDEBUG_PRINTK */ >> >> -/* ensures that function is always compiled */ >> -void uk_vprintk(const char *fmt, va_list ap) >> +/* >> + * DEBUG PRINTING ENTRY >> + * uk_printd() and uk_vprintd are always compiled in. >> + * We rely on OPTIMIZE_DEADELIM: These symbols are automatically >> + * removed from the final image when there was no usage. >> + */ >> +void uk_vprintd(const char *fmt __maybe_unused, va_list ap __maybe_unused) >> { >> -#if CONFIG_LIBUKDEBUG_PRINTK >> -#if CONFIG_LIBUKDEBUG_REDIR_PRINTK >> - _vprintd(DLVL_CONS, NULL, NULL, 0, fmt, ap); > > Do we intend to use #ifdef instead of #if >> +#if CONFIG_LIBUKDEBUG_REDIR_PRINTD >> + _vprintk(KLVL_DEBUG, NULL, NULL, 0, fmt, ap); >> #else >> - _vprintk(fmt, ap); >> + _vprintd(fmt, ap); >> #endif >> -#endif /* CONFIG_LIBUKDEBUG_PRINTK */ >> } >> >> -/* ensures that function is always compiled */ >> -void uk_printk(const char *fmt, ...) >> +void uk_printd(const char *fmt, ...) >> { >> -#if CONFIG_LIBUKDEBUG_PRINTK >> va_list ap; >> >> va_start(ap, fmt); >> - uk_vprintk(fmt, ap); >> + uk_vprintd(fmt, ap); >> va_end(ap); >> -#endif /* CONFIG_LIBUKDEBUG_PRINTK */ >> } >> >> -/* ensures that function is always compiled */ >> -void _uk_vprintd(int lvl, const char *libname, const char *srcname, >> +/* >> + * KERNEL PRINT ENTRY >> + * Different to uk_printd(), we have a global switch that disables kernel >> + * messages. We compile these entry points only in when the kernel console >> is >> + * enabled. >> + */ >> +#if CONFIG_LIBUKDEBUG_PRINTK >> +void _uk_vprintk(int lvl, const char *libname, const char *srcname, >> unsigned int srcline, const char *fmt, va_list ap) >> { >> -#if CONFIG_LIBUKDEBUG_PRINTD >> - if (likely(lvl > DLVL_MAX)) >> - return; >> - _vprintd(lvl, libname, srcname, srcline, fmt, ap); >> -#endif /* CONFIG_LIBUKDEBUG_PRINTD */ >> + _vprintk(lvl, libname, srcname, srcline, fmt, ap); >> } >> >> -/* ensures that function is always compiled */ >> -void _uk_printd(int lvl, const char *libname, const char *srcname, >> +void _uk_printk(int lvl, const char *libname, const char *srcname, >> unsigned int srcline, const char *fmt, ...) >> { >> -#if CONFIG_LIBUKDEBUG_PRINTD >> va_list ap; >> >> - if (likely(lvl > DLVL_MAX)) >> - return; >> - >> va_start(ap, fmt); >> - _uk_vprintd(lvl, libname, srcname, srcline, fmt, ap); >> + _uk_vprintk(lvl, libname, srcname, srcline, fmt, ap); >> va_end(ap); >> -#endif /* CONFIG_LIBUKDEBUG_PRINTD */ >> } > > Do you mean CONFIIG_LIBUKDEBUG_PRINTK? >> +#endif /* CONFIG_LIBUKDEBUG_PRINTD */ >> > > > Thanks & Regards > Sharan -- Yuri Volchkov Software Specialist NEC Europe Ltd Kurfürsten-Anlage 36 D-69115 Heidelberg _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |