关于如何删除 Visual Studio 断点的问题

发布于 2024-08-27 04:43:39 字数 158 浏览 10 评论 0原文

假设我有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

锦上情书 2024-09-03 04:43:39

如果您在调试时更改断点的状态,并且它是多重绑定断点,则断点的状态只会暂时更改。这实际上是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.

已下线请稍等 2024-09-03 04:43:39

按 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.

十六岁半 2024-09-03 04:43:39

打开断点窗口(调试->窗口->断点),选择要删除的断点并按删除键(或单击十字图标)。

如果您使用键盘切换断点(使用我的键盘映射的 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).

走野 2024-09-03 04:43:39

如果您想使用 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.

东京女 2024-09-03 04:43:39

以下代码可用作宏来删除当前所选行上的断点。 (请注意,当断点被击中时,Visual Studio 会自动选择断点行。)

Sub RemoveBreakPoint()
    Dim debugger As EnvDTE.Debugger = DTE.Debugger
    Dim children As EnvDTE.Breakpoints
    Dim sel As Integer = DTE.ActiveDocument.Selection.ActivePoint.Line
    For Each bp As EnvDTE.Breakpoint In debugger.Breakpoints
        If bp.File <> DTE.ActiveDocument.FullName Then
            Continue For
        End If
        For Each bpc As EnvDTE.Breakpoint In bp.Children
            If bpc.FileLine = sel Then
                bp.Delete()
                Exit For
            End If
        Next
    Next
End Sub

您可以为其分配键盘快捷键以方便访问。 (工具 > 选项 > 环境 > 键盘。)

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.)

Sub RemoveBreakPoint()
    Dim debugger As EnvDTE.Debugger = DTE.Debugger
    Dim children As EnvDTE.Breakpoints
    Dim sel As Integer = DTE.ActiveDocument.Selection.ActivePoint.Line
    For Each bp As EnvDTE.Breakpoint In debugger.Breakpoints
        If bp.File <> DTE.ActiveDocument.FullName Then
            Continue For
        End If
        For Each bpc As EnvDTE.Breakpoint In bp.Children
            If bpc.FileLine = sel Then
                bp.Delete()
                Exit For
            End If
        Next
    Next
End Sub

You can assign a keyboard shortcut to it for easy access. (Tools > Options > Environment > Keyboard.)

风蛊 2024-09-03 04:43:39

来自 https://stackoverflow.com/a/35935390/257470 的交叉帖子,但它更相关这里。

这里有一些答案,但在我看来,在调试期间使用建议的操作会分散注意力(我不想失去焦点)。

在断点期间使用粘性断点的流程如下:

在调试期间,禁用断点而不是删除它。

禁用断点的可能方法:

  • 将光标悬停并单击两个循环图标;
  • 或使用上下文菜单;
  • 或键盘快捷键 CTRL+F9。

后来,在开发过程中,当我看到一个禁用的断点时,我会删除它。

附言。偶尔删除所有断点也是一个好习惯。

Cross-post from https://stackoverflow.com/a/35935390/257470 , but it's even more relevant here.

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:

  • hover with cursor and click the two cycle icon;
  • or use context menu on it;
  • or keyboard short-cut CTRL+F9.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文