5

In C#, VS 2010, is there a keyboard shortcut to see from where did the breakpoint was hit when you debug?

For example, if I have a breakpoint in a method called myMethod(), and it was hit, how to see from what line was it called?

1
  • statically, i.e. without debugging, Resharper 6 has excellent options to show exactly where calls can originate. IIRC VS2010 should have a similar feature natively, but I can't tell right now, as I'm on VS2008 Commented Nov 7, 2011 at 11:46

6 Answers 6

10

You can look at the "Call Stack". In VS go to Debug > Windows > Call Stack. In debug mode the call stack will show which methods have been called in order to reach your break point.

Sign up to request clarification or add additional context in comments.

Comments

3

If you open up the Call Stack window you can see the chain of method calls leading to the current line.

If you've got one of the fancier versions of Visual Studio, you might also take a look at Debugger Canvas.

Comments

1

Isn't the call stack window enought ?

Comments

1

You can look at the call stack which will show you where the method call came from, it can be opened by going to the Debug => Windows menu option when your app is running or by pressing Ctrl+D,C.

Comments

1

Are you looking for the entire call stack?

In this case you may try this when your breakpoint is hit: - On the Debug menu, select Windows and then click Call Stack.

Comments

1

In simple cases the "Call stack" Window will show this.

If the compiler used tail call optimization or method inlining, it can give an unexpected result. But that shouldn't happen while debugging, because that (by default) disables those optimizations.

yield-iterators and async methods show from where they were resumed, and not where they were originally called.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.