45#include "dev/watchdog.h"
50#define LOG_MODULE "Stack"
51#define LOG_LEVEL LOG_LEVEL_MAIN
57#if STACK_CHECK_PERIODIC_CHECKS
58PROCESS(stack_check_process,
"Stack check");
62#define STACK_FILL 0xcd
66#define GET_STACK_ORIGIN() STACK_ORIGIN
69extern int _stack_origin;
70#define GET_STACK_ORIGIN() (&_stack_origin)
80 static void *stack_top;
81#if defined __GNUC__ && __GNUC__ >= 13
82#pragma GCC diagnostic push
83#pragma GCC diagnostic ignored "-Wdangling-pointer"
87#if defined __GNUC__ && __GNUC__ >= 13
88#pragma GCC diagnostic pop
93 while(p < (uint8_t *)stack_top) {
97#if STACK_CHECK_PERIODIC_CHECKS
106 uint8_t *p = &_stack;
114 while(*p != STACK_FILL && p < (uint8_t *)GET_STACK_ORIGIN()) {
119 while(*p == STACK_FILL && p < (uint8_t *)GET_STACK_ORIGIN()) {
126 if(p >= (uint8_t*)GET_STACK_ORIGIN()) {
131 return (uint8_t *)GET_STACK_ORIGIN() - p;
137 return (uint8_t *)GET_STACK_ORIGIN() - &_stack;
140#if STACK_CHECK_PERIODIC_CHECKS
155 if(actual > allowed) {
156 LOG_ERR(
"Check failed: %u vs. %u\n", (
unsigned)actual,
159 LOG_DBG(
"Check ok: %u vs. %u\n", (
unsigned)actual, (
unsigned)allowed);
void watchdog_periodic(void)
Writes the WDT clear sequence.
void etimer_reset(struct etimer *et)
Reset an event timer with the same interval as was previously set.
static bool etimer_expired(struct etimer *et)
Check if an event timer has expired.
void etimer_set(struct etimer *et, clock_time_t interval)
Set an event timer.
#define PROCESS(name, strname)
Declare a process.
#define PROCESS_BEGIN()
Define the beginning of a process.
#define PROCESS_WAIT_EVENT_UNTIL(c)
Wait for an event to be posted to the process, with an extra condition.
#define PROCESS_END()
Define the end of a process.
void process_start(struct process *p, process_data_t data)
Start a process.
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
size_t stack_check_get_usage(void)
Calculate the maximal stack usage so far.
size_t stack_check_get_reserved_size(void)
Calculate the maximal permitted stack usage.
void stack_check_init(void)
Initialize the stack area with a known pattern.
Header file for the logging system.
Stack checker library header file.