I've been looking over the internet to find out how to change the location of a breakpoint in Visual Studio 2017 and cannot find any answers. The only answer that comes close is from 2009 and is no longer an option in VS2017.
Most attempts to answer the question involve deleting and recreating the breakpoint. Most of the time that is fine, however if you're dealing with tracepoints or conditional breakpoints which have several options applied to the "breakpoint" you don't really want to delete and recreate it.
I've even seen requests on UserVoice to drag-n-drop the breakpoint to a different line, but nothing that tells me how to do it even without drag-n-drop.
Yes, I know a lot of people say why do you even want to move it? Well sometimes VS2017 just doesn't get that after doing a Get Latest
from TFVC, the code has moved but the breakpoint hasn't moved with the code, and I really don't want to recreate the conditional tracepoints. Or maybe I just want to move it for general testing and debugging and focus on a differnt bit of code. Either way, it doesn't really matter why - the question is how.
So how do I change the location of a breakpoint without having to delete and recreate all the options?
To set a breakpoint in source code: Click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint. The breakpoint appears as a red dot in the left margin.
Visual Studio saves breakpoints in a XML file. To save the breakpoints, you just need to click on the “Export” button in breakpoint window as shown in the following figure. You can use the saved XML file for the future and you can pass the same to other developers.
Visual Studio's/Atmel Studio's Breakpoint Window gives you an overview of all breakpoints you have set in your project. You open the Breakpoint Window with the menu item Debug > Windows > Breakpoints or by pressing [Alt+F9].
To set a data breakpoint: In a C++ project, start debugging, and wait until a breakpoint is reached. On the Debug menu, choose New Breakpoint > Data Breakpoint.
Okay, so maybe I'm just blind, but it was not at all obvious to me.
You see the blue text where it says Location: - that means you can click to edit! (Yes, just like you can click to edit the hit count or message string which are also in blue.)
And voila! We can now change both the line number and even the character position of the breakpoint without having to delete and recreate all the options (which is a pain if you have some complicated conditions or messages to output or a lot of breakpoints to move).
Hoping this helps someone because not even the Visual Studio Documentation for Using Breakpoints mentions this!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With