1 Reply Latest reply on Mar 12, 2020 12:41 AM by ChunleiL_51

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


      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.

        • 1. Re: Can we use backtrace() or obtain more than one level from __builtin_return_address()



          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.