Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: C++
Expertise: Beginner
Jul 18, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Debugging in Visual C++

Is there a way to access the call stack debugging information from the code? I would like to print the call stack inside a function, each time it is called.

The stack call information isn't directly accessible. If you want to access that information, you will have to extract it from the executable file (Microsoft's format of executable files is called PE, Portable Executable. You can read about its structure on MSDN). Another option is to use assembly code to check the stack frame, the status of registers, activation records etc. A simpler solution is to use a stack object to which each function adds its name as a push() operation. The problem is that you will be able to see only your functions in the call chain, but not startup code or runtime library function calls.

DevX Pro
Thanks for your registration, follow us on our social networks to keep up-to-date