-1

I can manually skip lines of code by setting a breakpoint, moving the execution cursor and hitting continue.

Is there a way to configure Visual Studio, perhaps with a macro, such that a specific line will be skipped every time it is hit? I could do it manually, but this is highly impractical in instances where the line is hit every frame, or in a loop with a large number of elements.

An alternative is commenting out the line, rebuilding and running the code up to the point I'm testing out. Sure I could add a static boolean to control whether or not the line is executed, but it is still impractical, especially with large codebases where the rebuilding time is not trivial.

Another idea is removing the line straight in memory/disassembly, but it is still impractical, and one has to be extremely careful as the slightest error can be catastrophic.

XenoChrist
  • 309
  • 1
  • 3
  • 11
  • 1
    Is your intent to execute everything except one line? – user4581301 Sep 06 '17 at 21:01
  • One or many lines. I can manually do the break->skip>continue trick on as much code as I want. I'm just looking for a way to mark code regions and perform the trick automatically on them. – XenoChrist Sep 06 '17 at 21:03
  • I often add static bool variables for that, and then while debugging modify such variable to change behaviour, ie. `void foo() { static bool verbose = false; if (verbose) { /*do some heavy logging here*/ } }` Then while debugging I set verbose to true to enable some code. Not sure if that is what you need. – marcinj Sep 06 '17 at 21:11
  • @marcinj I mentioned this possibility in my third paragraph but I hate paying the cost to recompile and re-launch the program; we're talking about 5 lost minutes in my specific case. – XenoChrist Sep 06 '17 at 21:13
  • @XenoChrist I dont remove/add such code very often - and actually I use it only to add extra logging. I agree this is not a good solution if you want to skip any random code. – marcinj Sep 06 '17 at 21:15
  • I can't think of any debugger that allows this off the top. Manually move the instruction pointer/program counter/whatever, that you might be able to do, but jump automatically... never seen it. – user4581301 Sep 06 '17 at 21:18
  • But if I can do easily do it by hand, surely VS offers a way to automate it. – XenoChrist Sep 06 '17 at 21:20

1 Answers1

1

Code Melee - FlexPoints would be an extension which could skip multiple lines of code while debugging without editing code or manually stepping over the line.

https://marketplace.visualstudio.com/items?itemName=CodeMelee.CodeMelee-FlexPoints

Actually this feature request has been submitted before for old VS version:

https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/2221315-implement-a-new-skip-over-breakpoint-type

But product team didn't think about adding this feature in current VS version. So my suggestion is that you could use above extension tool as a workaround, or you could submit a new feature for next VS version.

Jack Zhai
  • 6,230
  • 1
  • 12
  • 20