gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Stack trace using GCC

#52314 - Peter - Mon Aug 29, 2005 4:59 pm

Hi,

I'm looking for a method to perform a stack trace in code. I'm aware that it is possible using GDB, but that's not what I want. I would like to receive the names of the last called functions to output thethem on the screen. I actually found a lot of information about "how to use gdb" but nothing about how this could be done through code.

Any help appreciated. Thanks in advance.

PS: I'm using the latest devkitarm compiler btw.

#53024 - ribrdb2 - Mon Sep 05, 2005 3:45 pm

I experimented with this a little, but didn't get very far. (I've got gdb working in VBA again, so I'm happy)

First, you'll need to modify your link script to put the debugging information (or at the parts you want) into the rom. I just moved it into rodata, although that's going to mean you won't be able to use gdb. I'm sure there's a better way.

Next you have to read the debugging information. I modified libdwarf (from http://reality.sgi.com/davea/ ) to read the debugging info from the rom instead of using libelf.

Finally, you have to generate a stack trace using the debugging information. This is where I got stuck -- my code crashed, and without gdb I couldn't tell what was going on.