关于如何删除 Visual Studio 断点的问题
假设我有 10 个断点,我想清除其中一个,但不想清除另外 9 个断点。
如果我在要删除的断点上切换断点,则下次重新启动应用程序时,它会复活。我知道永久摆脱它的唯一方法是清除所有断点,我宁愿不这样做,因为我必须重置其他 9 个断点。
在任何 VS 版本中是否有更好的方法?
Let's say I have 10 breakpoints and I want to clear one but not the other 9.
If I toggle the breakpoint on the one that I want to remove, it is resurrected the next time I restart the app. The only way that I know to permanently get rid of it is to clear ALL the breakpoints, which I would rather not do since I would have to reset the other 9.
Is there a better way in ANY VS version?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
如果您在调试时更改断点的状态,并且它是多重绑定断点,则断点的状态只会暂时更改。这实际上是Visual Studio的一个功能。请参阅这里是最后一篇文章。
如果您不进行调试,并且将其删除,那么它就不会回来。或者,正如其他人所建议的,您可以使用断点管理窗口永久删除它。
The breakpoint's state is only temporarily altered if you change it while you're debugging and it's a multi-bound breakpoint. This is actually a feature of Visual Studio. See the last post here.
If you're not debugging, and you remove it, then it won't come back. Alternately, as others have suggested, you can remove it permanently using the breakpoint management window.
按 Ctrl+Alt+B 将显示解决方案中所有断点的列表,您可以通过右键单击手动切换或删除它们。
Hitting Ctrl+Alt+B will bring up a list of all breakpoints in your solution, from which you can manually toggle or delete them with a right-click.
打开断点窗口(调试->窗口->断点),选择要删除的断点并按删除键(或单击十字图标)。
如果您使用键盘切换断点(使用我的键盘映射的 F9),有时无法正确删除它。再次按 F9 将完全删除它(这是因为在多个线程上设置了断点,并且在调试时切换它只会禁用主断点,但不会禁用其他线程的断点)。
Open the breakpoints window (Debug -> Windows -> Breakpoints), select the breakpoint you want to delete and press the delete key (or click the cross icon).
If you are toggling the breakpoint using the keyboard (F9 using my keyboard mappings), it sometimes doesn't remove it properly. Pressing F9 again will remove it fully (this is due to the breakpoint being set on multiple threads and toggling it whilst debugging only disables the main breakpoint but not the ones for the other threads).
如果您想使用 F9 或单击红色标志来删除断点,则该断点必须是无子断点。否则,断点将通过其幸存的子断点持续存在。 (在调试期间设置断点时可以形成子断点。)
您可以检查这个问题“禁用/删除子断点?”,以删除宏子断点。我认为您不应该在调试会话期间调用宏,因为这可能会导致您的断点未被命中。
If you want to delete a breakpoint with F9 or by clicking the red glyph, that breakpoint needs to be childless. Otherwise, the breakpoint will persist through its surviving child breakpoints. (Child breakpoints can form when you set breakpoints during debug.)
You could check this question, " Disable/remove child Breakpoints? ", for a macro to remove child breakpoints. I think you shouldn't call the macro during a Debug session though, as this might result in your breakpoints to not be hit.
以下代码可用作宏来删除当前所选行上的断点。 (请注意,当断点被击中时,Visual Studio 会自动选择断点行。)
您可以为其分配键盘快捷键以方便访问。 (工具 > 选项 > 环境 > 键盘。)
The following code can be used as a macro to remove the breakpoint on the currently selected line. (Note that Visual Studio automatically selects the line of a breakpoint when it is hit.)
You can assign a keyboard shortcut to it for easy access. (Tools > Options > Environment > Keyboard.)
这里有一些答案,但在我看来,在调试期间使用建议的操作会分散注意力(我不想失去焦点)。
在断点期间使用粘性断点的流程如下:
在调试期间,禁用断点而不是删除它。
禁用断点的可能方法:
后来,在开发过程中,当我看到一个禁用的断点时,我会删除它。
附言。偶尔删除所有断点也是一个好习惯。
There are some answers here, but in my opinion proposed actions are distractive to use during debugging (I don't want to lose my focus).
My flow with sticky breakpoints during breakpoints is as follows:
During debug, DISABLE the breakpoint instead of removing it.
Possible ways of disabling a breakpoint:
Later on, during development, I remove a disabled breakpoint when I see one.
PS. It's also a good practice to remove all breakpoints once in a while.