Files
llvm-project/lldb/examples/python/in_call_stack.py
Ross Burton 11f1a35917 [lldb] Unify python shebangs (#187257)
As per PEP-0394[1], there is no real concensus over what binary names
Python has, specifically 'python' could be Python 3, Python 2, or not
exist.

However, everyone has a python3 interpreter and the scripts are all
written for Python 3. Unify the shebangs so that the ~50% of shebangs
that use python now use python3.

[1] https://peps.python.org/pep-0394/
2026-04-27 15:01:57 -07:00

25 lines
798 B
Python
Executable File

#!/usr/bin/env python3
def __lldb_init_module(debugger, internal_dict):
debugger.HandleCommand(
f"command alias in_call_stack breakpoint command add --python-function {__name__}.in_call_stack -k name -v %1"
)
def in_call_stack(frame, bp_loc, arg_dict, _):
"""Only break if the given name is in the current call stack."""
name = arg_dict.GetValueForKey("name").GetStringValue(1000)
thread = frame.GetThread()
found = False
for frame in thread.frames:
# Check the symbol.
symbol = frame.GetSymbol()
if symbol and name in frame.GetSymbol().GetName():
return True
# Check the function.
function = frame.GetFunction()
if function and name in function.GetName():
return True
return False