开发者

How can I tell the Visual Studio debugger to never step into a specific file?

I have a couple ANTLR-generated code files, and I'm currently happy with how they are working. I'd like to configure my project in Visual Studio (2008)开发者_如何学Python so the debugger skips over methods defined in those files. How can I do this?


You can attach the DebuggerStepThrough attribute to properties to make it skip them. You can still set breakpoints in the methods.

[DebuggerStepThrough()]
private void DontDebugMe(string message) {}
     ....

or 
[DebuggerStepThrough()]
public class BuhBye { .. }

I should add that you can also use the DebuggerNonUserCode attribute and DebuggerHidden to prevent VS from stepping in at all, or even respecting breakpoints in the code. Doubt you want that, though.

  • DebuggerNonUserCode also prevents the property/etc from displaying in the debugger window.

I use the StepThrough one all over the place though, since we compile in 3rd party code's and I don't want to step into their methods when debugging, or go into the container's name resolution/object creation code. Very handy for that.


Andy Pennell has posted the following article on his blog that you may find helpful:
How to Not Step Into Functions using the Visual C++ Debugger

But do note that this is officially undocumented and may not be supported in future versions of VS. It also doesn't work when you attach the debugger to an already running process.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