#include #ifdef STA_RTOS_STACK_OVERFLOW_HOOK #include #include #include #include extern "C" void vApplicationStackOverflowHook(xTaskHandle xTask, char * pcTaskName) { STA_DEBUG_PRINT("Stack overflow detected in task "); if (pcTaskName) { // Manually calculate string length // Limited to configMAX_TASK_NAME_LEN to avoid reading // garbage values in case TCB has been corrupted size_t len = 0; while (len < configMAX_TASK_NAME_LEN) { if (pcTaskName[len] == '\0') { break; } ++len; } STA_DEBUG_PRINTLN(pcTaskName, len); } STA_HALT(); } #endif // STA_RTOS_STACK_OVERFLOW_HOOK