简体   繁体   English

Visual Studio 2008调试 - 跳过代码

[英]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. 我正在使用调试来探索运行很多次的GUI绘图事件的代码。 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. 此属性与DebuggerHiddenAttribute相同,除了您可以在使用DebuggerStepThroughAttribute修饰的代码中设置断点,并且调试器将在断点处停止。

[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. 此属性将一段代码标记为不是用户代码,然后可以使用Tools-> Options-> Debugging-> General-> Enable Just My 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. 如果要在断点之后执行代码,直到另一行,请使用JMarsch的“Run to Cursor”建议。

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. 我经常使用这个“Step Into”代码,我已经完成了“Step Over”。

"Set Next Statement" in the right-click menu has the same effect. 右键单击菜单中的“设置下一个语句”具有相同的效果。

-Tom Bushell -Tom Bushell

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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