FreeRTOS 应用程序的长 gdb 回溯是堆栈溢出的标志吗?

Is the long gdb backtrace of FreeRTOS application a sign of stack overflow?

我正在为一个项目使用 FreeRTOS,我正在尝试使用 gdb 和 JLinkGDBServer 对其进行调试。 我的问题是,当我停止执行并进行回溯时,我只是一行接一行地得到:

#192 0x08005a88 in pxPortInitialiseStack (pxTopOfStack=0xa5a5a5a5, pxCode=0xa5a5a5a5, 
    pvParameters=0xa5a5a5a5)
    at /home/username/storage/repos/project/third_party/freertos/portable/GCC/ARM_CM3/port.c:231
#193 0x08005a88 in pxPortInitialiseStack (pxTopOfStack=0xa5a5a5a5, pxCode=0xa5a5a5a5, 
    pvParameters=0xa5a5a5a5)
    at /home/username/storage/repos/project/third_party/freertos/portable/GCC/ARM_CM3/port.c:231
#194 0x08005a88 in pxPortInitialiseStack (pxTopOfStack=0xa5a5a5a5, pxCode=0xa5a5a5a5, 
    pvParameters=0xa5a5a5a5)
    at /home/username/storage/repos/project/third_party/freertos/portable/GCC/ARM_CM3/port.c:231
#195 0x08005a88 in pxPortInitialiseStack (pxTopOfStack=0xa5a5a5a5, pxCode=0xa5a5a5a5, 
    pvParameters=0xa5a5a5a5)
    at /home/username/storage/repos/project/third_party/freertos/portable/GCC/ARM_CM3/port.c:231
#196 0x08005a88 in pxPortInitialiseStack (pxTopOfStack=0xa5a5a5a5, pxCode=0xa5a5a5a5, 
    pvParameters=0xa5a5a5a5)
    at /home/username/storage/repos/project/third_party/freertos/portable/GCC/ARM_CM3/port.c:231
#197 0x08005a88 in pxPortInitialiseStack (pxTopOfStack=0xa5a5a5a5, pxCode=0xa5a5a5a5, 
    pvParameters=0xa5a5a5a5)
    at /home/username/storage/repos/project/third_party/freertos/portable/GCC/ARM_CM3/port.c:231

这是堆栈溢出的迹象还是什么? 我正在 FreeRTOSConfig.h

中使用 configCHECK_FOR_STACK_OVERFLOW 2 检查堆栈溢出

原来在FreeRTOSConfig.h上加上#define configTASK_RETURN_ADDRESS 0就解决了问题

是 - 这是因为 GDB 不知道何时停止展开状态。或者换句话说,它不知道什么时候到达任务堆栈帧的末尾。

默认情况下,堆栈帧的末尾会将任务留在错误函数中,因为您不应该 return 从任务中删除它,但错误函数本身不会 return 任何地方。在大多数情况下,对于大多数调试器来说,这很好,但有时 GDB 可能会有点热情,并且提供了 configTASK_RETURN_ADDRESS 常量以允许您用简单的 NULL 替换错误函数的地址 - GDB 不会这样做尝试进一步放松。

为了将来参考,如果您想了解堆栈溢出,请阅读 FreeRTOS.org 网站上的堆栈溢出检测页面:http://www.freertos.org/Stacks-and-stack-overflow-checking.html