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")
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?
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With