Add stack overflow detection helper

This commit is contained in:
Henrik Stickann 2023-01-20 03:28:48 +01:00
parent 5cf9b25491
commit 2aed5c5ba3

View File

@ -0,0 +1,24 @@
#include <sta/config.hpp>
#ifdef STA_RTOS_STACK_OVERFLOW_HOOK
#include <sta/assert.hpp>
#include <sta/debug_serial.hpp>
#include <FreeRTOS.h>
#include <task.h>
extern "C" void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName)
{
// TODO Handle corrupted parameters
// * check pcTaskName is cstring (look for \0 within ? bytes)
STA_DEBUG_PRINT("Stack overflow detected in task ");
if (pcTaskName)
{
STA_DEBUG_PRINTLN(pcTaskName);
}
STA_HALT();
}
#endif // STA_RTOS_STACK_OVERFLOW_HOOK