30 lines · python
1import lldb2 3 4def stop_if_called_from_a(frame, bp_loc, dict):5 thread = frame.GetThread()6 process = thread.GetProcess()7 target = process.GetTarget()8 dbg = target.GetDebugger()9 10 # Perform synchronous interaction with the debugger.11 old_async = dbg.GetAsync()12 dbg.SetAsync(True)13 14 # We check the call frames in order to stop only when the immediate caller15 # of the leaf function c() is a(). If it's not the right caller, we ask the16 # command interpreter to continue execution.17 18 should_stop = True19 if thread.GetNumFrames() >= 2:20 if (21 thread.frames[0].function.name == "c"22 and thread.frames[1].function.name == "a"23 ):24 should_stop = True25 else:26 should_stop = False27 28 dbg.SetAsync(old_async)29 return should_stop30