ChibiOS  20.3.4
Checks and Assertions
Collaboration diagram for Checks and Assertions:

Detailed Description

Debug APIs and services:

Note
Stack checks are not implemented in this module but in the port layer in an architecture-dependent way.

Debug related settings

#define CH_DBG_STACK_FILL_VALUE   0x55
 Fill value for thread stack area in debug mode. More...
 

Macro Functions

#define chDbgCheck(c)
 Function parameters check. More...
 
#define chDbgAssert(c, r)
 Condition assertion. More...
 

Functions

void _dbg_check_disable (void)
 Guard code for chSysDisable(). More...
 
void _dbg_check_suspend (void)
 Guard code for chSysSuspend(). More...
 
void _dbg_check_enable (void)
 Guard code for chSysEnable(). More...
 
void _dbg_check_lock (void)
 Guard code for chSysLock(). More...
 
void _dbg_check_unlock (void)
 Guard code for chSysUnlock(). More...
 
void _dbg_check_lock_from_isr (void)
 Guard code for chSysLockFromIsr(). More...
 
void _dbg_check_unlock_from_isr (void)
 Guard code for chSysUnlockFromIsr(). More...
 
void _dbg_check_enter_isr (void)
 Guard code for CH_IRQ_PROLOGUE(). More...
 
void _dbg_check_leave_isr (void)
 Guard code for CH_IRQ_EPILOGUE(). More...
 
void chDbgCheckClassI (void)
 I-class functions context check. More...
 
void chDbgCheckClassS (void)
 S-class functions context check. More...
 

Macro Definition Documentation

◆ CH_DBG_STACK_FILL_VALUE

#define CH_DBG_STACK_FILL_VALUE   0x55

Fill value for thread stack area in debug mode.

Definition at line 47 of file chdebug.h.

◆ chDbgCheck

#define chDbgCheck (   c)
Value:
do { \
/*lint -save -e506 -e774 [2.1, 14.3] Can be a constant by design.*/ \
if (!(c)) { \
/*lint -restore*/ \
chSysHalt(__func__); \
} \
} \
} while (false)

Function parameters check.

If the condition check fails then the kernel panics and halts.

Note
The condition is tested only if the CH_DBG_ENABLE_CHECKS switch is specified in chconf.h else the macro does nothing.
Parameters
[in]cthe condition to be verified to be true
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 101 of file chdebug.h.

◆ chDbgAssert

#define chDbgAssert (   c,
 
)
Value:
do { \
/*lint -save -e506 -e774 [2.1, 14.3] Can be a constant by design.*/ \
if (!(c)) { \
/*lint -restore*/ \
chSysHalt(__func__); \
} \
} \
} while (false)

Condition assertion.

If the condition check fails then the kernel panics with a message and halts.

Note
The condition is tested only if the CH_DBG_ENABLE_ASSERTS switch is specified in chconf.h else the macro does nothing.
The remark string is not currently used except for putting a comment in the code about the assertion.
Parameters
[in]cthe condition to be verified to be true
[in]ra remark string
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 127 of file chdebug.h.

Function Documentation

◆ _dbg_check_disable()

void _dbg_check_disable ( void  )

Guard code for chSysDisable().

Function Class:
Not an API, this function is for internal use only.

Definition at line 112 of file chdebug.c.

References ch, chSysHalt(), ch_system::dbg, ch_system_debug::isr_cnt, and ch_system_debug::lock_cnt.

Here is the call graph for this function:

◆ _dbg_check_suspend()

void _dbg_check_suspend ( void  )

Guard code for chSysSuspend().

Function Class:
Not an API, this function is for internal use only.

Definition at line 124 of file chdebug.c.

References ch, chSysHalt(), ch_system::dbg, ch_system_debug::isr_cnt, and ch_system_debug::lock_cnt.

Here is the call graph for this function:

◆ _dbg_check_enable()

void _dbg_check_enable ( void  )

Guard code for chSysEnable().

Function Class:
Not an API, this function is for internal use only.

