Can we use backtrace() or obtain more than one level from __builtin_return_address()

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
PeRa_4144941
Level 2
Level 2
First solution authored First like received First reply posted

Hello All,

We are using WICED on the 43907, and would like to be able to read the entire stack back trace from within our application (for memory debugging purposes).  In other words, every time we call, say, malloc(), we would like to know not just who called it, but who called the caller etc. etc.

backtrace() does not seem to exist in the WICED world, and __builtin_return_address( 1 ) etc. (anything other than level 0) always returns a NULL pointer.  Obviously the debugger is able to unwind the stack, but we don't want to set a breakpoint on malloc().  Does anyone have an easy way to do this?  Thanks.

0 Likes
1 Solution
Charles_Lai
Moderator
Moderator
Moderator
500 replies posted 250 solutions authored 250 sign-ins

Hi,

backtrace() should be used with GDB (GNU Debugger Bridge), and according to GDB, this function requires the host's operating system to firstly enable ptrace feature, which can often be seen in Linux upon all architectures.

Unfortunately, WICED is based on FreeRTOS and unlike Linux, it seems that FreeRTOS does not support ptrace feature by default (at least in WICED World, though it's built upon ARM like what Linux can do). So backtrace() won't be available in WICED world.

This is what I know. Please let me know if I'm wrong.

<<<<<<<<<<<<<>>>>>>>>>>>>>

Best Regards

C. L.

<<<<<<<<<<<<<>>>>>>>>>>>>>

View solution in original post

0 Likes
1 Reply
Charles_Lai
Moderator
Moderator
Moderator
500 replies posted 250 solutions authored 250 sign-ins

Hi,

backtrace() should be used with GDB (GNU Debugger Bridge), and according to GDB, this function requires the host's operating system to firstly enable ptrace feature, which can often be seen in Linux upon all architectures.

Unfortunately, WICED is based on FreeRTOS and unlike Linux, it seems that FreeRTOS does not support ptrace feature by default (at least in WICED World, though it's built upon ARM like what Linux can do). So backtrace() won't be available in WICED world.

This is what I know. Please let me know if I'm wrong.

<<<<<<<<<<<<<>>>>>>>>>>>>>

Best Regards

C. L.

<<<<<<<<<<<<<>>>>>>>>>>>>>

0 Likes