* _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
This commit is contained in:
Axel Dörfler 2008-03-05 19:41:05 +00:00
parent c7c07366e0
commit d401b8f030

View File

@ -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;