Finding a call stack programmatically (unwind?).

I am attempting to write a routine that monitors the heap in order to track down a memory leak.  I've seen similar tools on other platforms and found them quite helpful.  To make this even more effective, I want to record the caller to malloc() that made the request. To do this, the routine would need to read the call stack (sometimes called unwind).  I've been googling and found clues for the GNU compiler, and other platforms but nothing that seems pertinent to my platform: nRF52840/ARM/IAR/FreeRTOS.

I realize this is extremely unportable, but this is only needed for debugging on occasion.

Anyone have any suggestions?  I've seen references to unwind.h, but they appear to only be for GNU.

Parents Reply
  • To reiterate: I am not interested in the malloc itself, I am just referencing that for context.  What I am interested in is how to access the caller stack.  This involves getting access to the sp and/or lr registers and walking through the stack.  Is the stack defined by IAR or ARM or Nordic.  Call stack unwinding is a critical piece of debugging, either live through a IDE or in postmortem as in this case.

    I am in touch with IAR, and their as confused by this as you folks.

    Thanks.

Children
Related