Reputation: 5675
The problem: I need to make a script or an expression that that doesn't break if somewhere on callstack is a function with a specific name.
Specific question: How can I get functions on callstack to a list of strings ?
Example:
Module!MyFunctionWithConditionalBreakpoint
Module!Function1
Module!Function2
Module!Function3
Module!MyFunctionWithConditionalBreakpoint
Module!Function1
Module!ClassA:MemberFunction
Module!Function3
I want Module!MyFunctionWithConditionalBreakpoint
to break only if the call cames from Module!ClassA:MemberFunction
I need this in unmanaged code. Managed solution is something like
System.Diagnostics.StackTrace().ToString().Contains("YourMethodName")
Upvotes: 11
Views: 3263
Reputation: 2753
Why not set a breakpoint on entering Module!ClassA:MemberFunction to enable a breakpoint for Module!MyFunctionWithConditionalBreakpoint and upon leaving Module!ClassA:MemberFunction disabling it?
Upvotes: 1
Reputation: 3864
In WinDbg you may set a conditional breakpoint using special $spat function:
bp Module!MyFunctionWithConditionalBreakpoint "r $t0 = 0;.foreach (v { k }) { .if ($spat(\"v\", \"*Module!ClassA:MemberFunction*\")) { r $t0 = 1;.break } }; .if($t0 = 0) { gc }"
In pseudo-code it will be something like:
t0 = 0
foreach (token in k-command result) {
if (token.contains("Module!ClassA:MemberFunction")) {
t0 = 1
break
}
}
if (t0 == 0) {
// continue execution
} else {
// break into the debugger
}
Upvotes: 12