From a3bb764305e25af17f8834f8d3eff22820e6f31f Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 11 Jun 2016 12:38:37 -0600 Subject: [PATCH] Add support for a warn() marco that will be between dbg() and info() in priority --- Kconfig | 11 +- include/debug.h | 749 +++++++++++++++++++++++++++----------------- libc/misc/lib_dbg.c | 39 ++- 3 files changed, 498 insertions(+), 301 deletions(-) diff --git a/Kconfig b/Kconfig index d8eafff5d2..ceea41ec91 100644 --- a/Kconfig +++ b/Kconfig @@ -413,9 +413,18 @@ if DEBUG comment "Debug SYSLOG Output Controls" -config CONFIG_DEBUG_INFO +config DEBUG_WARNINGS + bool "Enable Warnings Output" + default n + ---help--- + Enables output from warning statements. Warnings are considered to + be potential errors or errors that will not have serious + consequences. + +config DEBUG_INFO bool "Enable Informational Debug Output" default n + depends on DEBUG_WARNINGS ---help--- Enables verbose "informational" debug output. If you enable CONFIG_DEBUG_INFO, then very chatty (and often annoying) output diff --git a/include/debug.h b/include/debug.h index 2f09d73c57..80d175ed30 100644 --- a/include/debug.h +++ b/include/debug.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/debug.h * - * Copyright (C) 2007-2011, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2011, 2014, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -56,11 +56,16 @@ /* Debug macros to runtime filter the debug messages sent to the console. In * general, there are four forms of the debug macros: * - * [a-z]dbg() -- Outputs messages to the console similar to printf() except - * that the output is not buffered. The first character indicates the - * system system (e.g., n=network, f=filesystm, etc.). If the first - * character is missing (i.e., dbg()), then it is common. The common - * dbg() macro is enabled by CONFIG_DEBUG. Subsystem debug requires an + * [a-z]info() -- Outputs messages to the console similar to printf() except + * that the output is not buffered. Output is only generated if + * CONFIG_DEBUG_INFO is defined. The info macros are intended for + * verbose "informational" debug output. If you enable CONFIG_DEBUG_INFO, + * then very chatty (and often annoying) output will be generated. + * + * The first character of the macro name indicates the system system + * (e.g., n=network, f=filesystm, etc.). If the first character is + * missing (i.e., info()), then it is common. The common info() macro + * is enabled simply with CONFIG_DEBUG_INFO. Subsystem debug requires an * additional configuration setting to enable it (e.g., CONFIG_DEBUG_NET * for the network, CONFIG_DEBUG_FS for the file system, etc). * @@ -70,41 +75,53 @@ * directed stdout). Therefore [a-z]dbg() should not be used in interrupt * handlers. * - * [a-z]info() -- Identical to [a-z]dbg() except that it also requires that - * CONFIG_DEBUG_INFO be defined. This is intended for general debug - * output that you would normally want to suppress. + * [a-z]warn() -- Identical to [a-z]info() except that it also requires that + * CONFIG_DEBUG_WARN be defined. This is intended for important exception + * conditions that are potential errors (or perhaps real errors with non- + * fatal consequences). * - * [a-z]lldbg() -- Identical to [a-z]dbg() except this is uses special + * [a-z]dbg() -- Identical to [a-z]info() except that it also requires that + * CONFIG_DEBUG be defined. This is intended for important error-related + * information that you probably not want to suppress during normal debug + * general debugging. + * + * [a-z]llinfo() -- Identical to [a-z]dbg() except this is uses special * interfaces provided by architecture-specific logic to talk directly * to the underlying console hardware. If the architecture provides such * logic, it should define CONFIG_ARCH_LOWPUTC. * - * [a-z]lldbg() should not be used in normal code because the implementation + * [a-z]llinfo() should not be used in normal code because the implementation * probably disables interrupts and does things that are not consistent with - * good real-time performance. However, [a-z]lldbg() is particularly useful + * good real-time performance. However, [a-z]llinfo() is particularly useful * in low-level code where it is inappropriate to use file descriptors. For - * example, only [a-z]lldbg() should be used in interrupt handlers. + * example, only [a-z]llinfo() should be used in interrupt handlers. * - * [a-z]llinfo() -- Identical to [a-z]lldbg() except that it also requires that - * CONFIG_DEBUG_INFO be defined. This is intended for general debug - * output that you would normally want to suppress. + * [a-z]llwarn() -- Identical to [a-z]llinfo() except that it also requires that + * CONFIG_DEBUG_WARN be defined. This is intended for important exception + * conditions that are potential errors (or perhaps real errors with non- + * fatal consequences). + * + * [a-z]lldbg() -- Identical to [a-z]llinfo() except that it also requires that + * CONFIG_DEBUG be defined. This is intended for important error-related + * information that you probably not want to suppress during normal debug + * general debugging. */ #ifdef CONFIG_HAVE_FUNCTIONNAME -# define EXTRA_FMT "%s: " -# define EXTRA_ARG ,__FUNCTION__ +# define EXTRA_FMT "%s: " +# define EXTRA_ARG ,__FUNCTION__ #else -# define EXTRA_FMT -# define EXTRA_ARG +# define EXTRA_FMT +# define EXTRA_ARG #endif /* The actual logger function may be overridden in arch/debug.h if needed. */ #ifndef __arch_syslog -# define __arch_syslog syslog +# define __arch_syslog syslog #endif #ifndef __arch_lowsyslog -# define __arch_lowsyslog lowsyslog +# define __arch_lowsyslog lowsyslog #endif /* Debug macros will differ depending upon if the toolchain supports @@ -116,8 +133,8 @@ /* C-99 style variadic macros are supported */ #ifdef CONFIG_DEBUG -# define dbg(format, ...) \ - __arch_syslog(LOG_ERR, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) +# define dbg(format, ...) \ + __arch_syslog(LOG_ERR, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) # ifdef CONFIG_ARCH_LOWPUTC # define lldbg(format, ...) \ @@ -125,8 +142,28 @@ # else # define lldbg(x...) # endif +#else /* CONFIG_DEBUG */ -# ifdef CONFIG_DEBUG_INFO +# define dbg(x...) +# define lldbg(x...) +#endif + +#ifdef CONFIG_DEBUG_WARN +# define warn(format, ...) \ + __arch_syslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) + +# ifdef CONFIG_ARCH_LOWPUTC +# define llwarn(format, ...) \ + __arch_lowsyslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) +# else +# define llwarn(x...) +# endif +#else /* CONFIG_DEBUG_INFO */ +# define warn(x...) +# define llwarn(x...) +#endif /* CONFIG_DEBUG_INFO */ + +#ifdef CONFIG_DEBUG_INFO # define info(format, ...) \ __arch_syslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) @@ -136,201 +173,251 @@ # else # define llinfo(x...) # endif - -# else /* CONFIG_DEBUG_INFO */ +#else /* CONFIG_DEBUG_INFO */ # define info(x...) # define llinfo(x...) -# endif /* CONFIG_DEBUG_INFO */ - -#else /* CONFIG_DEBUG */ - -# define dbg(x...) -# define lldbg(x...) -# define info(x...) -# define llinfo(x...) - -#endif /* CONFIG_DEBUG */ +#endif /* CONFIG_DEBUG_INFO */ /* Subsystem specific debug */ #ifdef CONFIG_DEBUG_MM -# define mdbg(format, ...) dbg(format, ##__VA_ARGS__) -# define mlldbg(format, ...) lldbg(format, ##__VA_ARGS__) -# define minfo(format, ...) info(format, ##__VA_ARGS__) -# define mllinfo(format, ...) llinfo(format, ##__VA_ARGS__) +# define mdbg(format, ...) dbg(format, ##__VA_ARGS__) +# define mlldbg(format, ...) lldbg(format, ##__VA_ARGS__) +# define mwarn(format, ...) warn(format, ##__VA_ARGS__) +# define mllwarn(format, ...) llwarn(format, ##__VA_ARGS__) +# define minfo(format, ...) info(format, ##__VA_ARGS__) +# define mllinfo(format, ...) llinfo(format, ##__VA_ARGS__) #else -# define mdbg(x...) -# define mlldbg(x...) -# define minfo(x...) -# define mllinfo(x...) +# define mdbg(x...) +# define mlldbg(x...) +# define mwarn(x...) +# define mllwarn(x...) +# define minfo(x...) +# define mllinfo(x...) #endif #ifdef CONFIG_DEBUG_SCHED -# define sdbg(format, ...) dbg(format, ##__VA_ARGS__) -# define slldbg(format, ...) lldbg(format, ##__VA_ARGS__) -# define sinfo(format, ...) info(format, ##__VA_ARGS__) -# define sllinfo(format, ...) llinfo(format, ##__VA_ARGS__) +# define sdbg(format, ...) dbg(format, ##__VA_ARGS__) +# define slldbg(format, ...) lldbg(format, ##__VA_ARGS__) +# define swarn(format, ...) warn(format, ##__VA_ARGS__) +# define sllwarn(format, ...) llwarn(format, ##__VA_ARGS__) +# define sinfo(format, ...) info(format, ##__VA_ARGS__) +# define sllinfo(format, ...) llinfo(format, ##__VA_ARGS__) #else -# define sdbg(x...) -# define slldbg(x...) -# define sinfo(x...) -# define sllinfo(x...) +# define sdbg(x...) +# define slldbg(x...) +# define swarn(x...) +# define sllwarn(x...) +# define sinfo(x...) +# define sllinfo(x...) #endif #ifdef CONFIG_DEBUG_PAGING -# define pgdbg(format, ...) dbg(format, ##__VA_ARGS__) -# define pglldbg(format, ...) lldbg(format, ##__VA_ARGS__) -# define pginfo(format, ...) info(format, ##__VA_ARGS__) -# define pgllinfo(format, ...) llinfo(format, ##__VA_ARGS__) +# define pgdbg(format, ...) dbg(format, ##__VA_ARGS__) +# define pglldbg(format, ...) lldbg(format, ##__VA_ARGS__) +# define pgwarn(format, ...) warn(format, ##__VA_ARGS__) +# define pgllwarn(format, ...) llwarn(format, ##__VA_ARGS__) +# define pginfo(format, ...) info(format, ##__VA_ARGS__) +# define pgllinfo(format, ...) llinfo(format, ##__VA_ARGS__) #else -# define pgdbg(x...) -# define pglldbg(x...) -# define pginfo(x...) -# define pgllinfo(x...) +# define pgdbg(x...) +# define pglldbg(x...) +# define pgwarn(x...) +# define pgllwarn(x...) +# define pginfo(x...) +# define pgllinfo(x...) #endif #ifdef CONFIG_DEBUG_DMA -# define dmadbg(format, ...) dbg(format, ##__VA_ARGS__) -# define dmalldbg(format, ...) lldbg(format, ##__VA_ARGS__) -# define dmainfo(format, ...) info(format, ##__VA_ARGS__) -# define dmallinfo(format, ...) llinfo(format, ##__VA_ARGS__) +# define dmadbg(format, ...) dbg(format, ##__VA_ARGS__) +# define dmalldbg(format, ...) lldbg(format, ##__VA_ARGS__) +# define dmawarn(format, ...) warn(format, ##__VA_ARGS__) +# define dmallwarn(format, ...) llwarn(format, ##__VA_ARGS__) +# define dmainfo(format, ...) info(format, ##__VA_ARGS__) +# define dmallinfo(format, ...) llinfo(format, ##__VA_ARGS__) #else -# define dmadbg(x...) -# define dmalldbg(x...) -# define dmainfo(x...) -# define dmallinfo(x...) +# define dmadbg(x...) +# define dmalldbg(x...) +# define dmawarn(x...) +# define dmallwarn(x...) +# define dmainfo(x...) +# define dmallinfo(x...) #endif #ifdef CONFIG_DEBUG_NET -# define ndbg(format, ...) dbg(format, ##__VA_ARGS__) -# define nlldbg(format, ...) lldbg(format, ##__VA_ARGS__) -# define ninfo(format, ...) info(format, ##__VA_ARGS__) -# define nllinfo(format, ...) llinfo(format, ##__VA_ARGS__) +# define ndbg(format, ...) dbg(format, ##__VA_ARGS__) +# define nlldbg(format, ...) lldbg(format, ##__VA_ARGS__) +# define nwarn(format, ...) warn(format, ##__VA_ARGS__) +# define nllwarn(format, ...) llwarn(format, ##__VA_ARGS__) +# define ninfo(format, ...) info(format, ##__VA_ARGS__) +# define nllinfo(format, ...) llinfo(format, ##__VA_ARGS__) #else -# define ndbg(x...) -# define nlldbg(x...) -# define ninfo(x...) -# define nllinfo(x...) +# define ndbg(x...) +# define nlldbg(x...) +# define nwarn(x...) +# define nllwarn(x...) +# define ninfo(x...) +# define nllinfo(x...) #endif #ifdef CONFIG_DEBUG_USB -# define udbg(format, ...) dbg(format, ##__VA_ARGS__) -# define ulldbg(format, ...) lldbg(format, ##__VA_ARGS__) -# define uinfo(format, ...) info(format, ##__VA_ARGS__) -# define ullinfo(format, ...) llinfo(format, ##__VA_ARGS__) +# define udbg(format, ...) dbg(format, ##__VA_ARGS__) +# define ulldbg(format, ...) lldbg(format, ##__VA_ARGS__) +# define uwarn(format, ...) warn(format, ##__VA_ARGS__) +# define ullwarn(format, ...) llwarn(format, ##__VA_ARGS__) +# define uinfo(format, ...) info(format, ##__VA_ARGS__) +# define ullinfo(format, ...) llinfo(format, ##__VA_ARGS__) #else -# define udbg(x...) -# define ulldbg(x...) -# define uinfo(x...) -# define ullinfo(x...) +# define udbg(x...) +# define ulldbg(x...) +# define uwarn(x...) +# define ullwarn(x...) +# define uinfo(x...) +# define ullinfo(x...) #endif #ifdef CONFIG_DEBUG_FS -# define fdbg(format, ...) dbg(format, ##__VA_ARGS__) -# define flldbg(format, ...) lldbg(format, ##__VA_ARGS__) -# define finfo(format, ...) info(format, ##__VA_ARGS__) -# define fllinfo(format, ...) llinfo(format, ##__VA_ARGS__) +# define fdbg(format, ...) dbg(format, ##__VA_ARGS__) +# define flldbg(format, ...) lldbg(format, ##__VA_ARGS__) +# define fwarn(format, ...) warn(format, ##__VA_ARGS__) +# define fllwarn(format, ...) llwarn(format, ##__VA_ARGS__) +# define finfo(format, ...) info(format, ##__VA_ARGS__) +# define fllinfo(format, ...) llinfo(format, ##__VA_ARGS__) #else -# define fdbg(x...) -# define flldbg(x...) -# define finfo(x...) -# define fllinfo(x...) +# define fdbg(x...) +# define flldbg(x...) +# define fwarn(x...) +# define fllwarn(x...) +# define finfo(x...) +# define fllinfo(x...) #endif #ifdef CONFIG_DEBUG_CRYPTO -# define cryptdbg(format, ...) dbg(format, ##__VA_ARGS__) -# define cryptlldbg(format, ...) lldbg(format, ##__VA_ARGS__) -# define cryptinfo(format, ...) info(format, ##__VA_ARGS__) -# define cryptllinfo(format, ...) llinfo(format, ##__VA_ARGS__) +# define cryptdbg(format, ...) dbg(format, ##__VA_ARGS__) +# define cryptlldbg(format, ...) lldbg(format, ##__VA_ARGS__) +# define cryptwarn(format, ...) warn(format, ##__VA_ARGS__) +# define cryptllwarn(format, ...) llwarn(format, ##__VA_ARGS__) +# define cryptinfo(format, ...) info(format, ##__VA_ARGS__) +# define cryptllinfo(format, ...) llinfo(format, ##__VA_ARGS__) #else -# define cryptdbg(x...) -# define cryptlldbg(x...) -# define cryptinfo(x...) -# define cryptllinfo(x...) +# define cryptdbg(x...) +# define cryptlldbg(x...) +# define cryptwarn(x...) +# define cryptllwarn(x...) +# define cryptinfo(x...) +# define cryptllinfo(x...) #endif #ifdef CONFIG_DEBUG_INPUT -# define idbg(format, ...) dbg(format, ##__VA_ARGS__) -# define illdbg(format, ...) lldbg(format, ##__VA_ARGS__) -# define iinfo(format, ...) info(format, ##__VA_ARGS__) -# define illinfo(format, ...) llinfo(format, ##__VA_ARGS__) +# define idbg(format, ...) dbg(format, ##__VA_ARGS__) +# define illdbg(format, ...) lldbg(format, ##__VA_ARGS__) +# define iwarn(format, ...) warn(format, ##__VA_ARGS__) +# define illwarn(format, ...) llwarn(format, ##__VA_ARGS__) +# define iinfo(format, ...) info(format, ##__VA_ARGS__) +# define illinfo(format, ...) llinfo(format, ##__VA_ARGS__) #else -# define idbg(x...) -# define illdbg(x...) -# define iinfo(x...) -# define illinfo(x...) +# define idbg(x...) +# define illdbg(x...) +# define iwarn(x...) +# define illwarn(x...) +# define iinfo(x...) +# define illinfo(x...) #endif #ifdef CONFIG_DEBUG_SENSORS -# define sndbg(format, ...) dbg(format, ##__VA_ARGS__) -# define snlldbg(format, ...) lldbg(format, ##__VA_ARGS__) -# define sninfo(format, ...) info(format, ##__VA_ARGS__) -# define snllinfo(format, ...) llinfo(format, ##__VA_ARGS__) +# define sndbg(format, ...) dbg(format, ##__VA_ARGS__) +# define snlldbg(format, ...) lldbg(format, ##__VA_ARGS__) +# define snwarn(format, ...) warn(format, ##__VA_ARGS__) +# define snllwarn(format, ...) llwarn(format, ##__VA_ARGS__) +# define sninfo(format, ...) info(format, ##__VA_ARGS__) +# define snllinfo(format, ...) llinfo(format, ##__VA_ARGS__) #else -# define sndbg(x...) -# define snlldbg(x...) -# define sninfo(x...) -# define snllinfo(x...) +# define sndbg(x...) +# define snlldbg(x...) +# define snwarn(x...) +# define snllwarn(x...) +# define sninfo(x...) +# define snllinfo(x...) #endif #ifdef CONFIG_DEBUG_ANALOG -# define adbg(format, ...) dbg(format, ##__VA_ARGS__) -# define alldbg(format, ...) lldbg(format, ##__VA_ARGS__) -# define ainfo(format, ...) info(format, ##__VA_ARGS__) -# define allinfo(format, ...) llinfo(format, ##__VA_ARGS__) +# define adbg(format, ...) dbg(format, ##__VA_ARGS__) +# define alldbg(format, ...) lldbg(format, ##__VA_ARGS__) +# define awarn(format, ...) warn(format, ##__VA_ARGS__) +# define allwarn(format, ...) llwarn(format, ##__VA_ARGS__) +# define ainfo(format, ...) info(format, ##__VA_ARGS__) +# define allinfo(format, ...) llinfo(format, ##__VA_ARGS__) #else -# define adbg(x...) -# define alldbg(x...) -# define ainfo(x...) -# define allinfo(x...) +# define adbg(x...) +# define alldbg(x...) +# define awarn(x...) +# define allwarn(x...) +# define ainfo(x...) +# define allinfo(x...) #endif #ifdef CONFIG_DEBUG_GRAPHICS -# define gdbg(format, ...) dbg(format, ##__VA_ARGS__) -# define glldbg(format, ...) lldbg(format, ##__VA_ARGS__) -# define ginfo(format, ...) info(format, ##__VA_ARGS__) -# define gllinfo(format, ...) llinfo(format, ##__VA_ARGS__) +# define gdbg(format, ...) dbg(format, ##__VA_ARGS__) +# define glldbg(format, ...) lldbg(format, ##__VA_ARGS__) +# define gwarn(format, ...) warn(format, ##__VA_ARGS__) +# define gllwarn(format, ...) llwarn(format, ##__VA_ARGS__) +# define ginfo(format, ...) info(format, ##__VA_ARGS__) +# define gllinfo(format, ...) llinfo(format, ##__VA_ARGS__) #else -# define gdbg(x...) -# define glldbg(x...) -# define ginfo(x...) -# define gllinfo(x...) +# define gdbg(x...) +# define glldbg(x...) +# define gwarn(x...) +# define gllwarn(x...) +# define ginfo(x...) +# define gllinfo(x...) #endif #ifdef CONFIG_DEBUG_BINFMT -# define bdbg(format, ...) dbg(format, ##__VA_ARGS__) -# define blldbg(format, ...) lldbg(format, ##__VA_ARGS__) -# define binfo(format, ...) info(format, ##__VA_ARGS__) -# define bllinfo(format, ...) llinfo(format, ##__VA_ARGS__) +# define bdbg(format, ...) dbg(format, ##__VA_ARGS__) +# define blldbg(format, ...) lldbg(format, ##__VA_ARGS__) +# define bwarn(format, ...) warn(format, ##__VA_ARGS__) +# define bllwarn(format, ...) llwarn(format, ##__VA_ARGS__) +# define binfo(format, ...) info(format, ##__VA_ARGS__) +# define bllinfo(format, ...) llinfo(format, ##__VA_ARGS__) #else -# define bdbg(x...) -# define blldbg(x...) -# define binfo(x...) -# define bllinfo(x...) +# define bdbg(x...) +# define blldbg(x...) +# define bwarn(x...) +# define bllwarn(x...) +# define binfo(x...) +# define bllinfo(x...) #endif #ifdef CONFIG_DEBUG_LIB -# define ldbg(format, ...) dbg(format, ##__VA_ARGS__) -# define llldbg(format, ...) lldbg(format, ##__VA_ARGS__) -# define linfo(format, ...) info(format, ##__VA_ARGS__) -# define lllinfo(format, ...) llinfo(format, ##__VA_ARGS__) +# define ldbg(format, ...) dbg(format, ##__VA_ARGS__) +# define llldbg(format, ...) lldbg(format, ##__VA_ARGS__) +# define lwarn(format, ...) warn(format, ##__VA_ARGS__) +# define lllwarn(format, ...) llwarn(format, ##__VA_ARGS__) +# define linfo(format, ...) info(format, ##__VA_ARGS__) +# define lllinfo(format, ...) llinfo(format, ##__VA_ARGS__) #else -# define ldbg(x...) -# define llldbg(x...) -# define linfo(x...) -# define lllinfo(x...) +# define ldbg(x...) +# define llldbg(x...) +# define lwarn(x...) +# define lllwarn(x...) +# define linfo(x...) +# define lllinfo(x...) #endif #ifdef CONFIG_DEBUG_AUDIO -# define auddbg(format, ...) dbg(format, ##__VA_ARGS__) -# define audlldbg(format, ...) lldbg(format, ##__VA_ARGS__) -# define audinfo(format, ...) info(format, ##__VA_ARGS__) -# define audllinfo(format, ...) llinfo(format, ##__VA_ARGS__) +# define auddbg(format, ...) dbg(format, ##__VA_ARGS__) +# define audlldbg(format, ...) lldbg(format, ##__VA_ARGS__) +# define audwarn(format, ...) warn(format, ##__VA_ARGS__) +# define audllwarn(format, ...) llwarn(format, ##__VA_ARGS__) +# define audinfo(format, ...) info(format, ##__VA_ARGS__) +# define audllinfo(format, ...) llinfo(format, ##__VA_ARGS__) #else -# define auddbg(x...) -# define audlldbg(x...) -# define audinfo(x...) -# define audllinfo(x...) +# define auddbg(x...) +# define audlldbg(x...) +# define audwarn(x...) +# define audllwarn(x...) +# define audinfo(x...) +# define audllinfo(x...) #endif #else /* CONFIG_CPP_HAVE_VARARGS */ @@ -338,204 +425,272 @@ /* Variadic macros NOT supported */ #ifdef CONFIG_DEBUG -# ifndef CONFIG_ARCH_LOWPUTC -# define lldbg (void) -# endif -# ifndef CONFIG_DEBUG_INFO -# define info (void) -# define llinfo (void) -# else # ifndef CONFIG_ARCH_LOWPUTC -# define llinfo (void) +# define lldbg (void) # endif -# endif #else -# define dbg (void) -# define lldbg (void) -# define info (void) -# define llinfo (void) +# define dbg (void) +# define lldbg (void) +#endif + +#ifdef CONFIG_DEBUG_WARN +# ifndef CONFIG_ARCH_LOWPUTC +# define llwarn (void) +# endif +#else +# define warn (void) +# define llwarn (void) +#endif + +#ifdef CONFIG_DEBUG_INFO +# ifndef CONFIG_ARCH_LOWPUTC +# define llinfo (void) +# endif +#else +# define info (void) +# define llinfo (void) #endif /* Subsystem specific debug */ #ifdef CONFIG_DEBUG_MM -# define mdbg dbg -# define mlldbg lldbg -# define minfo info -# define mllinfo llinfo +# define mdbg dbg +# define mlldbg lldbg +# define mwarn warn +# define mllwarn llwarn +# define minfo info +# define mllinfo llinfo #else -# define mdbg (void) -# define mlldbg (void) -# define minfo (void) -# define mllinfo (void) +# define mdbg (void) +# define mlldbg (void) +# define mwarn (void) +# define mllwarn (void) +# define minfo (void) +# define mllinfo (void) #endif #ifdef CONFIG_DEBUG_SCHED -# define sdbg dbg -# define slldbg lldbg -# define sinfo info -# define sllinfo llinfo +# define sdbg dbg +# define slldbg lldbg +# define swarn warn +# define sllwarn llwarn +# define sinfo info +# define sllinfo llinfo #else -# define sdbg (void) -# define slldbg (void) -# define sinfo (void) -# define sllinfo (void) +# define sdbg (void) +# define slldbg (void) +# define swarn (void) +# define sllwarn (void) +# define sinfo (void) +# define sllinfo (void) #endif #ifdef CONFIG_DEBUG_PAGING -# define pgdbg dbg -# define pglldbg lldbg -# define pginfo info -# define pgllinfo llinfo +# define pgdbg dbg +# define pglldbg lldbg +# define pgwarn warn +# define pgllwarn llwarn +# define pginfo info +# define pgllinfo llinfo #else -# define pgdbg (void) -# define pglldbg (void) -# define pginfo (void) -# define pgllinfo (void) +# define pgdbg (void) +# define pglldbg (void) +# define pgwarn (void) +# define pgllwarn (void) +# define pginfo (void) +# define pgllinfo (void) #endif #ifdef CONFIG_DEBUG_DMA -# define dmadbg dbg -# define dmalldbg lldbg -# define dmainfo info -# define dmallinfo llinfo +# define dmadbg dbg +# define dmalldbg lldbg +# define dmawarn warn +# define dmallwarn llwarn +# define dmainfo info +# define dmallinfo llinfo #else -# define dmadbg (void) -# define dmalldbg (void) -# define dmainfo (void) -# define dmallinfo (void) +# define dmadbg (void) +# define dmalldbg (void) +# define dmawarn (void) +# define dmallwarn (void) +# define dmainfo (void) +# define dmallinfo (void) #endif #ifdef CONFIG_DEBUG_NET -# define ndbg dbg -# define nlldbg lldbg -# define ninfo info -# define nllinfo llinfo +# define ndbg dbg +# define nlldbg lldbg +# define nwarn warn +# define nllwarn llwarn +# define ninfo info +# define nllinfo llinfo #else -# define ndbg (void) -# define nlldbg (void) -# define ninfo (void) -# define nllinfo (void) +# define ndbg (void) +# define nlldbg (void) +# define nwarn (void) +# define nllwarn (void) +# define ninfo (void) +# define nllinfo (void) #endif #ifdef CONFIG_DEBUG_USB -# define udbg dbg -# define ulldbg lldbg -# define uinfo info -# define ullinfo llinfo +# define udbg dbg +# define ulldbg lldbg +# define uwarn warn +# define ullwarn llwarn +# define uinfo info +# define ullinfo llinfo #else -# define udbg (void) -# define ulldbg (void) -# define uinfo (void) -# define ullinfo (void) +# define udbg (void) +# define ulldbg (void) +# define uwarn (void) +# define ullwarn (void) +# define uinfo (void) +# define ullinfo (void) #endif #ifdef CONFIG_DEBUG_FS -# define fdbg dbg -# define flldbg lldbg -# define finfo info -# define fllinfo llinfo +# define fdbg dbg +# define flldbg lldbg +# define fwarn warn +# define fllwarn llwarn +# define finfo info +# define fllinfo llinfo #else -# define fdbg (void) -# define flldbg (void) -# define finfo (void) -# define fllinfo (void) +# define fdbg (void) +# define flldbg (void) +# define fwarn (void) +# define fllwarn (void) +# define finfo (void) +# define fllinfo (void) #endif #ifdef CONFIG_DEBUG_CRYPTO -# define cryptdbg dbg -# define cryptlldbg lldbg -# define cryptinfo info -# define cryptllinfo llinfo +# define cryptdbg dbg +# define cryptlldbg lldbg +# define cryptwarn warn +# define cryptllwarn llwarn +# define cryptinfo info +# define cryptllinfo llinfo #else -# define cryptdbg (void) -# define cryptlldbg (void) -# define cryptinfo (void) -# define cryptllinfo (void) +# define cryptdbg (void) +# define cryptlldbg (void) +# define cryptwarn (void) +# define cryptllwarn (void) +# define cryptinfo (void) +# define cryptllinfo (void) #endif #ifdef CONFIG_DEBUG_INPUT -# define idbg dbg -# define illdbg lldbg -# define iinfo info -# define illinfo llinfo +# define idbg dbg +# define illdbg lldbg +# define iwarn warn +# define illwarn llwarn +# define iinfo info +# define illinfo llinfo #else -# define idbg (void) -# define illdbg (void) -# define iinfo (void) -# define illinfo (void) +# define idbg (void) +# define illdbg (void) +# define iwarn (void) +# define illwarn (void) +# define iinfo (void) +# define illinfo (void) #endif #ifdef CONFIG_DEBUG_SENSORS -# define sndbg dbg -# define snlldbg lldbg -# define sninfo info -# define snllinfo llinfo +# define sndbg dbg +# define snlldbg lldbg +# define snwarn warn +# define snllwarn llwarn +# define sninfo info +# define snllinfo llinfo #else -# define sndbg (void) -# define snlldbg (void) -# define sninfo (void) -# define snllinfo (void) +# define sndbg (void) +# define snlldbg (void) +# define snwarn (void) +# define snllwarn (void) +# define sninfo (void) +# define snllinfo (void) #endif #ifdef CONFIG_DEBUG_ANALOG -# define adbg dbg -# define alldbg lldbg -# define ainfo info -# define allinfo llinfo +# define adbg dbg +# define alldbg lldbg +# define awarn warn +# define allwarn llwarn +# define ainfo info +# define allinfo llinfo #else -# define adbg (void) -# define alldbg (void) -# define ainfo (void) -# define allinfo (void) +# define adbg (void) +# define alldbg (void) +# define awarn (void) +# define allwarn (void) +# define ainfo (void) +# define allinfo (void) #endif #ifdef CONFIG_DEBUG_GRAPHICS -# define gdbg dbg -# define glldbg lldbg -# define ginfo info -# define gllinfo llinfo +# define gdbg dbg +# define glldbg lldbg +# define gwarn warn +# define gllwarn llwarn +# define ginfo info +# define gllinfo llinfo #else -# define gdbg (void) -# define glldbg (void) -# define ginfo (void) -# define gllinfo (void) +# define gdbg (void) +# define glldbg (void) +# define gwarn (void) +# define gllwarn (void) +# define ginfo (void) +# define gllinfo (void) #endif #ifdef CONFIG_DEBUG_BINFMT -# define bdbg dbg -# define blldbg lldbg -# define binfo info -# define bllinfo llinfo +# define bdbg dbg +# define blldbg lldbg +# define bwarn warn +# define bllwarn llwarn +# define binfo info +# define bllinfo llinfo #else -# define bdbg (void) -# define blldbg (void) -# define binfo (void) -# define bllinfo (void) +# define bdbg (void) +# define blldbg (void) +# define bwarn (void) +# define bllwarn (void) +# define binfo (void) +# define bllinfo (void) #endif #ifdef CONFIG_DEBUG_LIB -# define ldbg dbg -# define llldbg lldbg -# define linfo info -# define lllinfo llinfo +# define ldbg dbg +# define llldbg lldbg +# define lwarn warn +# define lllwarn llwarn +# define linfo info +# define lllinfo llinfo #else -# define ldbg (void) -# define llldbg (void) -# define linfo (void) -# define lllinfo (void) +# define ldbg (void) +# define llldbg (void) +# define lwarn (void) +# define lllwarn (void) +# define linfo (void) +# define lllinfo (void) #endif #ifdef CONFIG_DEBUG_AUDIO -# define auddbg dbg -# define audlldbg lldbg -# define audinfo info -# define audllinfo llinfo +# define auddbg dbg +# define audlldbg lldbg +# define audwarn warn +# define audllwarn llwarn +# define audinfo info +# define audllinfo llinfo #else -# define auddbg (void) -# define audlldbg (void) -# define audinfo (void) -# define audllinfo (void) +# define auddbg (void) +# define audlldbg (void) +# define audwarn (void) +# define audllwarn (void) +# define audinfo (void) +# define audllinfo (void) #endif #endif /* CONFIG_CPP_HAVE_VARARGS */ @@ -690,15 +845,23 @@ int dbg(const char *format, ...); # ifdef CONFIG_ARCH_LOWPUTC int lldbg(const char *format, ...); # endif +#endif /* CONFIG_DEBUG */ -# ifdef CONFIG_DEBUG_INFO +#ifdef CONFIG_DEBUG_WARN +int warn(const char *format, ...); + +# ifdef CONFIG_ARCH_LOWPUTC +int llwarn(const char *format, ...); +# endif +#endif /* CONFIG_DEBUG_WARN */ + +#ifdef CONFIG_DEBUG_INFO int info(const char *format, ...); # ifdef CONFIG_ARCH_LOWPUTC int llinfo(const char *format, ...); # endif -#endif -#endif /* CONFIG_DEBUG */ +#endif /* CONFIG_DEBUG_INFO */ #endif /* CONFIG_CPP_HAVE_VARARGS */ #if defined(__cplusplus) diff --git a/libc/misc/lib_dbg.c b/libc/misc/lib_dbg.c index 3e398d90b9..ba9bec63ea 100644 --- a/libc/misc/lib_dbg.c +++ b/libc/misc/lib_dbg.c @@ -1,7 +1,7 @@ /**************************************************************************** * libc/misc/lib_dbg.c * - * Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2012, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -46,10 +46,6 @@ #ifndef CONFIG_CPP_HAVE_VARARGS -/**************************************************************************** - * Public Data - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -82,13 +78,42 @@ int lldbg(const char *format, ...) va_list ap; int ret; + va_start(ap, format); + ret = lowvsyslog(LOG_ERR, format, ap); + va_end(ap); + + return ret; +} +#endif /* CONFIG_ARCH_LOWPUTC */ +#endif /* CONFIG_DEBUG */ + +#ifdef CONFIG_DEBUG_WARN +int warn(const char *format, ...) +{ + va_list ap; + int ret; + + va_start(ap, format); + ret = vsyslog(LOG_WARNING, format, ap); + va_end(ap); + + return ret; +} + +#ifdef CONFIG_ARCH_LOWPUTC +int llwarn(const char *format, ...) +{ + va_list ap; + int ret; + va_start(ap, format); ret = lowvsyslog(LOG_DEBUG, format, ap); va_end(ap); return ret; } -#endif +#endif /* CONFIG_ARCH_LOWPUTC */ +#endif /* CONFIG_DEBUG_INFO */ #ifdef CONFIG_DEBUG_INFO int info(const char *format, ...) @@ -117,5 +142,5 @@ int llinfo(const char *format, ...) } #endif /* CONFIG_ARCH_LOWPUTC */ #endif /* CONFIG_DEBUG_INFO */ -#endif /* CONFIG_DEBUG */ + #endif /* CONFIG_CPP_HAVE_VARARGS */