conditional_break.py [plain text]
import sys
import lldb
import lldbutil
def stop_if_called_from_a():
dbg = lldb.SBDebugger.FindDebuggerWithID(lldb.debugger_unique_id)
old_async = dbg.GetAsync()
dbg.SetAsync(True)
target = dbg.GetSelectedTarget()
process = target.GetProcess()
thread = process.GetThreadAtIndex(0)
print >> sys.stdout, "Checking call frames..."
lldbutil.print_stacktrace(thread)
should_stop = True
if thread.GetNumFrames() >= 2:
funcs = lldbutil.get_function_names(thread)
print >> sys.stdout, funcs[0], "called from", funcs[1]
if (funcs[0] == 'c' and funcs[1] == 'a'):
should_stop = True
else:
process.Continue()
should_stop = False
dbg.SetAsync(old_async)
return should_stop