Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the location of a breakpoint in Visual Studio 2017

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?

like image 362
bmadtiger Avatar asked Jun 19 '18 07:06

bmadtiger


People also ask

How do I move breakpoints in Visual Studio?

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.

Where are Visual Studio breakpoints stored?

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.

How do I view breakpoints in Visual Studio?

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

How do I add a data breakpoint in Visual Studio?

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.


1 Answers

Okay, so maybe I'm just blind, but it was not at all obvious to me.

VS2017 Breakpoint Settings

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

VS2017 Breakpoint Settings - edit Location

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!

like image 67
bmadtiger Avatar answered Sep 19 '22 08:09

bmadtiger