I'd like to print a backtrace from within a demo. For example if there is an error I can call print_backtrace_symbols() and get a debugger style view of call stack with function names etc. GCC or glib comes with such functions called backtrace()/backtrace_symbols(). Also there are utils like addr2line which can translate address to source line. However I can't see anything like this for vbcc.
Did anyone here write this kind of code before?
My guess is what needs to be done is: 1) Add debug symbols 2) Parse stack matching return addresses with the debug symbol info
------- Problem 1
Currently I've enabled the -g option for vbcc to get debug symbols. I can see symbols and some argument info is present by hexdump of the object file. However I don't know what kind of format it really is and when linking I'm getting lots of errors like:
Error 21: cctab.o (.debug_info+0x2a91): Reference to undefined symbol l1519.
I've tried to disable any kind of optimization that I theorized may strip compiler generated labels such as the one above, but so far no luck..
------- Problem 2
What does the stack frame look like on amiga? Is there a standard or is it compiler dependent. I heard some rough info like d0/d1/a0/a1 should be used for the first few arguments and then the rest of the arguments will be on stack, however would be nice with a doc which describes it precisely.
I could just scan the whole stack and print whenever there is a value which matches a function address as found in the debug_symbols as a start though.
|