xref: /llvm-project/lldb/test/API/functionalities/conditional_break/conditional_break.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1import lldb
2
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 caller
15    # of the leaf function c() is a().  If it's not the right caller, we ask the
16    # command interpreter to continue execution.
17
18    should_stop = True
19    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 = True
25        else:
26            should_stop = False
27
28    dbg.SetAsync(old_async)
29    return should_stop
30