禁用/删除子断点?

发布于 2024-12-13 11:10:23 字数 624 浏览 1 评论 0原文

我正在 Visual Studio 中使用 C# 调试 ASP.NET 网站。当我设置断点(在调试期间)时,随着时间的推移,创建的断点将积累许多子断点。 (请参阅此处。)< br> 现在,有时当我通过单击红色字形删除断点时,下次执行该行时仍会命中该断点,因为子断点仍然存在。

删除断点窗口中的断点可以解决问题,但是当你设置了很多断点时,找到正确的断点很烦人。此外,删除具有许多子项的断点是一个相当慢的操作。

因此,要解决这个问题,我可以禁用子断点的创建,还是有办法快速删除所有子断点?
替代解决方案表示赞赏!


请注意,这不是此内容的重复:问题如何删除 Visual Studio 断点,因为我问如何处理子断点。 (尽管我们的预期目标是相同的。)

I'm debugging an ASP.NET Website with C# in Visual Studio. When I set a breakpoint (during debug), over time, the created breakpoint will accumulate many child breakpoints. (See here.)
Now, sometimes when I remove a breakpoint by clicking the red glyph, the breakpoint will still be hit the next time the line is executed, because the child breakpoints persisted.

Removing the breakpoint in the breakpoint window will resolve the problem, but it's annoying to find the correct breakpoint(s) when you have many set. Also, the removal of a breakpoint with many children is quite a slow operation.

So to get to the question, can I disable this creation of child breakpoints, or is there a way to quickly remove all children?
Alternative solutions are appreciated!

Please note that this isn't a duplicate of this: Question on how to remove a Visual Studio Breakpoint, because I'm asking how to deal with the child breakpoints. (Although our intended goal is the same.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

山田美奈子 2024-12-20 11:10:23

以下代码可以用作宏来删除所有子断点。

Sub RemoveChildBreakpoints()
    Dim i As Integer
    Dim len As Integer
    Dim debugger As EnvDTE.Debugger = DTE.Debugger
    Dim children As EnvDTE.Breakpoints
    For Each bp As EnvDTE.Breakpoint In debugger.Breakpoints
        children = bp.Children
        len = children.Count
        For i = len To 1 Step -1
            children.Item(i).Delete()
        Next
    Next
End Sub

如果您有很多断点,它仍然非常慢,因此如果您遇到子断点问题,最好定期运行它。

The following code can be used as a macro to remove all the child breakpoints.

Sub RemoveChildBreakpoints()
    Dim i As Integer
    Dim len As Integer
    Dim debugger As EnvDTE.Debugger = DTE.Debugger
    Dim children As EnvDTE.Breakpoints
    For Each bp As EnvDTE.Breakpoint In debugger.Breakpoints
        children = bp.Children
        len = children.Count
        For i = len To 1 Step -1
            children.Item(i).Delete()
        Next
    Next
End Sub

It's still insanely slow if you have many breakpoints, so it's best to do run it on a regular basis if you're having a problem with child breakpoints.

情归归情 2024-12-20 11:10:23

以下代码可用作宏来删除当前所选行上的断点。 (请注意,当断点被击中时,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-12-20 11:10:23

以下是基于 javascript 的新宏加载项的更新宏 (https://marketplace。 Visualstudio.com/items?itemName=VisualStudioPlatformTeam.MacrosforVisualStudio) 删除所有子断点:

/// <reference path="C:\Users\ERobishaw\AppData\Local\Microsoft\VisualStudio\14.0\Macros\dte.js" />
try {

    var outputWindowPane = dte.Windows.Item("{34E76E81-EE4A-11D0-AE2E-00A0C90FFFC3}").Object.ActivePane;
    outputWindowPane.Activate();
    outputWindowPane.OutputString("display this text in the output window panel\n");

    var i;
    var len;
    var dbgr = dte.Debugger;
    var brk = dbgr.Breakpoints;
    outputWindowPane.OutputString("There are " + brk.Count + " Total\n");
    //Macro.InsertText("There are " + brk.Count + " Total");
    for (var bpi = 1; bpi <= brk.Count; bpi++) {
        outputWindowPane.OutputString("On " + bpi + " of " + brk.Count + "\n");
        var bp = brk.Item(bpi);
        var children = bp.Children;
        var len = children.Count;
        
        for (var chi = len; chi > 0; chi--) {
            outputWindowPane.OutputString(" Children Count = " + children.Count + "\n");
            children.Item(chi).Delete();
        }
    }
}
catch (e) {
    outputWindowPane.OutputString("Error\n");
    outputWindowPane.OutputString(e + "\n");
}

Here's an updated macro for the new javascript based macro add-in (https://marketplace.visualstudio.com/items?itemName=VisualStudioPlatformTeam.MacrosforVisualStudio) to remove all children breakpoints:

/// <reference path="C:\Users\ERobishaw\AppData\Local\Microsoft\VisualStudio\14.0\Macros\dte.js" />
try {

    var outputWindowPane = dte.Windows.Item("{34E76E81-EE4A-11D0-AE2E-00A0C90FFFC3}").Object.ActivePane;
    outputWindowPane.Activate();
    outputWindowPane.OutputString("display this text in the output window panel\n");

    var i;
    var len;
    var dbgr = dte.Debugger;
    var brk = dbgr.Breakpoints;
    outputWindowPane.OutputString("There are " + brk.Count + " Total\n");
    //Macro.InsertText("There are " + brk.Count + " Total");
    for (var bpi = 1; bpi <= brk.Count; bpi++) {
        outputWindowPane.OutputString("On " + bpi + " of " + brk.Count + "\n");
        var bp = brk.Item(bpi);
        var children = bp.Children;
        var len = children.Count;
        
        for (var chi = len; chi > 0; chi--) {
            outputWindowPane.OutputString(" Children Count = " + children.Count + "\n");
            children.Item(chi).Delete();
        }
    }
}
catch (e) {
    outputWindowPane.OutputString("Error\n");
    outputWindowPane.OutputString(e + "\n");
}

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