packagefs: Add va-args version ERRORV() to DebugSupport
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2009, Ingo Weinhold, [email protected].
|
* Copyright 2003-2013, Ingo Weinhold, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -127,24 +127,29 @@ dbg_printf_end()
|
|||||||
|
|
||||||
#if DEBUG_PRINT
|
#if DEBUG_PRINT
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
dbg_printf(const char *format,...)
|
dbg_vprintf(const char* format, va_list args)
|
||||||
{
|
{
|
||||||
if (!dbg_printf_lock())
|
if (!dbg_printf_lock())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
va_list args;
|
vsnprintf(buffer, sizeof(buffer) - 1, format, args);
|
||||||
va_start(args, format);
|
|
||||||
// no vsnprintf() on PPC and in kernel
|
|
||||||
#if defined(__INTEL__) && USER
|
|
||||||
vsnprintf(buffer, sizeof(buffer) - 1, format, args);
|
|
||||||
#else
|
|
||||||
vsprintf(buffer, format, args);
|
|
||||||
#endif
|
|
||||||
va_end(args);
|
|
||||||
buffer[sizeof(buffer) - 1] = '\0';
|
|
||||||
write(out, buffer, strlen(buffer));
|
write(out, buffer, strlen(buffer));
|
||||||
|
|
||||||
dbg_printf_unlock();
|
dbg_printf_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
dbg_printf(const char* format,...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, format);
|
||||||
|
dbg_vprintf(format, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // DEBUG_PRINT
|
#endif // DEBUG_PRINT
|
||||||
|
|||||||
@@ -44,16 +44,20 @@
|
|||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# if DEBUG_PRINT
|
# if DEBUG_PRINT
|
||||||
# define __out dbg_printf
|
# define __out dbg_printf
|
||||||
|
# define __outv dbg_vprintf
|
||||||
# else
|
# else
|
||||||
# define __out printf
|
# define __out printf
|
||||||
|
# define __outv vprintf
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
# include <KernelExport.h>
|
# include <KernelExport.h>
|
||||||
# include <null.h>
|
# include <null.h>
|
||||||
# if DEBUG_PRINT
|
# if DEBUG_PRINT
|
||||||
# define __out dbg_printf
|
# define __out dbg_printf
|
||||||
|
# define __outv dbg_vprintf
|
||||||
# else
|
# else
|
||||||
# define __out dprintf
|
# define __out dprintf
|
||||||
|
# define __outv dvprintf
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -74,18 +78,23 @@ status_t exit_debugging();
|
|||||||
void dbg_printf_begin();
|
void dbg_printf_begin();
|
||||||
void dbg_printf_end();
|
void dbg_printf_end();
|
||||||
#if DEBUG_PRINT
|
#if DEBUG_PRINT
|
||||||
void dbg_printf(const char *format,...);
|
void dbg_vprintf(const char* format, va_list args);
|
||||||
|
void dbg_printf(const char* format,...);
|
||||||
#else
|
#else
|
||||||
static inline void dbg_printf(const char *,...) {}
|
static inline void dbg_vprintf(const char*, va_list) {}
|
||||||
|
static inline void dbg_printf(const char*,...) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Short overview over the debug output macros:
|
// Short overview of the debug output macros:
|
||||||
// PRINT()
|
// PRINT()
|
||||||
// is for general messages that very unlikely should appear in a release
|
// general messages that shouldn't appear in a release build
|
||||||
// build
|
|
||||||
// FATAL()
|
// FATAL()
|
||||||
// this is for fatal messages, when something has really gone wrong
|
// fatal messages, when something has really gone wrong
|
||||||
|
// ERROR()
|
||||||
|
// non-fatal error messages
|
||||||
|
// WARN()
|
||||||
|
// warning messages
|
||||||
// INFORM()
|
// INFORM()
|
||||||
// general information, as disk size, etc.
|
// general information, as disk size, etc.
|
||||||
// REPORT_ERROR(status_t)
|
// REPORT_ERROR(status_t)
|
||||||
@@ -121,7 +130,8 @@ void dbg_printf_end();
|
|||||||
dbg_printf_end(); \
|
dbg_printf_end(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TPRINT(x...) DEBUG_CONTEXT( __out(x) )
|
#define TPRINT(x...) DEBUG_CONTEXT( __out(x) )
|
||||||
|
#define TPRINTV(format, args) DEBUG_CONTEXT( __outv(format, args) )
|
||||||
#define TREPORT_ERROR(status) \
|
#define TREPORT_ERROR(status) \
|
||||||
DEBUG_CONTEXT_LINE( __out("%s\n", strerror(status)) )
|
DEBUG_CONTEXT_LINE( __out("%s\n", strerror(status)) )
|
||||||
#define TRETURN_ERROR(err) \
|
#define TRETURN_ERROR(err) \
|
||||||
@@ -147,10 +157,6 @@ void dbg_printf_end();
|
|||||||
#define REPORT_ERROR(status) TREPORT_ERROR(status)
|
#define REPORT_ERROR(status) TREPORT_ERROR(status)
|
||||||
#define RETURN_ERROR(err) TRETURN_ERROR(err)
|
#define RETURN_ERROR(err) TRETURN_ERROR(err)
|
||||||
#define SET_ERROR(var, err) TSET_ERROR(var, err)
|
#define SET_ERROR(var, err) TSET_ERROR(var, err)
|
||||||
#define FATAL(x...) DEBUG_CONTEXT( __out(x) )
|
|
||||||
#define ERROR(x...) DEBUG_CONTEXT( __out(x) )
|
|
||||||
#define WARN(x...) DEBUG_CONTEXT( __out(x) )
|
|
||||||
#define INFORM(x...) DEBUG_CONTEXT( __out(x) )
|
|
||||||
#define FUNCTION(x...) TFUNCTION(x)
|
#define FUNCTION(x...) TFUNCTION(x)
|
||||||
#define FUNCTION_START() TFUNCTION_START()
|
#define FUNCTION_START() TFUNCTION_START()
|
||||||
#define FUNCTION_END() TFUNCTION_END()
|
#define FUNCTION_END() TFUNCTION_END()
|
||||||
@@ -161,10 +167,6 @@ void dbg_printf_end();
|
|||||||
#define REPORT_ERROR(status) ;
|
#define REPORT_ERROR(status) ;
|
||||||
#define RETURN_ERROR(status) return status;
|
#define RETURN_ERROR(status) return status;
|
||||||
#define SET_ERROR(var, err) var = err;
|
#define SET_ERROR(var, err) var = err;
|
||||||
#define FATAL(x...) DEBUG_CONTEXT( __out(x) )
|
|
||||||
#define ERROR(x...) DEBUG_CONTEXT( __out(x) )
|
|
||||||
#define WARN(x...) DEBUG_CONTEXT( __out(x) )
|
|
||||||
#define INFORM(x...) DEBUG_CONTEXT( __out(x) )
|
|
||||||
#define FUNCTION(x...) ;
|
#define FUNCTION(x...) ;
|
||||||
#define FUNCTION_START() ;
|
#define FUNCTION_START() ;
|
||||||
#define FUNCTION_END() ;
|
#define FUNCTION_END() ;
|
||||||
@@ -172,6 +174,12 @@ void dbg_printf_end();
|
|||||||
#define D(x) ;
|
#define D(x) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define FATAL(x...) TPRINT(x)
|
||||||
|
#define ERROR(x...) TPRINT(x)
|
||||||
|
#define ERRORV(format, args) TPRINTV(format, args)
|
||||||
|
#define WARN(x...) TPRINT(x)
|
||||||
|
#define INFORM(x...) TPRINT(x)
|
||||||
|
|
||||||
#ifndef TOUCH
|
#ifndef TOUCH
|
||||||
#define TOUCH(var) (void)var
|
#define TOUCH(var) (void)var
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user