Windbg Set Conditional Breakpoints that depends on Call Stack

守給你的承諾、 提交于 2019-12-03 06:19:34

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
}

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?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!