Definition at line 136 of file chdebug.c.

References ch, chSysHalt(), ch_system::dbg, ch_system_debug::isr_cnt, and ch_system_debug::lock_cnt.

Here is the call graph for this function:

◆ _dbg_check_lock()

void _dbg_check_lock ( void  )

Guard code for chSysLock().

Function Class:
Not an API, this function is for internal use only.

Definition at line 148 of file chdebug.c.

References ch, chSysHalt(), ch_system::dbg, ch_system_debug::isr_cnt, and ch_system_debug::lock_cnt.

Here is the call graph for this function:

◆ _dbg_check_unlock()

void _dbg_check_unlock ( void  )

Guard code for chSysUnlock().

Function Class:
Not an API, this function is for internal use only.

Definition at line 161 of file chdebug.c.

References ch, chSysHalt(), ch_system::dbg, ch_system_debug::isr_cnt, and ch_system_debug::lock_cnt.

Here is the call graph for this function:

◆ _dbg_check_lock_from_isr()

void _dbg_check_lock_from_isr ( void  )

Guard code for chSysLockFromIsr().

Function Class:
Not an API, this function is for internal use only.

Definition at line 174 of file chdebug.c.

References ch, chSysHalt(), ch_system::dbg, ch_system_debug::isr_cnt, and ch_system_debug::lock_cnt.

Here is the call graph for this function:

◆ _dbg_check_unlock_from_isr()

void _dbg_check_unlock_from_isr ( void  )

Guard code for chSysUnlockFromIsr().

Function Class:
Not an API, this function is for internal use only.

Definition at line 187 of file chdebug.c.

References ch, chSysHalt(), ch_system::dbg, ch_system_debug::isr_cnt, and ch_system_debug::lock_cnt.

Here is the call graph for this function:

◆ _dbg_check_enter_isr()

void _dbg_check_enter_isr ( void  )

Guard code for CH_IRQ_PROLOGUE().

Function Class:
Not an API, this function is for internal use only.

Definition at line 200 of file chdebug.c.

References ch, chSysHalt(), ch_system::dbg, ch_system_debug::isr_cnt, ch_system_debug::lock_cnt, port_lock_from_isr(), and port_unlock_from_isr().

Here is the call graph for this function:

◆ _dbg_check_leave_isr()

void _dbg_check_leave_isr ( void  )

Guard code for CH_IRQ_EPILOGUE().

Function Class:
Not an API, this function is for internal use only.

Definition at line 215 of file chdebug.c.

References ch, chSysHalt(), ch_system::dbg, ch_system_debug::isr_cnt, ch_system_debug::lock_cnt, port_lock_from_isr(), and port_unlock_from_isr().

Here is the call graph for this function:

◆ chDbgCheckClassI()

void chDbgCheckClassI ( void  )

I-class functions context check.

Verifies that the system is in an appropriate state for invoking an I-class API function. A panic is generated if the state is not compatible.

Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 233 of file chdebug.c.

References ch, chSysHalt(), ch_system::dbg, ch_system_debug::isr_cnt, and ch_system_debug::lock_cnt.

Here is the call graph for this function:

◆ chDbgCheckClassS()

void chDbgCheckClassS ( void  )

S-class functions context check.

Verifies that the system is in an appropriate state for invoking an S-class API function. A panic is generated if the state is not compatible.

Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 248 of file chdebug.c.

References ch, chSysHalt(), ch_system::dbg, ch_system_debug::isr_cnt, and ch_system_debug::lock_cnt.

Here is the call graph for this function:
CH_DBG_ENABLE_ASSERTS
#define CH_DBG_ENABLE_ASSERTS
Debug option, consistency checks.
Definition: rt/templates/chconf.h:559
CH_DBG_ENABLE_CHECKS
#define CH_DBG_ENABLE_CHECKS
Debug option, parameters checks.
Definition: rt/templates/chconf.h:547
FALSE
#define FALSE
Generic 'false' preprocessor boolean constant.
Definition: rt/include/ch.h:78