Fix an issue where the @lldb.command marker would not work with the new 5-argument version of the Python command function

This:
a) teaches PythonCallable to look inside a callable object
b) teaches PythonCallable to discover whether a callable method is bound
c) teaches lldb.command to dispatch to either the older 4 argument version or the newer 5 argument version

llvm-svn: 273640
This commit is contained in:
Enrico Granata
2016-06-24 02:07:15 +00:00
parent 68f7f1cf00
commit a5d6765cb0
4 changed files with 36 additions and 6 deletions

View File

@@ -810,6 +810,7 @@
def command(*args, **kwargs):
import lldb
import inspect
"""A decorator function that registers an LLDB command line
command that is bound to the function it is attached to."""
class obj(object):
@@ -821,11 +822,15 @@ def command(*args, **kwargs):
command = "command script add -f %s.%s %s" % (function.__module__, function.__name__, command_name)
lldb.debugger.HandleCommand(command)
self.function = function
def __call__(self, *args, **kwargs):
self.function(*args, **kwargs)
def __call__(self, debugger, command, exe_ctx, result, dict):
if len(inspect.getargspec(self.function).args) == 5:
self.function(debugger, command, exe_ctx, result, dict)
else:
self.function(debugger, command, result, dict)
def callable(function):
"""Creates a callable object that gets used."""
return obj(function, *args, **kwargs)
f = obj(function, *args, **kwargs)
return f.__call__
return callable
class declaration(object):
@@ -1129,4 +1134,4 @@ def is_numeric_type(basic_type):
#if basic_type == eBasicTypeOther:
return (False,False)
%}
%}