Implement robust task name printing

This commit is contained in:
Henrik Stickann 2023-01-20 14:12:40 +01:00
parent ced0bd1a2a
commit f866e27081

View File

@ -8,14 +8,25 @@
#include <task.h>
extern "C" void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName)
extern "C" void vApplicationStackOverflowHook(xTaskHandle xTask, 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);
// 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();
}