2024-01-22 11:51 PM
Hi Helpdesk,
I am currently facing an ASSERT issue on my custom board leveraging the STM32WB55 in conjunction with FreeRTOS. After some time scrawling the web, I have found the stack unwind functionality from `libunwind` available via the `unwind.h` file from the compiler. This would be a perfect fit for me, because it would allow to unwind the stack and provide vital information to trace the root cause.
Unfortunately, the function never calls the trace function, even though it compiles and "runs" successfully.
Here is my code:
#include "unwind.h"
_Unwind_Reason_Code trace_func(struct _Unwind_Context *context, void *arg)
{
void *ip = (void *)_Unwind_GetIP(context);
debug("Current ip: %p", ip);
return _URC_NO_REASON;
}
... some function
{
_Unwind_Reason_Code ret = _Unwind_Backtrace((_Unwind_Trace_Fn)&trace_func, NULL);
debug("_Unwind_Reason_Code: %d", ret); // always returns 9 = _URC_FAILURE
}
If I step through the program via a STMLink, I can see that the code jumps into the libunwind library, which puzzels my a bit.
I am using the following compiler version:
arm-none-eabi-gcc.exe (Arm GNU Toolchain 11.3.Rel1) 11.3.1 20220712
Do I need to enable some specific CMake flags?
Or does somebody know how to fix it?
Thank you very much for your feedback,
Andi
Solved! Go to Solution.
2024-01-23 12:44 AM
Hi All,
please apologize the question, but I have already found solution.
To leverage the `_Unwind_Backtrace` function, the compile flag `-funwind-tables` must be enabled, otherwise the function returns without calling the trace function.
In addition, I had to implement/moke the `_getpid_r` and `_kill_r` function.
2024-01-23 12:44 AM
Hi All,
please apologize the question, but I have already found solution.
To leverage the `_Unwind_Backtrace` function, the compile flag `-funwind-tables` must be enabled, otherwise the function returns without calling the trace function.
In addition, I had to implement/moke the `_getpid_r` and `_kill_r` function.