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