summaryrefslogtreecommitdiff
path: root/scripts/Python/python-extensions.swig
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/Python/python-extensions.swig')
-rw-r--r--scripts/Python/python-extensions.swig80
1 files changed, 73 insertions, 7 deletions
diff --git a/scripts/Python/python-extensions.swig b/scripts/Python/python-extensions.swig
index fae7f401bf134..693b06b9aab39 100644
--- a/scripts/Python/python-extensions.swig
+++ b/scripts/Python/python-extensions.swig
@@ -325,6 +325,22 @@
return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
%}
}
+
+%extend lldb::SBMemoryRegionInfo {
+ PyObject *lldb::SBMemoryRegionInfo::__str__ (){
+ lldb::SBStream description;
+ $self->GetDescription (description);
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return lldb_private::PythonString(llvm::StringRef(desc, desc_len)).release();
+ else
+ return lldb_private::PythonString("").release();
+ }
+}
+
%extend lldb::SBModule {
PyObject *lldb::SBModule::__str__ (){
lldb::SBStream description;
@@ -810,6 +826,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 +838,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):
@@ -1024,11 +1045,13 @@ class value(object):
return complex (int(self))
def __int__(self):
+ is_num,is_sign = is_numeric_type(self.sbvalue.GetType().GetCanonicalType().GetBasicType())
+ if is_num and not is_sign: return self.sbvalue.GetValueAsUnsigned()
return self.sbvalue.GetValueAsSigned()
-
+
def __long__(self):
- return self.sbvalue.GetValueAsSigned()
-
+ return self.__int__()
+
def __float__(self):
return float (self.sbvalue.GetValueAsSigned())
@@ -1084,4 +1107,47 @@ class SBSyntheticValueProvider(object):
return False
-%} \ No newline at end of file
+%}
+
+%pythoncode %{
+
+# given an lldb.SBBasicType it returns a tuple
+# (is_numeric, is_signed)
+# the value of is_signed is undefined if is_numeric == false
+def is_numeric_type(basic_type):
+ if basic_type == eBasicTypeInvalid: return (False,False)
+ if basic_type == eBasicTypeVoid: return (False,False)
+ if basic_type == eBasicTypeChar: return (True,False)
+ if basic_type == eBasicTypeSignedChar: return (True,True)
+ if basic_type == eBasicTypeUnsignedChar: return (True,False)
+ if basic_type == eBasicTypeWChar: return (True,False)
+ if basic_type == eBasicTypeSignedWChar: return (True,True)
+ if basic_type == eBasicTypeUnsignedWChar: return (True,False)
+ if basic_type == eBasicTypeChar16: return (True,False)
+ if basic_type == eBasicTypeChar32: return (True,False)
+ if basic_type == eBasicTypeShort: return (True,True)
+ if basic_type == eBasicTypeUnsignedShort: return (True,False)
+ if basic_type == eBasicTypeInt: return (True,True)
+ if basic_type == eBasicTypeUnsignedInt: return (True,False)
+ if basic_type == eBasicTypeLong: return (True,True)
+ if basic_type == eBasicTypeUnsignedLong: return (True,False)
+ if basic_type == eBasicTypeLongLong: return (True,True)
+ if basic_type == eBasicTypeUnsignedLongLong: return (True,False)
+ if basic_type == eBasicTypeInt128: return (True,True)
+ if basic_type == eBasicTypeUnsignedInt128: return (True,False)
+ if basic_type == eBasicTypeBool: return (False,False)
+ if basic_type == eBasicTypeHalf: return (True,True)
+ if basic_type == eBasicTypeFloat: return (True,True)
+ if basic_type == eBasicTypeDouble: return (True,True)
+ if basic_type == eBasicTypeLongDouble: return (True,True)
+ if basic_type == eBasicTypeFloatComplex: return (True,True)
+ if basic_type == eBasicTypeDoubleComplex: return (True,True)
+ if basic_type == eBasicTypeLongDoubleComplex: return (True,True)
+ if basic_type == eBasicTypeObjCID: return (False,False)
+ if basic_type == eBasicTypeObjCClass: return (False,False)
+ if basic_type == eBasicTypeObjCSel: return (False,False)
+ if basic_type == eBasicTypeNullPtr: return (False,False)
+ #if basic_type == eBasicTypeOther:
+ return (False,False)
+
+%}