![]() |
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_LEVELis the configuration for debug level.You can defineRBS_CFG_DEBUG_LEVELfrom one of the four optional debug levels macros.RBS_DEBUG_LEVEL_NOCHECKdisable all debug statement and outputRBS_DEBUG_LEVEL_ERRORSonly enable debug statement and debug error outputRBS_DEBUG_LEVEL_WARNINGSdebug warning output plusBS_DEBUG_LEVEL_ERRORSRBS_DEBUG_LEVEL_ALLdebug log output plusBS_DEBUG_LEVEL_WARNINGS
RBS_CFG_DEBUG_BUFSIZEcofigure 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_ERRORSneeds:void Port_Printf_Error(const char *s) for debug error output
RBS_DEBUG_LEVEL_WARNINGSneeds:void Port_Printf_Error(const char *s) for debug error output
void Port_Printf_Warn(const char *s) for debug warning outputBS_DEBUG_LEVEL_ALLneeds: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_MODELis 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
1.8.9.1
