When you have a bug in your code, Visual Studio halts and allows you to inspect the code. The place at which Visual Studio halts won't always be the exact location of the bug, but it can be close. It will at least be at a line of code that doesn't execute properly.
In this recipe, we'll describe Call Stack, and how to trace where you think an error may come from. Try adding a bug to your code, or add a breakpoint somewhere interesting that you'd like to pause for inspection.
Run the code to a point where a bug occurs by pressing F5, or selecting the Debug | Start Debugging menu option. For example, add these lines of code:
UObject *o = 0; // Initialize to an illegal null pointer o->GetName(); // Try and get the name of the object (has bug)
The code will pause at the second line (
o->GetName()
).When the code pauses, navigate to the Call Stack window (Debug | Windows | Call Stack).