Question:
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.
Answer:
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.