Breakpoint Groups


I’ve seen this feature requested often.  Here’s a couple of macros that take some of the hassle out of managing your breakpoints.  If you don’t know much about creating or using macros in VS, take just a couple minutes to read through my Idiot’s Guide to Creating and Using VS Macros.


Usage:



  • Set a bunch of breakpoints.
  • Disable some subset of them.  Leave enabled those breakpoints you’d like to treat as a group.
  • Run the following command in the command window or find-combobox.


>tagbps MyNamedGroup1 



  • Now enable a different set of bps in the breakpoint window and run the following command:


>tagbps MyNamedGroup2



  • To enable each breakpoint group, you can just enter one of the following commands whenever you please:


>enablebps MyNamedGroup1


>enablebps MyNamedGroup2


Setup:



  • Create the following macros:


Sub TagEnabledBreakpoints(Optional ByRef strTag As String = “Tag1”)


 

     Dim bps As EnvDTE.Breakpoints

     bps = DTE.Debugger.Breakpoints


If (bps.Count > 0) Then

    Dim bp As EnvDTE.Breakpoint

    For Each bp In bps

        If (bp.Enabled = True) Then

            bp.Tag = strTag

        End If

    Next

Else

    System.Windows.Forms.MessageBox.Show(“Can’t find any breakpoints to tag”)

End If

End Sub

 

 

Sub EnableTaggedBreakpoints(Optional ByRef strTag As String = “Tag1”)

    Dim bps As EnvDTE.Breakpoints

    bps = DTE.Debugger.Breakpoints

    If (bps.Count > 0) Then

        Dim bp As EnvDTE.Breakpoint

        For Each bp In bps

            If (bp.Tag = strTag) Then

                bp.Enabled = True

            Else

                bp.Enabled = False

            End If

        Next

    Else

        System.Windows.Forms.MessageBox.Show(“Can’t find any breakpoints to enable”)

    End If

End Sub



  • Add the following aliases:


>alias tagbps Macros.MyMacros.Module1.TagEnabledBreakpoints


>alias enablebps Macros.MyMacros.Module1.EnableTaggedBreakpoints




  • See the Usage section above.