简体   繁体   中英

Visual Studio 2008 Debugging - Skipping code

Is there a way to skip code without having to set a breakpoint after it? I am using the debugging to explore code with a GUI painting event that runs lots of times. I wish to see what comes after the event is done triggering without having to click next a bunch of times.

[DebuggerHidden] 

When this attribute is attached to a constructor/method/property or indexer then that code is hidden from the debugger, it will not be possible for you to step into the code, the debugger will just skip over the code. Even if you set a breakpoint inside one of the pieces of code decorated with this attribute, the debugger will ignore it.

[DebuggerStepThrough]

This attribute is the same as the DebuggerHiddenAttribute, apart from the fact that you can set a breakpoint inside the code which has been decorated with the DebuggerStepThroughAttribute, and the debugger will stop at the breakpoint.

[DebuggerNonUserCode]

This attributes marks a section of code as not being user code, you can then use this with the Tools->Options->Debugging->General->Enable Just My Code, option to tell the debugger not to step into the decorated code.

您可以指定断点条件(右键单击断点红色圆圈图标),以便断点仅在发生有趣事件时停止执行。

这是另一个方便的:如果你当前停在断点上,并且你只想运行代码中的其他一些点,你可以右键单击你想要运行的行并选择“Run to Cursor” 。

If you want to execute the code after the breakpoint, up to another line, use JMarsch's "Run to Cursor" suggestion.

If you want to SKIP the following lines, and resume execution at another point, you can use your mouse to drag the yellow arrow in the left margin of the code window - down to the line you want to execute next.

This is also useful if you want to re-execute some code that's already run - just drag the yellow arrow UP to that line. I often use this to "Step Into" code that I've already done a "Step Over" on.

"Set Next Statement" in the right-click menu has the same effect.

-Tom Bushell

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM