Contiki-NG
Files | Functions
Stack checker library

Basic support for stack guards and stack overflow detection. More...

Files

file  stack-check.c
 
Implementation of the stack checker library.

 

Functions

void stack_check_init (void)
 Initialize the stack area with a known pattern. More...
 
int32_t stack_check_get_usage (void)
 Calculate the maximal stack usage so far. More...
 
int32_t stack_check_get_reserved_size (void)
 Calculate the maximal permitted stack usage. More...
 

Detailed Description

Basic support for stack guards and stack overflow detection.

On startup, fills the area between the stack and the heap with a known pattern. During execution, the fill can be checked in order to find out the extent to which the stack has been used.

Function Documentation

◆ stack_check_get_reserved_size()

int32_t stack_check_get_reserved_size ( void  )

Calculate the maximal permitted stack usage.

This function returns the number of bytes between the origin of the stack and the end of heap.

Definition at line 127 of file stack-check.c.

◆ stack_check_get_usage()

int32_t stack_check_get_usage ( void  )

Calculate the maximal stack usage so far.

This function relies on the assumption that the stack memory that has been reserved by functions and local variables is actually overwritten with new contents. If the stack is just reserved, but not used, the function will fail to detect that usage. In addition, this function can warn if the stack memory range has been completely used, but it cannot detect and warn if stack overflow has already taken place.

Definition at line 96 of file stack-check.c.

◆ stack_check_init()

void stack_check_init ( void  )

Initialize the stack area with a known pattern.

This function initializes the memory between the stack and heap areas. The function should be called by the system during boot-up.

Definition at line 74 of file stack-check.c.