diff --git a/lldb/bindings/python/python-extensions.swig b/lldb/bindings/python/python-extensions.swig --- a/lldb/bindings/python/python-extensions.swig +++ b/lldb/bindings/python/python-extensions.swig @@ -523,9 +523,39 @@ def __ne__(self, other): return not self.__eq__(other) -%} -%pythoncode %{ + +def find(pattern, flags=re.I): + """ + Find matching SB methods/properties. See also Python's builtin `help()`. + """ + import lldb + import re + + regex = re.compile(pattern, flags) + + # Gather matching methods and properties. + methods = [] + + for attr in dir(lldb): + value = getattr(lldb, attr) + if not isinstance(value, type): + continue + + class_name = attr + class_type = value + for method_name in dir(class_type): + if regex.search(method_name): + methods.append(f"lldb.{class_name}.{method_name}") + + if len(methods) == 1: + # For one match, print its help. + help(methods[0]) + return + + # Print the name of each matching method or property. + print(*methods, sep="\n") + class SBSyntheticValueProvider(object): def __init__(self,valobj): @@ -547,10 +577,6 @@ return False -%} - -%pythoncode %{ - # given an lldb.SBBasicType it returns a tuple # (is_numeric, is_signed) # the value of is_signed is undefined if is_numeric == false