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?
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.
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.
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).
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.
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.)
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.
Related
I often find myself in a situation where I wish to break on several breakpoints in a run, but only for a while until I have seen enough on on those breakpoints and would like the Visual Studio to stop breaking on the breakpoints for the remainder of the current debug session.
I certainly do not want to delete all breakpoints because later I may change something in database or the code, and would like to perform a new, similar run to the one described above again.
I do not want to disable all breakpoints, since I want them to be activated again at the next debug run. At the same time I already have breakpoints, both active and disabled, in other parts of the code (which I am not currently interested in for instance) but I do not want to disable them and then try to remember later which I need for debugging a specific area/functionality of the code.
What I want is simply to be able to tell Visual Studio that "from now on as I resume execution, please ignore all breakpoints for the remainder of this debugging session. Thank you very much!"
So for the next debug run, all breakpoints should be hit again as they already were configured before as usual, but I mean at some point when I have seen enough I just want to continue execution without breaking. and without changing the status to "disabled" for all breakpoints - because doing so will make them stay disabled even at the next run, and I do not want to "Enable all" because I already had some breakpoints on my list which were disabled. And I certainly do not want to manually select/deselect breakpoints before every run just because I chose "Disable all" during a run.
Is this possible to and, in that case, how to do it?
Thanks!
I'm using VS2017 but hopefully the options are similar in VS2013:
Go to the Debug menu, then Windows > Breakpoints to open the Breakpoints window.
From here, the blue curvy arrows in the toolbar allow you to Export and Import breakpoints into an XML file.
So you could export all of your breakpoints, then delete them all. Later you can re-import them instead of having to set them all up again manually.
I want to remove several breakpoints along my program execution path. XCode stops at each breakpoint and I want to clear it immediately. In contrast to all other tools that I used to, Xcode does not put cursor on the line it stopped. Therefore, "toggle breakpoint" shortcut instead of clearing current breakpoint, puts breakpoint somewhere out of sight.
To clear current breakpoint I need to grab mouse or press extra shortcut before actually clearing breakpoint. It gets very annoying for several breakpoints in row.
Maybe there's workaround?
You can click inside the topmost thread in the Debug Navigator ⌘+6 to see where you stopped.
If you want to automatically skip a breakpoint or perform other actions when it's triggered you can Right-Click or Control+Click the breakpoint, choose Edit Breakpoint... then check Automatically continue after evaluating actions.
As title, How to force visual studio to ignore all other breakpoints except one
Under the Debug Menu click Disable All Breakpoints, then right click the Break Point in question and click Enable Break Point.
With breakpoints window (Debug | Windows | Breakpoints) having focus select all (control-a), control-click the break point you want to keep (to unselect) and untick one of the selected breakpoints. All the selected breakpoints will be disabled.
Try exporting all your breakpoints then choose Delete All Breakpoints from the Debug menu.
you can then re-add your breakpoint and import your old ones when you're ready.
In addition to Astander's answer, you can bring up the debug window (Ctrl D+B), and it has an option there to Enable or disable all breakpoints matching the current Search, with the Search box just along from it. Very nifty.
Is there a shortcut to cycle through my breakpoints? I often lose track of the breakpoints when debugging a project. When I finish working with one bug, I have to reset my breakpoints for a new bug that I am about to solve. It would be handy to have a keystroke that would allow me to cycle through the breakpoints and disable ones I don't need and keep the ones I need.
You can always open the breakpoints window (Ctrl + Alt + B) to cycle through them.
I don't believe you can.
You can display a list of all breakpoints and jump to them using the breakpoint view (Debug / Windows / Breakpoints).
You may also be able to write a macro to do it if you want.
I don't think there is a built in way of doing this. However you might want to take a look at this question. You can probably save the breakpoints for one bug and load it whenever you want it.
Often, when I have a breakpoint on some line in Visual Studio, The program will run and stop there. great. I will then click the red circle (or press F9) to remove it. Obviously I don't want my program to keep stopping there. The problem is that the next time I refresh the page the breakpoint is back! The only way to permanently remove it is to open the breakpoints window and remove it there. Why does this happen and how can I change this behavior?
I have noticed that these breakpoints which keep coming back have a little plus next to them in the breakpoints window which when you click on - open up many sub lines of breakpoints. What is the deal with that?
Thanks,
Adin
Helpful Key combo: to permanently delete all breakpoints, press CTRL + SHIFT + F9.
Just clear the breakpoint while the debugger is off. When you clear or add a breakpoint while debugging, the action only lasts for that debugging session.
The plus in the breakpoints window is there when one user-supplied breakpoint binds in multiple places. This can happen when a single file is loaded multiple times in the same debugging session, for example. The + lets you look at each of the places it bound.
#Joel: modifying breakpoints during a debugging session does not make your change temporary, although there are circumstances (like the original question), where the actual behavior can be non-obvious.
I've post suggestion to MS to fix it:
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=391642
It appears since Visual Studio allows multiple breakpoints on a single line, i.e. in separate sub-clauses, architecturally it allows multiple identical breakpoints. The interface does not necessarily reflect this and you will see the removal of a breakpoint as graphically removing it, but not programmatically removing all instances of it.
Looking at the Debug > Windows > Breakpoints window shows for a given set of breakpoints on a line, they are stored in a sub-tree under that line item. Removing a breakpoint while watching this list will reveal the behaviour, that only one of a series of identical breakpoints is removed from the list associated with that line. By removing the breakpoint line item and with it all sub items it will completely remove all instances of the breakpoint.
Wipe the breakpoint out using the Breakpoints Window (Ctrl + Alt + B).
While debugging, when you hit the breakpoint, look at the BreakPoint window for the one that is bold.
Then, right-click it and choose Delete.