Question

If I set a breakpoint on a method, how can I see what called the method, when the breakpoint is hit in Visual Studio 2008?

Was it helpful?

Solution

Check the Call Stack window (Debug, Windows, Call Stack). Double clicking each entry there will take you to the calling statement. You can also right click on it to enable/disable showing external code items and calls from other threads.

OTHER TIPS

If you can't see anything in the call stack at a user-set breakpoint, it generally means it was called from native code.

Another case where it can't get a stack: You hit Debug>Break All and the main thread is in a wait/sleep state, the debugger can have problems building the call stack. I believe the debugger uses the main thread for its implicit function evaluation.

Try attaching (or launching) the mixed-mode (native & managed) code debugger and see if that straightens it out.

When the breakpoint is hit, you can view the entire call stack. You can bring that window up by going through the Debug menu->Windows->Call Stack.

You can also bring it up by the shortcut Alt+Ctrl+C

EDIT: You can also right-click on a function name, and view the "Callers Graph", which will show you all the callers for your method. Alternatively, you can bring the Call Browser (by going to View->Other windows->Call Browser ) and search for your method's name.

If you can't see anything in the Call Stack window, then there's definitely something wrong. I would suggest the famous sequence of R-actions:

  • Retry
  • Recompile
  • Restart
  • Reinstall :)

If the break point is in a function that is raised by an event, you might not have a direct call stack back to the caller, and will need to enable viewing all code, and not just "just my code".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top