summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/scripts/Python/python-extensions.swig276
-rw-r--r--lldb/scripts/interface/SBAddress.i2
-rw-r--r--lldb/scripts/interface/SBBlock.i2
-rw-r--r--lldb/scripts/interface/SBBreakpoint.i2
-rw-r--r--lldb/scripts/interface/SBBreakpointLocation.i2
-rw-r--r--lldb/scripts/interface/SBBreakpointName.i1
-rw-r--r--lldb/scripts/interface/SBCommandReturnObject.i2
-rw-r--r--lldb/scripts/interface/SBCompileUnit.i2
-rw-r--r--lldb/scripts/interface/SBData.i2
-rw-r--r--lldb/scripts/interface/SBDebugger.i2
-rw-r--r--lldb/scripts/interface/SBDeclaration.i2
-rw-r--r--lldb/scripts/interface/SBError.i2
-rw-r--r--lldb/scripts/interface/SBFileSpec.i2
-rw-r--r--lldb/scripts/interface/SBFrame.i2
-rw-r--r--lldb/scripts/interface/SBFunction.i2
-rw-r--r--lldb/scripts/interface/SBInstruction.i2
-rw-r--r--lldb/scripts/interface/SBInstructionList.i2
-rw-r--r--lldb/scripts/interface/SBLineEntry.i2
-rw-r--r--lldb/scripts/interface/SBMemoryRegionInfo.i1
-rw-r--r--lldb/scripts/interface/SBModule.i2
-rw-r--r--lldb/scripts/interface/SBModuleSpec.i2
-rw-r--r--lldb/scripts/interface/SBTarget.i16
-rw-r--r--lldb/scripts/lldb.swig18
-rw-r--r--lldb/scripts/lldb_lua.swig1
-rw-r--r--lldb/scripts/macros.swig33
25 files changed, 95 insertions, 287 deletions
diff --git a/lldb/scripts/Python/python-extensions.swig b/lldb/scripts/Python/python-extensions.swig
index dbd4b1d79d0..36dac19644b 100644
--- a/lldb/scripts/Python/python-extensions.swig
+++ b/lldb/scripts/Python/python-extensions.swig
@@ -1,42 +1,4 @@
-%extend lldb::SBAddress {
- %nothreadallow;
- PyObject *lldb::SBAddress::__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;
- return PythonString(llvm::StringRef(desc, desc_len)).release();
- }
- %clearnothreadallow;
-}
-%extend lldb::SBBlock {
- %nothreadallow;
- PyObject *lldb::SBBlock::__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;
- return PythonString(llvm::StringRef(desc, desc_len)).release();
- }
- %clearnothreadallow;
-}
%extend lldb::SBBreakpoint {
- %nothreadallow;
- PyObject *lldb::SBBreakpoint::__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;
- return PythonString(llvm::StringRef(desc, desc_len)).release();
- }
- %clearnothreadallow;
-
%pythoncode %{
def __eq__(self, rhs):
if not isinstance(rhs, type(self)):
@@ -50,34 +12,6 @@
return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
%}
-
-}
-%extend lldb::SBBreakpointLocation {
- %nothreadallow;
- PyObject *lldb::SBBreakpointLocation::__str__ (){
- lldb::SBStream description;
- $self->GetDescription (description, lldb::eDescriptionLevelFull);
- 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;
- return PythonString(llvm::StringRef(desc, desc_len)).release();
- }
- %clearnothreadallow;
-}
-
-%extend lldb::SBBreakpointName {
- %nothreadallow;
- PyObject *lldb::SBBreakpointName::__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;
- return PythonString(llvm::StringRef(desc, desc_len)).release();
- }
- %clearnothreadallow;
}
%extend lldb::SBBroadcaster {
@@ -97,18 +31,6 @@
}
%extend lldb::SBCommandReturnObject {
- %nothreadallow;
- PyObject *lldb::SBCommandReturnObject::__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;
- return PythonString(llvm::StringRef(desc, desc_len)).release();
- }
- %clearnothreadallow;
-
/* the write() and flush() calls are not part of the SB API proper, and are solely for Python usage
they are meant to make an SBCommandReturnObject into a file-like object so that instructions of the sort
print >>sb_command_return_object, "something"
@@ -122,18 +44,8 @@
void lldb::SBCommandReturnObject::flush ()
{}
}
+
%extend lldb::SBCompileUnit {
- %nothreadallow;
- PyObject *lldb::SBCompileUnit::__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;
- return PythonString(llvm::StringRef(desc, desc_len)).release();
- }
- %clearnothreadallow;
%pythoncode %{
def __eq__(self, rhs):
if not isinstance(rhs, type(self)):
@@ -148,45 +60,8 @@
return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
%}
}
-%extend lldb::SBData {
- %nothreadallow;
- PyObject *lldb::SBData::__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;
- return PythonString(llvm::StringRef(desc, desc_len)).release();
- }
- %clearnothreadallow;
-}
-%extend lldb::SBDebugger {
- %nothreadallow;
- PyObject *lldb::SBDebugger::__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;
- return PythonString(llvm::StringRef(desc, desc_len)).release();
- }
- %clearnothreadallow;
-}
-%extend lldb::SBDeclaration {
- %nothreadallow;
- PyObject *lldb::SBDeclaration::__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;
- return PythonString(llvm::StringRef(desc, desc_len)).release();
- }
- %clearnothreadallow;
+%extend lldb::SBDeclaration {
%pythoncode %{
def __eq__(self, rhs):
if not isinstance(rhs, type(self)):
@@ -200,60 +75,9 @@
return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
%}
-
-}
-%extend lldb::SBError {
- %nothreadallow;
- PyObject *lldb::SBError::__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;
- return PythonString(llvm::StringRef(desc, desc_len)).release();
- }
- %clearnothreadallow;
-}
-%extend lldb::SBFileSpec {
- %nothreadallow;
- PyObject *lldb::SBFileSpec::__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;
- return PythonString(llvm::StringRef(desc, desc_len)).release();
- }
- %clearnothreadallow;
}
-%extend lldb::SBFrame {
- %nothreadallow;
- PyObject *lldb::SBFrame::__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;
- return PythonString(llvm::StringRef(desc, desc_len)).release();
- }
- %clearnothreadallow;
-}
-%extend lldb::SBFunction {
- %nothreadallow;
- PyObject *lldb::SBFunction::__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;
- return PythonString(llvm::StringRef(desc, desc_len)).release();
- }
- %clearnothreadallow;
+%extend lldb::SBFunction {
%pythoncode %{
def __eq__(self, rhs):
if not isinstance(rhs, type(self)):
@@ -267,47 +91,9 @@
return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
%}
-
-}
-%extend lldb::SBInstruction {
- %nothreadallow;
- PyObject *lldb::SBInstruction::__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;
- return PythonString(llvm::StringRef(desc, desc_len)).release();
- }
- %clearnothreadallow;
-}
-%extend lldb::SBInstructionList {
- %nothreadallow;
- PyObject *lldb::SBInstructionList::__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;
- return PythonString(llvm::StringRef(desc, desc_len)).release();
- }
- %clearnothreadallow;
}
-%extend lldb::SBLineEntry {
- %nothreadallow;
- PyObject *lldb::SBLineEntry::__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;
- return PythonString(llvm::StringRef(desc, desc_len)).release();
- }
- %clearnothreadallow;
+%extend lldb::SBLineEntry {
%pythoncode %{
def __eq__(self, rhs):
if not isinstance(rhs, type(self)):
@@ -323,33 +109,7 @@
%}
}
-%extend lldb::SBMemoryRegionInfo {
- %nothreadallow;
- 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;
- return PythonString(llvm::StringRef(desc, desc_len)).release();
- }
- %clearnothreadallow;
-}
-
%extend lldb::SBModule {
- %nothreadallow;
- PyObject *lldb::SBModule::__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;
- return PythonString(llvm::StringRef(desc, desc_len)).release();
- }
- %clearnothreadallow;
-
%pythoncode %{
def __eq__(self, rhs):
if not isinstance(rhs, type(self)):
@@ -365,34 +125,6 @@
%}
}
-%extend lldb::SBModuleSpec {
- %nothreadallow;
- PyObject *lldb::SBModuleSpec::__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;
- return PythonString(llvm::StringRef(desc, desc_len)).release();
- }
- %clearnothreadallow;
-}
-
-%extend lldb::SBModuleSpecList {
- %nothreadallow;
- PyObject *lldb::SBModuleSpecList::__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;
- return PythonString(llvm::StringRef(desc, desc_len)).release();
- }
- %clearnothreadallow;
-}
-
%extend lldb::SBProcess {
%nothreadallow;
PyObject *lldb::SBProcess::__str__ (){
diff --git a/lldb/scripts/interface/SBAddress.i b/lldb/scripts/interface/SBAddress.i
index 6c5352bac6d..4658534d153 100644
--- a/lldb/scripts/interface/SBAddress.i
+++ b/lldb/scripts/interface/SBAddress.i
@@ -140,6 +140,8 @@ public:
lldb::SBLineEntry
GetLineEntry ();
+ STRING_EXTENSION(SBAddress)
+
#ifdef SWIGPYTHON
%pythoncode %{
def __get_load_addr_property__ (self):
diff --git a/lldb/scripts/interface/SBBlock.i b/lldb/scripts/interface/SBBlock.i
index 73079a11760..8bd8e37953c 100644
--- a/lldb/scripts/interface/SBBlock.i
+++ b/lldb/scripts/interface/SBBlock.i
@@ -100,6 +100,8 @@ public:
bool locals,
bool statics);
+ STRING_EXTENSION(SBBlock)
+
#ifdef SWIGPYTHON
%pythoncode %{
def get_range_at_index(self, idx):
diff --git a/lldb/scripts/interface/SBBreakpoint.i b/lldb/scripts/interface/SBBreakpoint.i
index f84f2ada3d3..20354346be9 100644
--- a/lldb/scripts/interface/SBBreakpoint.i
+++ b/lldb/scripts/interface/SBBreakpoint.i
@@ -249,6 +249,8 @@ public:
bool
IsHardware ();
+ STRING_EXTENSION(SBBreakpoint)
+
#ifdef SWIGPYTHON
%pythoncode %{
diff --git a/lldb/scripts/interface/SBBreakpointLocation.i b/lldb/scripts/interface/SBBreakpointLocation.i
index 44fd42b514f..dc39c83c2d6 100644
--- a/lldb/scripts/interface/SBBreakpointLocation.i
+++ b/lldb/scripts/interface/SBBreakpointLocation.i
@@ -134,6 +134,8 @@ public:
SBBreakpoint
GetBreakpoint ();
+
+ STRING_EXTENSION_LEVEL(SBBreakpointLocation, lldb::eDescriptionLevelFull)
};
} // namespace lldb
diff --git a/lldb/scripts/interface/SBBreakpointName.i b/lldb/scripts/interface/SBBreakpointName.i
index 2a06d0a2105..e280d422459 100644
--- a/lldb/scripts/interface/SBBreakpointName.i
+++ b/lldb/scripts/interface/SBBreakpointName.i
@@ -108,6 +108,7 @@ public:
bool GetDescription(lldb::SBStream &description);
+ STRING_EXTENSION(SBBreakpointName)
};
} // namespace lldb
diff --git a/lldb/scripts/interface/SBCommandReturnObject.i b/lldb/scripts/interface/SBCommandReturnObject.i
index 73d4001aaba..affa16520f2 100644
--- a/lldb/scripts/interface/SBCommandReturnObject.i
+++ b/lldb/scripts/interface/SBCommandReturnObject.i
@@ -96,6 +96,8 @@ public:
void SetImmediateOutputFile(lldb::FileSP BORROWED);
void SetImmediateErrorFile(lldb::FileSP BORROWED);
+ STRING_EXTENSION(SBCommandReturnObject)
+
%extend {
// transfer_ownership does nothing, and is here for compatibility with
// old scripts. Ownership is tracked by reference count in the ordinary way.
diff --git a/lldb/scripts/interface/SBCompileUnit.i b/lldb/scripts/interface/SBCompileUnit.i
index bc2d45ae8e5..d6a4c07038c 100644
--- a/lldb/scripts/interface/SBCompileUnit.i
+++ b/lldb/scripts/interface/SBCompileUnit.i
@@ -116,6 +116,8 @@ public:
bool
operator != (const lldb::SBCompileUnit &rhs) const;
+ STRING_EXTENSION(SBCompileUnit)
+
#ifdef SWIGPYTHON
%pythoncode %{
def __iter__(self):
diff --git a/lldb/scripts/interface/SBData.i b/lldb/scripts/interface/SBData.i
index fdaa6962f0e..3e74240329e 100644
--- a/lldb/scripts/interface/SBData.i
+++ b/lldb/scripts/interface/SBData.i
@@ -134,6 +134,8 @@ public:
bool
SetDataFromDoubleArray (double* array, size_t array_len);
+ STRING_EXTENSION(SBData)
+
#ifdef SWIGPYTHON
%pythoncode %{
diff --git a/lldb/scripts/interface/SBDebugger.i b/lldb/scripts/interface/SBDebugger.i
index 52f65841893..f2e23a7ed78 100644
--- a/lldb/scripts/interface/SBDebugger.i
+++ b/lldb/scripts/interface/SBDebugger.i
@@ -479,6 +479,8 @@ public:
lldb::SBTypeSynthetic
GetSyntheticForType (lldb::SBTypeNameSpecifier);
+ STRING_EXTENSION(SBDebugger)
+
%feature("docstring",
"Launch a command interpreter session. Commands are read from standard input or
from the input handle specified for the debugger object. Output/errors are
diff --git a/lldb/scripts/interface/SBDeclaration.i b/lldb/scripts/interface/SBDeclaration.i
index cdaec856764..621c1a0ab7c 100644
--- a/lldb/scripts/interface/SBDeclaration.i
+++ b/lldb/scripts/interface/SBDeclaration.i
@@ -53,6 +53,8 @@ namespace lldb {
bool
operator != (const lldb::SBDeclaration &rhs) const;
+ STRING_EXTENSION(SBDeclaration)
+
#ifdef SWIGPYTHON
%pythoncode %{
file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this line entry.''')
diff --git a/lldb/scripts/interface/SBError.i b/lldb/scripts/interface/SBError.i
index 96cd6c4886f..ea48e2263a7 100644
--- a/lldb/scripts/interface/SBError.i
+++ b/lldb/scripts/interface/SBError.i
@@ -105,6 +105,8 @@ public:
bool
GetDescription (lldb::SBStream &description);
+ STRING_EXTENSION(SBError)
+
#ifdef SWIGPYTHON
%pythoncode %{
value = property(GetError, None, doc='''A read only property that returns the same result as GetError().''')
diff --git a/lldb/scripts/interface/SBFileSpec.i b/lldb/scripts/interface/SBFileSpec.i
index 07a7630ebba..d287a940c05 100644
--- a/lldb/scripts/interface/SBFileSpec.i
+++ b/lldb/scripts/interface/SBFileSpec.i
@@ -80,6 +80,8 @@ public:
void
AppendPathComponent (const char *file_or_directory);
+ STRING_EXTENSION(SBFileSpec)
+
#ifdef SWIGPYTHON
%pythoncode %{
def __get_fullpath__(self):
diff --git a/lldb/scripts/interface/SBFrame.i b/lldb/scripts/interface/SBFrame.i
index 811f7f22f9b..c65b88f863e 100644
--- a/lldb/scripts/interface/SBFrame.i
+++ b/lldb/scripts/interface/SBFrame.i
@@ -285,6 +285,8 @@ public:
bool
GetDescription (lldb::SBStream &description);
+ STRING_EXTENSION(SBFrame)
+
#ifdef SWIGPYTHON
%pythoncode %{
def get_all_variables(self):
diff --git a/lldb/scripts/interface/SBFunction.i b/lldb/scripts/interface/SBFunction.i
index 7b157bb3881..630c4db22c5 100644
--- a/lldb/scripts/interface/SBFunction.i
+++ b/lldb/scripts/interface/SBFunction.i
@@ -111,6 +111,8 @@ public:
bool
operator != (const lldb::SBFunction &rhs) const;
+ STRING_EXTENSION(SBFunction)
+
#ifdef SWIGPYTHON
%pythoncode %{
def get_instructions_from_current_target (self):
diff --git a/lldb/scripts/interface/SBInstruction.i b/lldb/scripts/interface/SBInstruction.i
index 09688214630..d50a080fd04 100644
--- a/lldb/scripts/interface/SBInstruction.i
+++ b/lldb/scripts/interface/SBInstruction.i
@@ -74,6 +74,8 @@ public:
bool
TestEmulation (lldb::SBStream &output_stream, const char *test_file);
+ STRING_EXTENSION(SBInstruction)
+
#ifdef SWIGPYTHON
%pythoncode %{
def __mnemonic_property__ (self):
diff --git a/lldb/scripts/interface/SBInstructionList.i b/lldb/scripts/interface/SBInstructionList.i
index d50deba4f5e..13573230275 100644
--- a/lldb/scripts/interface/SBInstructionList.i
+++ b/lldb/scripts/interface/SBInstructionList.i
@@ -66,6 +66,8 @@ public:
bool
DumpEmulationForAllInstructions (const char *triple);
+ STRING_EXTENSION(SBInstructionList)
+
#ifdef SWIGPYTHON
%pythoncode %{
def __iter__(self):
diff --git a/lldb/scripts/interface/SBLineEntry.i b/lldb/scripts/interface/SBLineEntry.i
index 90f60df2324..be365377ba8 100644
--- a/lldb/scripts/interface/SBLineEntry.i
+++ b/lldb/scripts/interface/SBLineEntry.i
@@ -84,6 +84,8 @@ public:
bool
operator != (const lldb::SBLineEntry &rhs) const;
+ STRING_EXTENSION(SBLineEntry)
+
#ifdef SWIGPYTHON
%pythoncode %{
file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this line entry.''')
diff --git a/lldb/scripts/interface/SBMemoryRegionInfo.i b/lldb/scripts/interface/SBMemoryRegionInfo.i
index 7a59d0051ce..6a2ad6a3e36 100644
--- a/lldb/scripts/interface/SBMemoryRegionInfo.i
+++ b/lldb/scripts/interface/SBMemoryRegionInfo.i
@@ -55,6 +55,7 @@ public:
bool
GetDescription (lldb::SBStream &description);
+ STRING_EXTENSION(SBMemoryRegionInfo)
};
} // namespace lldb
diff --git a/lldb/scripts/interface/SBModule.i b/lldb/scripts/interface/SBModule.i
index 03c8aeb2bed..a9d9480cd7c 100644
--- a/lldb/scripts/interface/SBModule.i
+++ b/lldb/scripts/interface/SBModule.i
@@ -344,6 +344,8 @@ public:
lldb::SBAddress
GetObjectFileEntryPointAddress() const;
+ STRING_EXTENSION(SBModule)
+
#ifdef SWIGPYTHON
%pythoncode %{
def __len__(self):
diff --git a/lldb/scripts/interface/SBModuleSpec.i b/lldb/scripts/interface/SBModuleSpec.i
index ec4e9bb7fbf..64d0aa641a7 100644
--- a/lldb/scripts/interface/SBModuleSpec.i
+++ b/lldb/scripts/interface/SBModuleSpec.i
@@ -91,6 +91,7 @@ public:
bool
GetDescription (lldb::SBStream &description);
+ STRING_EXTENSION(SBModuleSpec)
};
@@ -127,6 +128,7 @@ public:
bool
GetDescription (lldb::SBStream &description);
+ STRING_EXTENSION(SBModuleSpecList)
};
} // namespace lldb
diff --git a/lldb/scripts/interface/SBTarget.i b/lldb/scripts/interface/SBTarget.i
index 02c70b6e1cd..371bf5c35eb 100644
--- a/lldb/scripts/interface/SBTarget.i
+++ b/lldb/scripts/interface/SBTarget.i
@@ -967,21 +967,7 @@ public:
lldb::SBValue
EvaluateExpression (const char *expr, const lldb::SBExpressionOptions &options);
- %extend {
- %nothreadallow;
- std::string lldb::SBTarget::__str__(){
- lldb::SBStream stream;
- $self->GetDescription (stream, lldb::eDescriptionLevelBrief);
-
- const char *desc = stream.GetData();
- size_t desc_len = stream.GetSize();
- if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
- --desc_len;
-
- return std::string(desc, desc_len);
- }
- %clearnothreadallow;
- }
+ STRING_EXTENSION_LEVEL(SBTarget, lldb::eDescriptionLevelBrief)
#ifdef SWIGPYTHON
%pythoncode %{
diff --git a/lldb/scripts/lldb.swig b/lldb/scripts/lldb.swig
index c3b90833274..bebf9bf534a 100644
--- a/lldb/scripts/lldb.swig
+++ b/lldb/scripts/lldb.swig
@@ -59,6 +59,23 @@ except ImportError:
// Parameter types will be used in the autodoc string.
%feature("autodoc", "1");
+%define ARRAYHELPER(type,name)
+%inline %{
+type *new_ ## name (int nitems) {
+ return (type *) malloc(sizeof(type)*nitems);
+}
+void delete_ ## name(type *t) {
+ free(t);
+}
+type name ## _get(type *t, int index) {
+ return t[index];
+}
+void name ## _set(type *t, int index, type val) {
+ t[index] = val;
+}
+%}
+%enddef
+
%pythoncode%{
import uuid
import re
@@ -95,6 +112,7 @@ def lldb_iter(obj, getsize, getelem):
%include <std_string.i>
%include "./Python/python-typemaps.swig"
+%include "./macros.swig"
%include "./headers.swig"
%{
diff --git a/lldb/scripts/lldb_lua.swig b/lldb/scripts/lldb_lua.swig
index bf8809015d9..3b279a6b69e 100644
--- a/lldb/scripts/lldb_lua.swig
+++ b/lldb/scripts/lldb_lua.swig
@@ -9,6 +9,7 @@
%module lldb
%include <std_string.i>
+%include "./macros.swig"
%include "./headers.swig"
%{
diff --git a/lldb/scripts/macros.swig b/lldb/scripts/macros.swig
new file mode 100644
index 00000000000..e0756c2f179
--- /dev/null
+++ b/lldb/scripts/macros.swig
@@ -0,0 +1,33 @@
+%define STRING_EXTENSION_LEVEL(Class, Level)
+%extend {
+ %nothreadallow;
+ std::string lldb:: ## Class ## ::__str__(){
+ lldb::SBStream stream;
+ $self->GetDescription (stream, Level);
+ const char *desc = stream.GetData();
+ size_t desc_len = stream.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == 'n' || desc[desc_len-1] == 'r')) {
+ --desc_len;
+ }
+ return std::string(desc, desc_len);
+ }
+ %clearnothreadallow;
+}
+%enddef
+
+%define STRING_EXTENSION(Class)
+%extend {
+ %nothreadallow;
+ std::string lldb:: ## Class ## ::__str__(){
+ lldb::SBStream stream;
+ $self->GetDescription (stream);
+ const char *desc = stream.GetData();
+ size_t desc_len = stream.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == 'n' || desc[desc_len-1] == 'r')) {
+ --desc_len;
+ }
+ return std::string(desc, desc_len);
+ }
+ %clearnothreadallow;
+}
+%enddef
OpenPOWER on IntegriCloud