Block debugger to step into functions
I'm searching for a way to block the Visual Studio debugger to step into certain classes and functions when pressing F11. Or block some files so the IDE won't open them, just step trough (except when there's an exception).
I know this sounds kind of stupid, but I'm using smart pointers and other helper classes, many overloaded operators, simple expression are composed of many function calls, which disappear on optimization, so it's not a speed issue, but it is a debugging issue, opening and closing that many files all the time, going through many functions, accidentally leaving the target code and so on.
Here's an example, of what I'm talking about:
stepToThisFunction(objectOfIgnoreClass->ignoreFunction());
When the debugger is on this line, pressing F11 should enter only stepToThisFunction
, stepping through the ignoreFunction()
or possibly any function call from objectOfIgnoreClass
.
Some native equivalent of the managed DebuggerStepThrough
. I don't want to use CLI. Just a keyword or macro written before the function/class. I also found something,开发者_如何学运维 some registry key modifications, but that doesn't seem to be the thing I'm looking for, or I don't understand it's mechanism (I don't even understand what registry keys have to do with this). Also, "put a breakpoint" and "run to cursor" are not accepted solution.
I have a macro to do precisely this. It's not very fast, but it's very useful (in fact I've also converted it to C# so I can use it in an AddIn, which is much faster). Just customise the regexp with the functions you want to ignore and bind to F11 or another key of your choice:
Sub StepIntoNextRealFunction()
DTE.Debugger.StepInto(True)
Dim frame As EnvDTE.StackFrame = DTE.Debugger.CurrentStackFrame
Dim fn As String = frame.FunctionName
Dim skipRE As Regex = New Regex("operator.*->|MyString::MyString|operator new|operator.*\*|ignoreFunction")
If (skipRE.Match(fn).Success) Then
DTE.Debugger.StepOut(True)
DTE.Debugger.StepInto(True)
End If
End Sub
Edit: here's a C# version - you'll need to create an addin and then wire up to the DTE object:
public void StepIntoNextRealFunction(DTE2 dte)
{
Debugger2 debugger=(Debugger2)dte.Debugger;
debugger.StepInto(true);
while (true) {
EnvDTE.StackFrame frame = debugger.CurrentStackFrame;
string fn = frame.FunctionName;
Regex skipRE = new Regex("operator.*->|basic_string.*basic_string");
if ((skipRE.Match(fn).Success)) {
debugger.StepOut(true);
debugger.StepInto(true);
} else {
break;
}
}
}
Right-click on the line and choose "Step into specific". Then choose the function you want.
There is an unsupported feature in Visual Studio that allows you to permanently configure the debugger not to step into certain functions. The details are given in this MSDN blog post:
http://blogs.msdn.com/b/andypennell/archive/2004/02/06/69004.aspx
精彩评论