31

I'm aware of the "Enable just my code" debug option, but that only works for managed code.

I'm looking for a way to step into a function call without having to step through, for example, an STL string cast operator because there is an implicit conversion from a char* to a string in one of the function's parameters.

Ferruccio
  • 98,941
  • 38
  • 226
  • 299

5 Answers5

21

I found this blog entry which has a solution. Although I'd prefer to be able to say "don't step into anything that isn't part of this project", this looks workable.

EDIT: After looking at a few blogs and newsgroups, the method is to add an entry for each function that you don't want to step into under this registry key (assuming VS 2005):

32 bit Windows
    \\HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\NativeDE\StepOver
64 bit Windows
    \\HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\VisualStudio\8.0\NativeDE\StepOver

Version numbers for the path:

Visual Studio 2005: 8.0
Visual Studio 2008: 9.0
Visual Studio 2010: 10.0
Visual Studio 2012: 11.0
Visual Studio 2013: 12.0

This key contains a set of rules which affect how stepping is performed. Each rule is specified as a separate entry whose name is a decimal number and whose value is a function name pattern that specifies which functions we want to affect. e.g.

    "10" = "boost\:\:scoped_ptr.*\:\:.*=NoStepInto"

prevents stepping into boost::scoped_ptr functions.

The rules are evaluated from high to low values until a matching pattern is found, or there are no rules left. In that case the function is stepped into.

Function names are regular expressions.

Colons need to be quoted with a backslash.

You can specify StepInto as well as NoStepInto. This gives you a way to avoid stepping into all but a few functions in the same scope/namespace.

Restart Visual Studio to pick up the changes to the registry.

Ferruccio
  • 98,941
  • 38
  • 226
  • 299
  • 3
    Although Visual Studio 2012, 2013 are listed in the details above, the registry is NOT used anymore. Follow the blog entry link for details on how to update default.natstepfilter. – jws Jul 15 '14 at 14:01
  • I think the registry is used in VS 2012 and 2013 when you enable Edit and Continue. – Marian Spanik Aug 22 '16 at 11:21
6

https://learn.microsoft.com/en-us/visualstudio/debugger/just-my-code?view=vs-2019#BKMK_CPP_Customize_stepping_behavior

In C++ projects, you can specify functions to step over by listing them as non-user code in *.natstepfilter files. Functions listed in *.natstepfilter files are not dependent on Just My Code settings.

  • To specify non-user code for all local Visual Studio users, add the .natstepfilter file to the %VsInstallDirectory%\Common7\Packages\Debugger\Visualizers folder.
  • To specify non-user code for an individual user, add the .natstepfilter file to the %USERPROFILE%\My Documents\<Visual Studio version>\Visualizers folder.

A .natstepfilter file is an XML file with this syntax:

<?xml version="1.0" encoding="utf-8"?>
<StepFilter xmlns="http://schemas.microsoft.com/vstudio/debugger/natstepfilter/2010">
    <Function>
        <Name>FunctionSpec</Name>
        <Action>StepAction</Action>
    </Function>
    <Function>
        <Name>FunctionSpec</Name>
        <Module>ModuleSpec</Module>
        <Action>StepAction</Action>
    </Function>
</StepFilter>
Element Description
Function Required. Specifies one or more functions as non-user functions.
Name Required. An ECMA-262 formatted regular expression specifying the full function name to match. For example:

<Name>MyNS::MyClass.*</Name>

tells the debugger that all methods in MyNS::MyClass are to be considered non-user code. The match is case-sensitive.
Module Optional. An ECMA-262 formatted regular expression specifying the full path to the module containing the function. The match is case-insensitive.
Action Required. One of these case-sensitive values:

NoStepInto - tells the debugger to step over the function.
StepInto - tells the debugger to step into the function, overriding any other NoStepInto for the matched function.
Mark Ingram
  • 71,849
  • 51
  • 176
  • 230
4

My copy-past:

Avoiding Stepping Into Things

It's often useful to avoid stepping into some common code like constructors or overloaded operators. autoexp.dat provides this capability. Add a section called "[ExecutionControl]". Add keys where the key is the function name and the value is "NoStepInto". You can specify an asterisk (*) as a wildcard as the first set of colons for a namespace or class.

autoexp.dat is only read on Visual Studio's start up.

To ignore the function myfunctionname, and all calls to the class CFoo:

[ExecutionControl]

myfunctionname=NoStepInto

CFoo::*=NoStepInto

To ignore construction and assignment of MFC CStrings: (Notice the extra = in CString::operator=.)

[ExecutionControl]

CString::CString=NoStepInto

CString::operator==NoStepInto

To ignore all ATL calls:

[ExecutionControl]

ATL::*=NoStepInto

from this (http://www.highprogrammer.com/alan/windev/visualstudio.html) article.

Also you can use "Step Into Specific Function" from pupup menu.

Edit Sorry, it looks like that autoexp.dat doesn't works in vs 2003/2005. The same you can do with registry settings. http://groups.google.com/group/microsoft.public.vsnet.debugging/browse_thread/thread/b03dee5a626470c0/26addb1b539883e8

bayda
  • 13,365
  • 8
  • 39
  • 48
  • It looks like the AUTOEXP.DAT file is supported only in Visual Studio 6. Newer versions use registry entries. – Ferruccio Mar 09 '09 at 16:12
4

There is also the "step into specific" entry on the context menu, that will list the functions that could be stepped into on the current line, and you can pick the one you want.

Rob K
  • 8,757
  • 2
  • 32
  • 36
3

VS6 used to let you define values in the autoexp file that let you skip stepping into common functions (e.g. string constructors). Starting with VS7 these exclusions were moved to the registry. Ease of use takes a serious hit.

In VS7 and higher Microsoft, in their wisdom, moved these exclusions to the registry. Here are some examples:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\NativeDE\StepOver]
"10"="CString\\:\\:CString=NoStepInto"
"11"=".*\\.c_str.*=NoStepInto"

Key names represent the search order. Key values contain VS regular expressions to search for.

If you create your own exclusions, be sure to get the name out of the disassembly view. The declaration in source may not match the compiler generated name, especially for templated functions.

Aaron Saarela
  • 3,956
  • 1
  • 19
  • 17