Added function dprintf_no_syslog(). It is basically equivalent to

dprintf() with the exception that it doesn't write anything to the
syslog. The reason is that syslog_write() releases a semaphore and can
therefore not be invoked when the thread spinlock is held.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22428 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2007-10-03 22:14:53 +00:00
parent 0e69ce7702
commit 76ab7bdcf8
2 changed files with 36 additions and 11 deletions

View File

@ -9,7 +9,7 @@
#define _KERNEL_DEBUG_H
#include <OS.h>
#include <KernelExport.h>
#define KDEBUG 1
@ -27,7 +27,7 @@
#define ASSERT_ALWAYS_PRINT(x, format...) \
do { \
if (!(x)) { \
dprintf(format); \
dprintf_no_syslog(format); \
panic("ASSERT FAILED (%s:%d): %s\n", __FILE__, __LINE__, #x); \
} \
} while (0)
@ -56,6 +56,9 @@ extern void debug_puts(const char *s, int32 length);
extern bool debug_debugger_running(void);
extern void debug_stop_screen_debug_output(void);
extern void dprintf_no_syslog(const char *format, ...)
__attribute__ ((format (__printf__, 1, 2)));
extern void _user_debug_output(const char *userString);
#ifdef __cplusplus

View File

@ -972,16 +972,12 @@ check_pending_repeats(void *data, int iter)
}
void
dprintf(const char *format, ...)
static void
dprintf_args(const char *format, va_list args, bool syslogOutput)
{
cpu_status state;
va_list args;
int32 length;
if (!sSerialDebugEnabled && !sSyslogOutputEnabled && !sBlueScreenEnabled)
return;
// ToDo: maybe add a non-interrupt buffer and path that only
// needs to acquire a semaphore instead of needing to disable
// interrupts?
@ -989,9 +985,7 @@ dprintf(const char *format, ...)
state = disable_interrupts();
acquire_spinlock(&sSpinlock);
va_start(args, format);
length = vsnprintf(sOutputBuffer, OUTPUT_BUFFER_SIZE, format, args);
va_end(args);
if (length >= OUTPUT_BUFFER_SIZE)
length = OUTPUT_BUFFER_SIZE - 1;
@ -1005,7 +999,7 @@ dprintf(const char *format, ...)
if (sSerialDebugEnabled)
arch_debug_serial_puts(sOutputBuffer);
if (sSyslogOutputEnabled)
if (syslogOutput)
syslog_write(sOutputBuffer, length);
if (sBlueScreenEnabled || sDebugScreenEnabled)
blue_screen_puts(sOutputBuffer);
@ -1019,6 +1013,34 @@ dprintf(const char *format, ...)
}
void
dprintf(const char *format, ...)
{
va_list args;
if (!sSerialDebugEnabled && !sSyslogOutputEnabled && !sBlueScreenEnabled)
return;
va_start(args, format);
dprintf_args(format, args, sSyslogOutputEnabled);
va_end(args);
}
void
dprintf_no_syslog(const char *format, ...)
{
va_list args;
if (!sSerialDebugEnabled && !sBlueScreenEnabled)
return;
va_start(args, format);
dprintf_args(format, args, false);
va_end(args);
}
/** Similar to dprintf() but thought to be used in the kernel
* debugger only (it doesn't lock).
*/