forked from Archive/PX4-Autopilot
Add interface to enabled/disable debug output
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4386 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
parent
686d0f0daa
commit
acf1031af3
|
@ -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.
|
||||
|
||||
|
|
|
@ -3729,6 +3729,9 @@ build
|
|||
If only <code>CONFIG_DEBUG</code> then the only output will be errors, warnings, and critical information.
|
||||
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.
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
#
|
||||
|
|
|
@ -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
|
||||
|
||||
#
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -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
|
||||
****************************************************************************/
|
||||
|
|
|
@ -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
|
||||
|
@ -44,10 +44,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
|
||||
*
|
||||
|
@ -64,9 +89,16 @@ int dbg(const char *format, ...)
|
|||
va_list ap;
|
||||
int ret;
|
||||
|
||||
#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;
|
||||
|
||||
#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;
|
||||
|
||||
#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;
|
||||
|
||||
#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 */
|
||||
|
|
|
@ -111,9 +111,16 @@ int lib_lowprintf(const char *fmt, ...)
|
|||
va_list ap;
|
||||
int ret;
|
||||
|
||||
#ifdef CONFIG_DEBUG_ENABLE
|
||||
ret = 0;
|
||||
if (g_dbgenable)
|
||||
#endif
|
||||
{
|
||||
va_start(ap, fmt);
|
||||
ret= lib_lowvprintf(fmt, ap);
|
||||
ret = lib_lowvprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -137,8 +137,15 @@ int lib_rawprintf(const char *fmt, ...)
|
|||
va_list ap;
|
||||
int ret;
|
||||
|
||||
#ifdef CONFIG_DEBUG_ENABLE
|
||||
ret = 0;
|
||||
if (g_dbgenable)
|
||||
#endif
|
||||
{
|
||||
va_start(ap, fmt);
|
||||
ret= lib_rawvprintf(fmt, ap);
|
||||
ret = lib_rawvprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue