![]() |
RainbowBS Manual
v0.1.0
Written by QWQ([email protected])
|
Table of Contents
Debug is important for software development and RBS contains a useful debug component.
Detail references to debug
Debug Features
- four optional debug levels:none,error,warning,log
- output re-targeting
- thread-safety support
Debug Usage
Four types debug macros are available.
debug statement
debug error output
RBS_DEBUG_ERROR_FORMAT(exp,format,...)
debug warning output
RBS_DEBUG_WARN_FORMAT(exp,format,...)
debug log output
RBS_DEBUG_LOG_FORMAT(format,...)
How to configure debug component
There are two macro configuration for debug component.
RBS_CFG_DEBUG_LEVEL
is the configuration for debug level.You can defineRBS_CFG_DEBUG_LEVEL
from one of the four optional debug levels macros.RBS_DEBUG_LEVEL_NOCHECK
disable all debug statement and outputRBS_DEBUG_LEVEL_ERRORS
only enable debug statement and debug error outputRBS_DEBUG_LEVEL_WARNINGS
debug warning output plusBS_DEBUG_LEVEL_ERRORS
RBS_DEBUG_LEVEL_ALL
debug log output plusBS_DEBUG_LEVEL_WARNINGS
RBS_CFG_DEBUG_BUFSIZE
cofigure the debug buffer size in bytes.Default size is 300 bytes.One output string length should not exceed debug buffer size.
How to port debug component
- Depending to debug level you configure
RBS_CFG_DEBUG_LEVEL
,different porting functions are needed.
And you can re-targeting output by these porting functions.RBS_DEBUG_LEVEL_ERRORS
needs:void Port_Printf_Error(const char *s) for debug error output
RBS_DEBUG_LEVEL_WARNINGS
needs:void Port_Printf_Error(const char *s) for debug error output
void Port_Printf_Warn(const char *s) for debug warning outputBS_DEBUG_LEVEL_ALL
needs:void Port_Printf_Error(const char *s) for debug error output
void Port_Printf_Warn(const char *s) for debug warning output
void Port_Printf_Log(const char *s) for debug log output
If application model
RBS_CFG_APP_MODEL
is configured toRBS_APP_OS
,then OS lock such as mutex or semaphore should used for thread-safe debug.Debug error output(
RBS_DEBUG_LEVEL_ERRORS
),debug warning output(RBS_DEBUG_LEVEL_WARNINGS
) and debug log(RBS_DEBUG_LEVEL_ALL
) output use the same lock. And three following porting functions should be present.BOOL Port_Init(void) for creating debug lock
BOOL Port_GetMutex(HMUTEX hMutex) for lock debug output
BOOL Port_FreeMutex(HMUTEX hMutex) for unlock debug output
Generated by
