Debugging in Visual C++

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.

See also  How College Students Can Shape the Future of Tech Responsibility

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist