27

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?

Chad
  • 23,658
  • 51
  • 191
  • 321

6 Answers6

19

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.

jpaugh
  • 6,634
  • 4
  • 38
  • 90
womp
  • 115,835
  • 26
  • 236
  • 269
  • 1
    I've always been able to remove breakpoints while debugging. The times it doesn't get removed (ie. its state is temporarily altered) is when the breakpoint has child breakpoints (ie. you've set a breakpoint on an overloaded function). See http://msdn.microsoft.com/en-us/library/02ckd1z7(VS.71).aspx#vctskbreakpointswindowchildbreakpoints – adrianbanks Apr 02 '10 at 23:18
  • 2
    *"The breakpoint's state is only temporarily altered if you change it while you're debugging. This is actually a feature of Visual Studio."* Can you substantiate this? This is not something i have ever noticed in all my years of using VS. I find that when VS refuses to delete my breakpoints it is because of a corrupted .user file. – slugster Apr 02 '10 at 23:27
  • http://connect.microsoft.com/VisualStudio/feedback/details/391642/permanently-remove-a-breakpoint-in-visual-studio-during-debugging - adrian is right though, it's only for multi-bound breakpoints. – womp Apr 02 '10 at 23:39
  • 3
    'bound in multiple locations' - what on earth does that mean??? two different projects calling a library class or something like that? – Simon_Weaver Sep 29 '10 at 03:48
11

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.

Dan Story
  • 9,985
  • 1
  • 23
  • 27
4

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

adrianbanks
  • 81,306
  • 22
  • 176
  • 206
1

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.

Community
  • 1
  • 1
Protector one
  • 6,926
  • 5
  • 62
  • 86
0

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

Protector one
  • 6,926
  • 5
  • 62
  • 86
0

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.

Community
  • 1
  • 1
andrew.fox
  • 7,435
  • 5
  • 52
  • 75