Today I’d like to explain to you how you can prevent the debugger from stepping into trivial functions. In my examples I use wxWidgets and its wxString. It should be almost the same if you use MFC and its CStrings.
If you do a lot of debugging (and who doesn’t?), you’ve probably encountered many function calls that you’d really like to step into. In particular, if the code makes function calls to produce arguments for the function:
call_me( new foo( "a", 1 ), my_vector.begin(), my_vector.end() );
When you are single stepping in the debugger (using F11) and you want to step into a function that has strings as a parameter, the debugger will first step into the string constructor. This is correct but annoying - especially when you are absolutely certain that you don’t need to. You don’t want to debug the string constructor. The same applies to many other functions, e.g. new(), malloc(), wxString::c_str(). There is a way to tell the debugger to step over these functions even if you use “Step Into”.
Create a ‘NoStepInto’ entry for every function you do not want to step into.
Note: Visual Studio uses the regular expression syntax to specify the function names. regexp is much more powerful than wildcards such as ? and *.
Note: Don’t forget - you have to “escape” special characters with ‘\’. If you want to step over wxString::c_str*, you need to write wxString\:\:c_str.*. There is a lot of confusion in the newgroups and other examples if you need to write \\:\\: or simply \:\:.. My personal view is, \: is enough (as is correct with regexp) and the other expression came from pasting a CString to a newgroup post.
—
If you are using Visual Studio 6, add these lines to autoexp.dat under
[ExecutionControl]
wxString\:\:c_str.*=NoStepInto
operator new=NoStepInto
—
If you are using Visual Studio .NET 2003 or 2002, modify the registry.
- Add the Key NativeDE\StepOver under HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\7.1 (or 7.0 if you are using .NET 2002)
- For every function you want to skip, add a new key/string value under the StepOver key.
- The keys must be numerical. Think of them as linenumbers like in the old Basic days. Due to a bug in the Debugger, these numbers will get evaluated in reverse order.
- The string contains the regular expression I have described above.
For instance, this is a good idea:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\7.1\NativeDE\StepOver\10 = wxString\:\:c_str.*
This will prevent the debugger from stepping into these functions when you press F11 or choose “step into”.
Other useful expressions are:
- wxString Constructor
- wxString\:\:wxString
- wxString Destructor
- wxString\:\:~wxString
—
Visual Studio 8 has the same basic functionality as Visual Studio 7 with a few improvements. In addition, you should be aware that the key you must modify is now:
HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\NativeDE\StepOver
You’ll need an account with Admin privileges to set this up.
In addition to the ability to match regular expressions provided in Visual Studio 7, a few new escape sequences have been added to the regular expressions you can use, including '\funct' to match the name of a function, '\scope' to match a scope (e.g., std::my_namespace::etc::so::forth), and '\oper', which matches any operator.
Note: When using these escape sequences, you must indicate the end of the escape sequence with a colon. So you might write '\scope:' followed by the rest of the expression to match.
For example, you could avoid stepping into any overloaded operators by using the expression
\scope:operator\oper:=NoStepInto
which might be useful if you are using a lot of classes with simple operators whose behaviors you can trust to be correct.
—
There is a lot more you can do with it. Once done it saves time and energy 