From 2aed5c5ba31859cd95c5b2ec1f877d571fefa0b2 Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Fri, 20 Jan 2023 03:28:48 +0100 Subject: [PATCH] Add stack overflow detection helper --- src/debug/stack_overflow.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/debug/stack_overflow.cpp diff --git a/src/debug/stack_overflow.cpp b/src/debug/stack_overflow.cpp new file mode 100644 index 0000000..06cf2a7 --- /dev/null +++ b/src/debug/stack_overflow.cpp @@ -0,0 +1,24 @@ +#include +#ifdef STA_RTOS_STACK_OVERFLOW_HOOK + +#include +#include + +#include +#include + + +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