summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-02-12 23:54:26 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-02-12 23:54:26 +0000
commitc2079e368c183a100c549671925b66d6b993c8c2 (patch)
tree6e9e40c95947255b743c4a08926a407360d2a19c
parenta8d12f6d37d46732011e008ac8252c4a3183e182 (diff)
downloadnuttx-c2079e368c183a100c549671925b66d6b993c8c2.tar.gz
nuttx-c2079e368c183a100c549671925b66d6b993c8c2.tar.bz2
nuttx-c2079e368c183a100c549671925b66d6b993c8c2.zip
Add interface to enabled/disable debug output
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4386 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/ChangeLog2
-rw-r--r--nuttx/Documentation/NuttxPortingGuide.html3
-rw-r--r--nuttx/arch/sim/src/up_initialize.c13
-rw-r--r--nuttx/arch/sim/src/up_internal.h23
-rw-r--r--nuttx/configs/README.txt1
-rw-r--r--nuttx/configs/stm3240g-eval/nsh/defconfig2
-rw-r--r--nuttx/configs/stm3240g-eval/nsh2/defconfig2
-rw-r--r--nuttx/drivers/ramlog.c24
-rw-r--r--nuttx/include/assert.h4
-rw-r--r--nuttx/include/debug.h6
-rw-r--r--nuttx/include/nuttx/ramlog.h4
-rw-r--r--nuttx/lib/lib_internal.h10
-rw-r--r--nuttx/lib/misc/lib_dbg.c79
-rw-r--r--nuttx/lib/stdio/lib_lowprintf.c13
-rw-r--r--nuttx/lib/stdio/lib_rawprintf.c13
15 files changed, 149 insertions, 50 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 77d4c443d..d6874bbca 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -2456,4 +2456,6 @@
* lib/stdio/lib_syslogstream: Add a stream object that will be used to
re-direct all debug output to the RAM log if CONFIG_SYSLOG and
CONFIG_RAMLOG_SYSLOG are defined.
+ * lib/misc/lib_dbg.c: Add an interface enabled with CONFIG_DEBUG_ENABLE that
+ can be used to turn debug output on and off.
diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html
index 4b562057d..62f795887 100644
--- a/nuttx/Documentation/NuttxPortingGuide.html
+++ b/nuttx/Documentation/NuttxPortingGuide.html
@@ -3730,6 +3730,9 @@ build
If <code>CONFIG_DEBUG_VERBOSE</code> is defined in addition, then general debug comments will also be included in the console output.
</li>
<li>
+ <code>CONFIG_DEBUG_ENABLE</code>: Support an interface to enable or disable debug output.
+ </li>
+ <li>
<code>CONFIG_DEBUG_SYMBOLS</code>: build without optimization and with debug symbols (needed for use with a debugger).
This option has nothing to do with debug output.
</li>
diff --git a/nuttx/arch/sim/src/up_initialize.c b/nuttx/arch/sim/src/up_initialize.c
index 488f2431e..66fb11b9a 100644
--- a/nuttx/arch/sim/src/up_initialize.c
+++ b/nuttx/arch/sim/src/up_initialize.c
@@ -51,12 +51,6 @@
* Private Definitions
****************************************************************************/
-/* Determine which device to use as the system logging device */
-
-#ifndef CONFIG_SYSLOG
-# undef CONFIG_RAMLOG_SYSLOG
-#endif
-
/****************************************************************************
* Private Data
****************************************************************************/
@@ -104,7 +98,14 @@ void up_initialize(void)
devnull_register(); /* Standard /dev/null */
devzero_register(); /* Standard /dev/zero */
+
+ /* Register a console (or not) */
+
+#if defined(USE_DEVCONSOLE)
up_devconsole(); /* Our private /dev/console */
+#elif defined(CONFIG_RAMLOG_CONSOLE)
+ ramlog_consoleinit();
+#endif
#ifdef CONFIG_RAMLOG_SYSLOG
ramlog_sysloginit(); /* System logging device */
diff --git a/nuttx/arch/sim/src/up_internal.h b/nuttx/arch/sim/src/up_internal.h
index 194191de0..343a4b39b 100644
--- a/nuttx/arch/sim/src/up_internal.h
+++ b/nuttx/arch/sim/src/up_internal.h
@@ -1,8 +1,8 @@
/**************************************************************************
* up_internal.h
*
- * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Copyright (C) 2007, 2009, 2011-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
@@ -63,6 +63,25 @@
# endif
#endif
+/* Determine which (if any) console driver to use */
+
+#if !defined(CONFIG_DEV_CONSOLE) || CONFIG_NFILE_DESCRIPTORS == 0
+# undef USE_DEVCONSOLE
+# undef CONFIG_RAMLOG_CONSOLE
+#else
+# if defined(CONFIG_RAMLOG_CONSOLE)
+# undef USE_DEVCONSOLE
+# else
+# define USE_DEVCONSOLE 1
+# endif
+#endif
+
+/* Determine which device to use as the system logging device */
+
+#ifndef CONFIG_SYSLOG
+# undef CONFIG_RAMLOG_SYSLOG
+#endif
+
/* Context Switching Definitions ******************************************/
/* Storage order: %ebx, $esi, %edi, %ebp, sp, and return PC */
diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt
index 81473b73b..6df735970 100644
--- a/nuttx/configs/README.txt
+++ b/nuttx/configs/README.txt
@@ -246,6 +246,7 @@ defconfig -- This is a configuration file similar to the Linux
CONFIG_DEBUG - enables built-in debug options
CONFIG_DEBUG_VERBOSE - enables verbose debug output
+ CCONFIG_DEBUG_ENABLE - Support an interface to enable or disable debug output.
CONFIG_DEBUG_SYMBOLS - build without optimization and with
debug symbols (needed for use with a debugger).
CONFIG_DEBUG_SCHED - enable OS debug output (disabled by
diff --git a/nuttx/configs/stm3240g-eval/nsh/defconfig b/nuttx/configs/stm3240g-eval/nsh/defconfig
index 712d25458..c82ebc04d 100644
--- a/nuttx/configs/stm3240g-eval/nsh/defconfig
+++ b/nuttx/configs/stm3240g-eval/nsh/defconfig
@@ -679,7 +679,7 @@ CONFIG_NUNGET_CHARS=2
CONFIG_PREALLOC_MQ_MSGS=4
CONFIG_MQ_MAXMSGSIZE=32
CONFIG_MAX_WDOGPARMS=2
-CONFIG_PREALLOC_WDOGS=4
+CONFIG_PREALLOC_WDOGS=8
CONFIG_PREALLOC_TIMERS=4
#
diff --git a/nuttx/configs/stm3240g-eval/nsh2/defconfig b/nuttx/configs/stm3240g-eval/nsh2/defconfig
index 3afb83151..df2d3eec4 100644
--- a/nuttx/configs/stm3240g-eval/nsh2/defconfig
+++ b/nuttx/configs/stm3240g-eval/nsh2/defconfig
@@ -679,7 +679,7 @@ CONFIG_NUNGET_CHARS=2
CONFIG_PREALLOC_MQ_MSGS=4
CONFIG_MQ_MAXMSGSIZE=32
CONFIG_MAX_WDOGPARMS=2
-CONFIG_PREALLOC_WDOGS=4
+CONFIG_PREALLOC_WDOGS=16
CONFIG_PREALLOC_TIMERS=4
#
diff --git a/nuttx/drivers/ramlog.c b/nuttx/drivers/ramlog.c
index b3dd81b65..e3cd057a7 100644
--- a/nuttx/drivers/ramlog.c
+++ b/nuttx/drivers/ramlog.c
@@ -402,6 +402,9 @@ errout_without_sem:
ramlog_pollnotify(priv, POLLOUT);
}
#endif
+
+ /* Return the number of characters actually read */
+
return nread;
}
@@ -502,9 +505,12 @@ static ssize_t ramlog_write(FAR struct file *filep, FAR const char *buffer, size
}
#endif
- /* Return the number of bytes written */
+ /* We always have to return the number of bytes requested and NOT the
+ * number of bytes that were actually written. Otherwise, callers
+ * will think that this is a short write and probably retry (causing
+ */
- return nwritten;
+ return len;
}
/****************************************************************************
@@ -688,16 +694,6 @@ int ramlog_consoleinit(void)
/* Register the console character driver */
ret = register_driver("/dev/console", &g_ramlogfops, 0666, priv);
-
- /* Register the syslog character driver */
-
-#ifdef CONFIG_RAMLOG_SYSLOG
- if (ret >= 0)
- {
- ret = register_driver("/dev/syslog", &g_ramlogfops, 0666, priv);
- }
-#endif
- return ret;
}
#endif
@@ -713,9 +709,11 @@ int ramlog_consoleinit(void)
*
****************************************************************************/
-#if !defined(CONFIG_RAMLOG_CONSOLE) && defined(CONFIG_RAMLOG_SYSLOG)
+#ifdef CONFIG_RAMLOG_SYSLOG
int ramlog_sysloginit(void)
{
+ /* Register the syslog character driver */
+
return register_driver("/dev/syslog", &g_ramlogfops, 0666, &g_sysdev);
}
#endif
diff --git a/nuttx/include/assert.h b/nuttx/include/assert.h
index c666d528c..89606b6f6 100644
--- a/nuttx/include/assert.h
+++ b/nuttx/include/assert.h
@@ -1,8 +1,8 @@
/****************************************************************************
* include/assert.h
*
- * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Copyright (C) 2007-2009, 2011-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
diff --git a/nuttx/include/debug.h b/nuttx/include/debug.h
index 5cfe1e601..c8666ff57 100644
--- a/nuttx/include/debug.h
+++ b/nuttx/include/debug.h
@@ -596,6 +596,12 @@ EXTERN int lib_lowprintf(FAR const char *format, ...);
EXTERN void lib_dumpbuffer(FAR const char *msg, FAR const uint8_t *buffer,
unsigned int buflen);
+/* Enable or disable debug output */
+
+#ifdef CONFIG_DEBUG_ENABLE
+EXTERN void dbg_enable(bool enable);
+#endif
+
/* If the cross-compiler's pre-processor does not support variable
* length arguments, then these additional APIs will be built.
*/
diff --git a/nuttx/include/nuttx/ramlog.h b/nuttx/include/nuttx/ramlog.h
index eeef494ed..c2c75e067 100644
--- a/nuttx/include/nuttx/ramlog.h
+++ b/nuttx/include/nuttx/ramlog.h
@@ -188,11 +188,7 @@ EXTERN int ramlog_consoleinit(void);
****************************************************************************/
#ifdef CONFIG_RAMLOG_SYSLOG
-#ifndef CONFIG_RAMLOG_CONSOLE
EXTERN int ramlog_sysloginit(void);
-#else
-# define ramlog_sysloginit()
-#endif
#endif
/****************************************************************************
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;
}