From d401b8f030d92342ce500c6b7631b624d2bf7535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 5 Mar 2008 19:41:05 +0000 Subject: [PATCH] * _rtDebugFlag is supposed to default to true (is usually only used when DEBUG is defined, anyway). This fixes bug #1892. * _debugPrintf() and _sPrintf() are supposed to be silent when _rtDebugFlag is false. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24243 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/libroot/os/debug.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/system/libroot/os/debug.c b/src/system/libroot/os/debug.c index a5dc44f787..d689552d34 100644 --- a/src/system/libroot/os/debug.c +++ b/src/system/libroot/os/debug.c @@ -1,5 +1,5 @@ /* - * Copyright 2002-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -54,6 +54,8 @@ static const debug_string_entry sDebugExceptionTypeStrings[] = { { NULL, 0 } }; +bool _rtDebugFlag = true; + void debugger(const char *message) @@ -180,14 +182,8 @@ get_debug_exception_string(debug_exception_type exception, char *buffer, } -// #pragma mark - -// Debug.h functions +// #pragma mark - Debug.h functions -// TODO: verify these functions -// TODO: add implementations for printfs? - - -bool _rtDebugFlag = false; bool _debugFlag(void) @@ -211,6 +207,9 @@ _debugPrintf(const char *fmt, ...) va_list ap; int ret; + if (!_rtDebugFlag) + return 0; + va_start(ap, fmt); ret = vfprintf(stdout, fmt, ap); va_end(ap); @@ -222,10 +221,13 @@ _debugPrintf(const char *fmt, ...) int _sPrintf(const char *fmt, ...) { - char buffer[1024]; + char buffer[512]; va_list ap; int ret; + if (!_rtDebugFlag) + return 0; + va_start(ap, fmt); ret = vsnprintf(buffer, sizeof(buffer), fmt, ap); va_end(ap); @@ -238,7 +240,7 @@ _sPrintf(const char *fmt, ...) int -_xdebugPrintf(const char * fmt, ...) +_xdebugPrintf(const char *fmt, ...) { va_list ap; int ret; @@ -252,14 +254,15 @@ _xdebugPrintf(const char * fmt, ...) int -_debuggerAssert(const char * file, int line, char *message) +_debuggerAssert(const char *file, int line, char *message) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "Assert failed: File: %s, Line: %d, %s", file, line, message); - - debug_printf("%ld: ASSERT: %s\n", find_thread(NULL), buffer); + + debug_printf("%ld: ASSERT: %s:%d %s\n", find_thread(NULL), file, line, + buffer); _kern_debugger(buffer); return 0;