diff options
Diffstat (limited to 'nuttx/lib')
-rw-r--r-- | nuttx/lib/lib_internal.h | 10 | ||||
-rw-r--r-- | nuttx/lib/misc/lib_dbg.c | 79 | ||||
-rw-r--r-- | nuttx/lib/stdio/lib_lowprintf.c | 13 | ||||
-rw-r--r-- | nuttx/lib/stdio/lib_rawprintf.c | 13 |
4 files changed, 94 insertions, 21 deletions
diff --git a/nuttx/lib/lib_internal.h b/nuttx/lib/lib_internal.h index d960d6cf3..29d49303d 100644 --- a/nuttx/lib/lib_internal.h +++ b/nuttx/lib/lib_internal.h @@ -1,8 +1,8 @@ /**************************************************************************** * lib/lib_internal.h * - * Copyright (C) 2007-2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Copyright (C) 2007-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -99,6 +99,12 @@ * Public Variables ****************************************************************************/ +/* Debug output is initially disabled */ + +#ifdef CONFIG_DEBUG_ENABLE +extern bool g_dbgenable; +#endif + /**************************************************************************** * Public Function Prototypes ****************************************************************************/ diff --git a/nuttx/lib/misc/lib_dbg.c b/nuttx/lib/misc/lib_dbg.c index e4b1071cd..6f326bf4f 100644 --- a/nuttx/lib/misc/lib_dbg.c +++ b/nuttx/lib/misc/lib_dbg.c @@ -1,7 +1,7 @@ /**************************************************************************** * lib/misc/lib_dbg.c * - * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -45,10 +45,35 @@ #include "lib_internal.h" /**************************************************************************** + * Global Variables + ****************************************************************************/ + +/* Debug output is initially disabled */ + +#ifdef CONFIG_DEBUG_ENABLE +bool g_dbgenable; +#endif + +/**************************************************************************** * Global Functions ****************************************************************************/ /**************************************************************************** + * Name: dbg_enable + * + * Description: + * Enable or disable debug output. + * + ****************************************************************************/ + +#ifdef CONFIG_DEBUG_ENABLE +void dbg_enable(bool enable) +{ + g_dbgenable = enable; +} +#endif + +/**************************************************************************** * Name: dbg, lldbg, vdbg * * Description: @@ -64,9 +89,16 @@ int dbg(const char *format, ...) va_list ap; int ret; - va_start(ap, format); - ret = lib_rawvprintf(format, ap); - va_end(ap); +#ifdef CONFIG_DEBUG_ENABLE + ret = 0; + if (g_dbgenable) +#endif + { + va_start(ap, format); + ret = lib_rawvprintf(format, ap); + va_end(ap); + } + return ret; } @@ -76,9 +108,16 @@ int lldbg(const char *format, ...) va_list ap; int ret; - va_start(ap, format); - ret = lib_lowvprintf(format, ap); - va_end(ap); +#ifdef CONFIG_DEBUG_ENABLE + ret = 0; + if (g_dbgenable) +#endif + { + va_start(ap, format); + ret = lib_lowvprintf(format, ap); + va_end(ap); + } + return ret; } #endif @@ -89,9 +128,16 @@ int vdbg(const char *format, ...) va_list ap; int ret; - va_start(ap, format); - ret = lib_rawvprintf(format, ap); - va_end(ap); +#ifdef CONFIG_DEBUG_ENABLE + ret = 0; + if (g_dbgenable) +#endif + { + va_start(ap, format); + ret = lib_rawvprintf(format, ap); + va_end(ap); + } + return ret; } @@ -101,9 +147,16 @@ int llvdbg(const char *format, ...) va_list ap; int ret; - va_start(ap, format); - ret = lib_lowvprintf(format, ap); - va_end(ap); +#ifdef CONFIG_DEBUG_ENABLE + ret = 0; + if (g_dbgenable) +#endif + { + va_start(ap, format); + ret = lib_lowvprintf(format, ap); + va_end(ap); + } + return ret; } #endif /* CONFIG_ARCH_LOWPUTC */ diff --git a/nuttx/lib/stdio/lib_lowprintf.c b/nuttx/lib/stdio/lib_lowprintf.c index e27a5021b..50a6568fb 100644 --- a/nuttx/lib/stdio/lib_lowprintf.c +++ b/nuttx/lib/stdio/lib_lowprintf.c @@ -111,9 +111,16 @@ int lib_lowprintf(const char *fmt, ...) va_list ap; int ret; - va_start(ap, fmt); - ret= lib_lowvprintf(fmt, ap); - va_end(ap); +#ifdef CONFIG_DEBUG_ENABLE + ret = 0; + if (g_dbgenable) +#endif + { + va_start(ap, fmt); + ret = lib_lowvprintf(fmt, ap); + va_end(ap); + } + return ret; } diff --git a/nuttx/lib/stdio/lib_rawprintf.c b/nuttx/lib/stdio/lib_rawprintf.c index a28e6b695..19dfa895e 100644 --- a/nuttx/lib/stdio/lib_rawprintf.c +++ b/nuttx/lib/stdio/lib_rawprintf.c @@ -137,8 +137,15 @@ int lib_rawprintf(const char *fmt, ...) va_list ap; int ret; - va_start(ap, fmt); - ret= lib_rawvprintf(fmt, ap); - va_end(ap); +#ifdef CONFIG_DEBUG_ENABLE + ret = 0; + if (g_dbgenable) +#endif + { + va_start(ap, fmt); + ret = lib_rawvprintf(fmt, ap); + va_end(ap); + } + return ret; } |