1import lldb 2 3# bunch of different kinds of python callables that should 4# all work as commands. 5 6 7def check(debugger, command, context, result, internal_dict): 8 if ( 9 not isinstance(debugger, lldb.SBDebugger) 10 or not isinstance(command, str) 11 or not isinstance(result, lldb.SBCommandReturnObject) 12 or not isinstance(internal_dict, dict) 13 or (not context is None and not isinstance(context, lldb.SBExecutionContext)) 14 ): 15 raise Exception() 16 result.AppendMessage("All good.") 17 18 19def vfoobar(*args): 20 check(*args) 21 22 23def v5foobar(debugger, command, context, result, internal_dict, *args): 24 check(debugger, command, context, result, internal_dict) 25 26 27def foobar(debugger, command, context, result, internal_dict): 28 check(debugger, command, context, result, internal_dict) 29 30 31def foobar4(debugger, command, result, internal_dict): 32 check(debugger, command, None, result, internal_dict) 33 34 35class FooBar: 36 @staticmethod 37 def sfoobar(debugger, command, context, result, internal_dict): 38 check(debugger, command, context, result, internal_dict) 39 40 @classmethod 41 def cfoobar(cls, debugger, command, context, result, internal_dict): 42 check(debugger, command, context, result, internal_dict) 43 44 def ifoobar(self, debugger, command, context, result, internal_dict): 45 check(debugger, command, context, result, internal_dict) 46 47 def __call__(self, debugger, command, context, result, internal_dict): 48 check(debugger, command, context, result, internal_dict) 49 50 @staticmethod 51 def sfoobar4(debugger, command, result, internal_dict): 52 check(debugger, command, None, result, internal_dict) 53 54 @classmethod 55 def cfoobar4(cls, debugger, command, result, internal_dict): 56 check(debugger, command, None, result, internal_dict) 57 58 def ifoobar4(self, debugger, command, result, internal_dict): 59 check(debugger, command, None, result, internal_dict) 60 61 62class FooBar4: 63 def __call__(self, debugger, command, result, internal_dict): 64 check(debugger, command, None, result, internal_dict) 65 66 67FooBarObj = FooBar() 68 69FooBar4Obj = FooBar4() 70