Sign in to follow this  
Nitage

how to get call stack information programatically?

Recommended Posts

I'm using C++ (VC7.1) and I want to be able to write the call stack to my log system when an exception gets thrown. Is there any way using VC7.1 to programatically obtain the call stack info?

Share this post


Link to post
Share on other sites
StackWalk64 is the ticket, yes. But don't get his hopes up. Writing a simple dump-stack-addresses thing is easily done, but going whole-hog and dumping function names and their local variable values is quite a bit of work.
Let's see: 2200 LOC for symbol engine, 1200 LOC for general debug code (catching exceptions, enabling debug token, etc.), 700 for pretty STL container dumps, and a further 1000 or so for misc. crap (caching of symbols, displaying the error dialog).
Now don't get me wrong, this is really great to have; it's just so much work and hard to get right, you definitely want to reuse existing code. Mine is going to be released Real Soon Now under GPL; as an alternative, John Robbins (the Bugslayer) has in the meantime written a book that includes a symbol engine, but I've not seen it myself.

BTW: putting symbol files (e.g. .PDB) in program's directory is reasonable, but not required: the absolute path to them is stored in the .EXE.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this