Possible to Grab the Call Stack?
BlitzMax Forums/BlitzMax Programming/Possible to Grab the Call Stack?
| ||
Is it possible to grab the call stack as an object in BlitzMax? I was thinking that info would be really helpful to attach to events in my event system. Thanks. |
| ||
I guess you could do this in debug mode (seeing as the debugger can). Release mode is a different story. Its possible, but would require some black magic ;) |
| ||
If anyone wonders, To make a call-chain, one has to trace through the call-frames on the stack, then decode the address from the call instruction before the return ip. Heres an example for x86 and win32 (mac & linux should work too, but not tested) note that it will crash for functions without a call-frame UPDATE: added decoding of more call instructions, allowing to trace methods as well. |
| ||
Thanks, Grable. I figured odds were low that it would just mean including a pointer to an object... I'll have to hold off until after we get our IGF entry in. Appreciate it! Scott |