20

During step-by-step debugging, I often use "step into" to halt at every line in the section that I am debugging, to see all my code that's executed.

But library calls can disrupt this work flow: The debugger will jump into some STL file and continue there. I then have to press "jump out" to go back to my own code.

Is there a way to prevent the debugger from opening STL source files? A blacklist or a setting somewhere? I work with native C++ code. The "only my code" debugger setting unfortunately only works for managed code.

Felix Dombek
  • 13,664
  • 17
  • 79
  • 131
  • possible duplicate of [How to skip common classes in VS 2008 when stepping in?](http://stackoverflow.com/questions/2062881/how-to-skip-common-classes-in-vs-2008-when-stepping-in) – Suma Sep 21 '11 at 08:40

3 Answers3

12

good question, the debugger constantly jumping into everything is indeed a huge slowdown and distraction during debugging. Luckily there's a solution:

open your registry editor, navigate to

HKLM\SOFTWARE\Microsoft\VisualStudio\10.0\NativeDE\StepOver

(add \Wow6432Node after SOFTWARE if you're on a 64bit machine, this casued me headaches in the past).

Add a new String Value (REG_SZ). The name is not so important, I used NoSTL for clarity and set it's value to

std\:\:.*=NoStepInto

This tells the debugger to not step into anything matching that regex so it will skip every function (global and class level) in the std namespace. By using StepInto you can add overrides for specific methods, and you can still use breakpoints off course. It's also handy to add some of your own methods that get stepped into often but of which you know the result by head.

Here is a more detailed explanation, google on NoStepInto for more scattered information.

stijn
  • 34,664
  • 13
  • 111
  • 163
3

The answer is as above mentioned, but in case you use VisualStudio 2017 or it didn't work for you, then try the following:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Packages\Debugger\Visualizers

Open the following file with notepad or whatever you have:

default.natjmc

and add this line: <Function><Name>std\:\:.*</Name><Action>NoStepInto</Action></Function> The 'name' means the value of the registry key in that file and 'action' is self-explanatory.

If you want to add the registry key too, (not sure if it is necessary), then you will find it here: \HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VSTA\8.0\NativeDE\StepOver At least, that was the path in my case. It took a good hour to find these, so I hope that it will help somebody. Remove the 'Wow6432Node' if you have 32bit machine, as above mentioned.

CorpseDead
  • 113
  • 2
  • 7
  • I did this again when I reinstalled my pc. The location was still the Package\Visualisation folder. Registry key wasn't needed for me. But I had to add this line in the: `default.natstepfilter` file this time, instead of the `default.natjmc` file. Simply said, add it to the file which has the same format as the line I posted above. For clarification, this format: `std\:\:.*NoStepInto` – CorpseDead Nov 07 '17 at 21:20
  • 2
    For visual studio 2019, you have to edit `C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Packages\Debugger\Visualizers\default.natstepfilter` . The change is immediately applied, no need to restart the IDE. – Pascal T. Oct 06 '19 at 11:29
  • And how to do it the same in Visual Studio 2015? – Molochnik Nov 25 '19 at 08:56
  • I don't have VS2015 installed but I think that something similar to what I wrote or the accepted answer should work for it. The pattern seems to be similar for all of them, after all. – CorpseDead Nov 26 '19 at 09:41
-3

You don't use F10/F11/Shift+F11??? Those are "step over", "step into", "step out", and there are many more that are useful. Much more usable than hunting for buttons, and you never have to take your eyes off the source code.

In general you're well served by using keyboard shortcuts in Visual Studio instead of the mouse. Not just for debugging, but everything. Learn 'em, you'll love 'em! You probably can't learn them all at once, just pick a few functions you use often, get used to them, then start on a different set. It becomes second nature over time.

Sorry that this is off-topic, but your original question was beautifully answered by the previous poster already, and I thought I'd help with something else :)

steel_3d
  • 3
  • 1