Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / examples / python / in_call_stack.py
blobc699355ce0045b486c701fe52a893a4191946822
1 #!/usr/bin/env python
4 def __lldb_init_module(debugger, internal_dict):
5 debugger.HandleCommand(
6 f"command alias in_call_stack breakpoint command add --python-function {__name__}.in_call_stack -k name -v %1"
10 def in_call_stack(frame, bp_loc, arg_dict, _):
11 """Only break if the given name is in the current call stack."""
12 name = arg_dict.GetValueForKey("name").GetStringValue(1000)
13 thread = frame.GetThread()
14 found = False
15 for frame in thread.frames:
16 # Check the symbol.
17 symbol = frame.GetSymbol()
18 if symbol and name in frame.GetSymbol().GetName():
19 return True
20 # Check the function.
21 function = frame.GetFunction()
22 if function and name in function.GetName():
23 return True
24 return False