summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/API/SBAddress.h7
-rw-r--r--lldb/include/lldb/API/SBBlock.h7
-rw-r--r--lldb/include/lldb/API/SBBreakpoint.h7
-rw-r--r--lldb/include/lldb/API/SBBreakpointLocation.h7
-rw-r--r--lldb/include/lldb/API/SBCommandReturnObject.h7
-rw-r--r--lldb/include/lldb/API/SBCompileUnit.h7
-rw-r--r--lldb/include/lldb/API/SBDebugger.h7
-rw-r--r--lldb/include/lldb/API/SBDefines.h5
-rw-r--r--lldb/include/lldb/API/SBError.h7
-rw-r--r--lldb/include/lldb/API/SBEvent.h7
-rw-r--r--lldb/include/lldb/API/SBFileSpec.h7
-rw-r--r--lldb/include/lldb/API/SBFrame.h7
-rw-r--r--lldb/include/lldb/API/SBFunction.h7
-rw-r--r--lldb/include/lldb/API/SBInstruction.h7
-rw-r--r--lldb/include/lldb/API/SBLineEntry.h7
-rw-r--r--lldb/include/lldb/API/SBModule.h7
-rw-r--r--lldb/include/lldb/API/SBProcess.h7
-rw-r--r--lldb/include/lldb/API/SBSymbol.h7
-rw-r--r--lldb/include/lldb/API/SBSymbolContext.h16
-rw-r--r--lldb/include/lldb/API/SBTarget.h7
-rw-r--r--lldb/include/lldb/API/SBThread.h7
-rw-r--r--lldb/include/lldb/API/SBType.h7
-rw-r--r--lldb/include/lldb/API/SBValue.h7
-rw-r--r--lldb/lldb.xcodeproj/project.pbxproj3
-rw-r--r--lldb/scripts/Python/python-extensions.swig135
-rw-r--r--lldb/scripts/lldb.swig2
-rw-r--r--lldb/source/API/SBAddress.cpp10
-rw-r--r--lldb/source/API/SBBlock.cpp9
-rw-r--r--lldb/source/API/SBBreakpoint.cpp11
-rw-r--r--lldb/source/API/SBBreakpointLocation.cpp10
-rw-r--r--lldb/source/API/SBCommandReturnObject.cpp8
-rw-r--r--lldb/source/API/SBCompileUnit.cpp10
-rw-r--r--lldb/source/API/SBDebugger.cpp9
-rw-r--r--lldb/source/API/SBError.cpp8
-rw-r--r--lldb/source/API/SBEvent.cpp10
-rw-r--r--lldb/source/API/SBFileSpec.cpp8
-rw-r--r--lldb/source/API/SBFrame.cpp10
-rw-r--r--lldb/source/API/SBFunction.cpp10
-rw-r--r--lldb/source/API/SBLineEntry.cpp8
-rw-r--r--lldb/source/API/SBModule.cpp10
-rw-r--r--lldb/source/API/SBProcess.cpp8
-rw-r--r--lldb/source/API/SBSymbol.cpp13
-rw-r--r--lldb/source/API/SBSymbolContext.cpp25
-rw-r--r--lldb/source/API/SBTarget.cpp10
-rw-r--r--lldb/source/API/SBThread.cpp8
-rw-r--r--lldb/source/API/SBType.cpp8
-rw-r--r--lldb/source/API/SBValue.cpp8
47 files changed, 171 insertions, 348 deletions
diff --git a/lldb/include/lldb/API/SBAddress.h b/lldb/include/lldb/API/SBAddress.h
index d9d4ace706b..ffafdf179bb 100644
--- a/lldb/include/lldb/API/SBAddress.h
+++ b/lldb/include/lldb/API/SBAddress.h
@@ -47,13 +47,6 @@ public:
bool
GetDescription (lldb::SBStream &description);
- // The following function gets called by Python when a user tries to print
- // an object of this class. It takes no arguments and returns a
- // PyObject * representing a char * (and it must be named "__repr__");
-
- PyObject *
- __repr__ ();
-
protected:
friend class SBFrame;
diff --git a/lldb/include/lldb/API/SBBlock.h b/lldb/include/lldb/API/SBBlock.h
index c49c9a17a95..4e84aaee900 100644
--- a/lldb/include/lldb/API/SBBlock.h
+++ b/lldb/include/lldb/API/SBBlock.h
@@ -52,13 +52,6 @@ public:
bool
GetDescription (lldb::SBStream &description);
- // The following function gets called by Python when a user tries to print
- // an object of this class. It takes no arguments and returns a
- // PyObject *, which contains a char * (and it must be named "__repr__");
-
- PyObject *
- __repr__ ();
-
private:
friend class SBFrame;
friend class SBSymbolContext;
diff --git a/lldb/include/lldb/API/SBBreakpoint.h b/lldb/include/lldb/API/SBBreakpoint.h
index b24515b6adc..2c0c256c847 100644
--- a/lldb/include/lldb/API/SBBreakpoint.h
+++ b/lldb/include/lldb/API/SBBreakpoint.h
@@ -116,13 +116,6 @@ public:
static lldb::SBBreakpointLocation
GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx);
- // The following function gets called by Python when a user tries to print
- // an object of this class. It takes no arguments and returns a
- // PyObject * representing a char * (and it must be named "__repr__");
-
- PyObject *
- __repr__ ();
-
private:
friend class SBBreakpointLocation;
friend class SBTarget;
diff --git a/lldb/include/lldb/API/SBBreakpointLocation.h b/lldb/include/lldb/API/SBBreakpointLocation.h
index 32e83f245bd..529cd0570b6 100644
--- a/lldb/include/lldb/API/SBBreakpointLocation.h
+++ b/lldb/include/lldb/API/SBBreakpointLocation.h
@@ -74,13 +74,6 @@ public:
SBBreakpoint
GetBreakpoint ();
- // The following function gets called by Python when a user tries to print
- // an object of this class. It takes no arguments and returns a
- // PyObject * representing a char * (and it must be named "__repr__");
-
- PyObject *
- __repr__ ();
-
private:
friend class SBBreakpoint;
diff --git a/lldb/include/lldb/API/SBCommandReturnObject.h b/lldb/include/lldb/API/SBCommandReturnObject.h
index 5d52dc1c211..1533816367d 100644
--- a/lldb/include/lldb/API/SBCommandReturnObject.h
+++ b/lldb/include/lldb/API/SBCommandReturnObject.h
@@ -61,13 +61,6 @@ public:
bool
GetDescription (lldb::SBStream &description);
- // The following function gets called by Python when a user tries to print
- // an object of this class. It takes no arguments and returns a
- // PyObject * representing a char * (and it must be named "__repr__");
-
- PyObject *
- __repr__ ();
-
protected:
friend class SBCommandInterpreter;
friend class SBOptions;
diff --git a/lldb/include/lldb/API/SBCompileUnit.h b/lldb/include/lldb/API/SBCompileUnit.h
index 5c7d6a45f28..e0bebd079c3 100644
--- a/lldb/include/lldb/API/SBCompileUnit.h
+++ b/lldb/include/lldb/API/SBCompileUnit.h
@@ -53,13 +53,6 @@ public:
bool
GetDescription (lldb::SBStream &description);
- // The following function gets called by Python when a user tries to print
- // an object of this class. It takes no arguments and returns a
- // PyObject representing a char * (and it must be named "__repr__");
-
- PyObject *
- __repr__ ();
-
private:
friend class SBFrame;
friend class SBSymbolContext;
diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h
index bef4cad1439..d05bb9fc572 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -157,13 +157,6 @@ public:
bool
GetDescription (lldb::SBStream &description);
- // The following function gets called by Python when a user tries to print
- // an object of this class. It takes no arguments and returns a
- // PyObject * representing a char * (and it must be named "__repr__");
-
- PyObject *
- __repr__ ();
-
uint32_t
GetTerminalWidth () const;
diff --git a/lldb/include/lldb/API/SBDefines.h b/lldb/include/lldb/API/SBDefines.h
index 3a2ad79b704..fb59cc64542 100644
--- a/lldb/include/lldb/API/SBDefines.h
+++ b/lldb/include/lldb/API/SBDefines.h
@@ -10,11 +10,6 @@
#ifndef LLDB_SBDefines_h_
#define LLDB_SBDefines_h_
-// In order to guarantee correct working with Python, Python.h *MUST* be
-// the *FIRST* header file included:
-
-#include <Python.h>
-
// C Includes
// C++ Includes
// Other libraries and framework includes
diff --git a/lldb/include/lldb/API/SBError.h b/lldb/include/lldb/API/SBError.h
index 3fedd13ff87..cbea6910ffa 100644
--- a/lldb/include/lldb/API/SBError.h
+++ b/lldb/include/lldb/API/SBError.h
@@ -68,13 +68,6 @@ public:
bool
GetDescription (lldb::SBStream &description);
- // The following function gets called by Python when a user tries to print
- // an object of this class. It takes no arguments and returns a
- // PyObject * representing a char * (and it must be named "__repr__");
-
- PyObject *
- __repr__ ();
-
protected:
friend class SBArguments;
friend class SBDebugger;
diff --git a/lldb/include/lldb/API/SBEvent.h b/lldb/include/lldb/API/SBEvent.h
index 9f6a425058c..cab413a9ab3 100644
--- a/lldb/include/lldb/API/SBEvent.h
+++ b/lldb/include/lldb/API/SBEvent.h
@@ -57,13 +57,6 @@ public:
bool
GetDescription (lldb::SBStream &description);
- // The following function gets called by Python when a user tries to print
- // an object of this class. It takes no arguments and returns a
- // PyObject * representing a char * (and it must be named "__repr__");
-
- PyObject *
- __repr__ ();
-
protected:
friend class SBListener;
friend class SBBroadcaster;
diff --git a/lldb/include/lldb/API/SBFileSpec.h b/lldb/include/lldb/API/SBFileSpec.h
index fa8564df2b2..db76655795a 100644
--- a/lldb/include/lldb/API/SBFileSpec.h
+++ b/lldb/include/lldb/API/SBFileSpec.h
@@ -54,13 +54,6 @@ public:
bool
GetDescription (lldb::SBStream &description);
- // The following function gets called by Python when a user tries to print
- // an object of this class. It takes no arguments and returns a
- // PyObject * representing a char * (and it must be named "__repr__");
-
- PyObject *
- __repr__ ();
-
private:
friend class SBBlock;
friend class SBCompileUnit;
diff --git a/lldb/include/lldb/API/SBFrame.h b/lldb/include/lldb/API/SBFrame.h
index ae12452e6f3..67c4b60c20e 100644
--- a/lldb/include/lldb/API/SBFrame.h
+++ b/lldb/include/lldb/API/SBFrame.h
@@ -115,13 +115,6 @@ public:
bool
GetDescription (lldb::SBStream &description);
- // The following function gets called by Python when a user tries to print
- // an object of this class. It takes no arguments and returns a
- // PyObject * representing a char * (and it must be named "__repr__");
-
- PyObject *
- __repr__ ();
-
protected:
friend class SBValue;
diff --git a/lldb/include/lldb/API/SBFunction.h b/lldb/include/lldb/API/SBFunction.h
index 4e7ae8081a4..643d5273471 100644
--- a/lldb/include/lldb/API/SBFunction.h
+++ b/lldb/include/lldb/API/SBFunction.h
@@ -42,13 +42,6 @@ public:
bool
GetDescription (lldb::SBStream &description);
- // The following function gets called by Python when a user tries to print
- // an object of this class. It takes no arguments and returns a
- // PyObject * representing a char * (and it must be named "__repr__");
-
- PyObject *
- __repr__ ();
-
private:
friend class SBFrame;
friend class SBSymbolContext;
diff --git a/lldb/include/lldb/API/SBInstruction.h b/lldb/include/lldb/API/SBInstruction.h
index 0461ce34e42..d64a4d3da0d 100644
--- a/lldb/include/lldb/API/SBInstruction.h
+++ b/lldb/include/lldb/API/SBInstruction.h
@@ -49,13 +49,6 @@ public:
//bool
//GetDescription (lldb::SBStream &description);
- // The following function gets called by Python when a user tries to print
- // an object of this class. It takes no arguments and returns a
- // PyObject * representing a char * (and it must be named "__repr__");
-
- //PyObject *
- //__repr__ ();
-
private:
//lldb_private::Disassembler::Instruction::SharedPtr m_opaque_sp;
diff --git a/lldb/include/lldb/API/SBLineEntry.h b/lldb/include/lldb/API/SBLineEntry.h
index 619884ed310..851e63f7ea7 100644
--- a/lldb/include/lldb/API/SBLineEntry.h
+++ b/lldb/include/lldb/API/SBLineEntry.h
@@ -61,13 +61,6 @@ public:
bool
GetDescription (lldb::SBStream &description);
- // The following function gets called by Python when a user tries to print
- // an object of this class. It takes no arguments and returns a
- // PyObject * representing a char * (and it must be named "__repr__");
-
- PyObject *
- __repr__ ();
-
private:
friend class SBCompileUnit;
friend class SBFrame;
diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h
index 6231d13a319..835386d3129 100644
--- a/lldb/include/lldb/API/SBModule.h
+++ b/lldb/include/lldb/API/SBModule.h
@@ -52,13 +52,6 @@ public:
bool
GetDescription (lldb::SBStream &description);
- // The following function gets called by Python when a user tries to print
- // an object of this class. It takes no arguments and returns a
- // PyObject * representing a char * (and it must be named "__repr__");
-
- PyObject *
- __repr__ ();
-
private:
friend class SBSymbolContext;
friend class SBTarget;
diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h
index 3543ee1e9e8..0e462ce3e92 100644
--- a/lldb/include/lldb/API/SBProcess.h
+++ b/lldb/include/lldb/API/SBProcess.h
@@ -155,13 +155,6 @@ public:
bool
GetDescription (lldb::SBStream &description);
- // The following function gets called by Python when a user tries to print
- // an object of this class. It take no arguments and returns a
- // PyObject * representing a char * (and it must be named "__repr__");
-
- PyObject *
- __repr__ ();
-
protected:
friend class SBAddress;
friend class SBBreakpoint;
diff --git a/lldb/include/lldb/API/SBSymbol.h b/lldb/include/lldb/API/SBSymbol.h
index a51cb424c62..9c056251421 100644
--- a/lldb/include/lldb/API/SBSymbol.h
+++ b/lldb/include/lldb/API/SBSymbol.h
@@ -43,13 +43,6 @@ public:
bool
GetDescription (lldb::SBStream &description);
- // The following function gets called by Python when a user tries to print
- // an object of this class. It takes no arguments and returns a
- // PyObject * representing a char * (and it must be named "__repr__");
-
- PyObject *
- __repr__ ();
-
private:
friend class SBSymbolContext;
diff --git a/lldb/include/lldb/API/SBSymbolContext.h b/lldb/include/lldb/API/SBSymbolContext.h
index 659683f9148..6744fa8ddab 100644
--- a/lldb/include/lldb/API/SBSymbolContext.h
+++ b/lldb/include/lldb/API/SBSymbolContext.h
@@ -44,6 +44,9 @@ public:
SBLineEntry GetLineEntry ();
SBSymbol GetSymbol ();
+ bool
+ GetDescription (lldb::SBStream &description);
+
protected:
friend class SBFrame;
friend class SBModule;
@@ -58,6 +61,9 @@ protected:
lldb_private::SymbolContext&
operator*();
+ lldb_private::SymbolContext&
+ ref();
+
const lldb_private::SymbolContext&
operator*() const;
@@ -71,16 +77,6 @@ protected:
void
SetSymbolContext (const lldb_private::SymbolContext *sc_ptr);
- bool
- GetDescription (lldb::SBStream &description);
-
- // The following function gets called by Python when a user tries to print
- // an object of this class. It takes no arguments and returns a
- // PyObject * representing a char * (and it must be named "__repr__");
-
- PyObject *
- __repr__ ();
-
private:
std::auto_ptr<lldb_private::SymbolContext> m_opaque_ap;
};
diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 1b4c09ab38c..1f9d0ce1b25 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -145,13 +145,6 @@ public:
bool
GetDescription (lldb::SBStream &description);
- // The following function gets called by Python when a user tries to print
- // an object of this class. It takes no arguments and returns a
- // PyObject * representing a char * (and it must be named "__repr__");
-
- PyObject *
- __repr__ ();
-
protected:
friend class SBAddress;
friend class SBDebugger;
diff --git a/lldb/include/lldb/API/SBThread.h b/lldb/include/lldb/API/SBThread.h
index ead395ae529..bf2cc4f2e97 100644
--- a/lldb/include/lldb/API/SBThread.h
+++ b/lldb/include/lldb/API/SBThread.h
@@ -91,13 +91,6 @@ public:
bool
GetDescription (lldb::SBStream &description);
- // The following function gets called by Python when a user tries to print
- // an object of this class. It takes no arguments and returns a
- // PyObject * representing a char * (and it must be named "__repr__");
-
- PyObject *
- __repr__ ();
-
protected:
friend class SBBreakpoint;
friend class SBBreakpointLocation;
diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index c745989364b..b89aca92e51 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -57,13 +57,6 @@ public:
bool
GetDescription (lldb::SBStream &description);
- // The following function gets called by Python when a user tries to print
- // an object of this class. It takes no arguments and returns a
- // PyObject * representing a char * (and it must be named "__repr__");
-
- PyObject *
- __repr__ ();
-
protected:
void *m_ast;
void *m_type;
diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h
index 78b4ea9bbf0..c247339ef5b 100644
--- a/lldb/include/lldb/API/SBValue.h
+++ b/lldb/include/lldb/API/SBValue.h
@@ -88,13 +88,6 @@ public:
bool
GetDescription (lldb::SBStream &description);
- // The following function gets called by Python when a user tries to print
- // an object of this class. It take no arguments and returns a
- // PyObject * representing a char * (and it must be named "__repr__");
-
- PyObject *
- __repr__ ();
-
protected:
friend class SBValueList;
friend class SBFrame;
diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj
index 752dc86fc99..ddeb11274af 100644
--- a/lldb/lldb.xcodeproj/project.pbxproj
+++ b/lldb/lldb.xcodeproj/project.pbxproj
@@ -1046,6 +1046,7 @@
9A42976211861AA600FE05CD /* CommandObjectBreakpointCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectBreakpointCommand.cpp; path = source/Commands/CommandObjectBreakpointCommand.cpp; sourceTree = "<group>"; };
9A4633DA11F65D8600955CE1 /* UserSettingsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UserSettingsController.h; path = include/lldb/Core/UserSettingsController.h; sourceTree = "<group>"; };
9A4633DC11F65D9A00955CE1 /* UserSettingsController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UserSettingsController.cpp; path = source/Core/UserSettingsController.cpp; sourceTree = "<group>"; };
+ 9A48A3A7124AAA5A00922451 /* python-extensions.swig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "python-extensions.swig"; sourceTree = "<group>"; };
9A633FE7112DCE3C001A7E43 /* SBFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBFrame.cpp; path = source/API/SBFrame.cpp; sourceTree = "<group>"; };
9A633FE8112DCE3C001A7E43 /* SBFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBFrame.h; path = include/lldb/API/SBFrame.h; sourceTree = "<group>"; };
9A82010B10FFB49800182560 /* ScriptInterpreter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ScriptInterpreter.cpp; path = source/Interpreter/ScriptInterpreter.cpp; sourceTree = "<group>"; };
@@ -1553,6 +1554,7 @@
266960601199F4230075C61A /* build-swig-Python.sh */,
266960611199F4230075C61A /* edit-swig-python-wrapper-file.py */,
266960621199F4230075C61A /* finish-swig-Python-lldb.sh */,
+ 9A48A3A7124AAA5A00922451 /* python-extensions.swig */,
);
path = Python;
sourceTree = "<group>";
@@ -2349,7 +2351,6 @@
isa = PBXProject;
buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */;
compatibilityVersion = "Xcode 3.1";
- developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
en,
diff --git a/lldb/scripts/Python/python-extensions.swig b/lldb/scripts/Python/python-extensions.swig
new file mode 100644
index 00000000000..7d706fd0d63
--- /dev/null
+++ b/lldb/scripts/Python/python-extensions.swig
@@ -0,0 +1,135 @@
+
+%extend lldb::SBAddress {
+ PyObject *lldb::SBAddress::__repr__ (){
+ lldb::SBStream description;
+ $self->GetDescription (description);
+ return PyString_FromString (description.GetData());
+ }
+}
+%extend lldb::SBBlock {
+ PyObject *lldb::SBBlock::__repr__ (){
+ lldb::SBStream description;
+ $self->GetDescription (description);
+ return PyString_FromString (description.GetData());
+ }
+}
+%extend lldb::SBBreakpoint {
+ PyObject *lldb::SBBreakpoint::__repr__ (){
+ lldb::SBStream description;
+ $self->GetDescription ("full", description);
+ return PyString_FromString (description.GetData());
+ }
+}
+%extend lldb::SBBreakpointLocation {
+ PyObject *lldb::SBBreakpointLocation::__repr__ (){
+ lldb::SBStream description;
+ $self->GetDescription ("full", description);
+ return PyString_FromString (description.GetData());
+ }
+}
+%extend lldb::SBCommandReturnObject {
+ PyObject *lldb::SBCommandReturnObject::__repr__ (){
+ lldb::SBStream description;
+ $self->GetDescription (description);
+ return PyString_FromString (description.GetData());
+ }
+}
+%extend lldb::SBCompileUnit {
+ PyObject *lldb::SBCompileUnit::__repr__ (){
+ lldb::SBStream description;
+ $self->GetDescription (description);
+ return PyString_FromString (description.GetData());
+ }
+}
+%extend lldb::SBDebugger {
+ PyObject *lldb::SBDebugger::__repr__ (){
+ lldb::SBStream description;
+ $self->GetDescription (description);
+ return PyString_FromString (description.GetData());
+ }
+}
+%extend lldb::SBError {
+ PyObject *lldb::SBError::__repr__ (){
+ lldb::SBStream description;
+ $self->GetDescription (description);
+ return PyString_FromString (description.GetData());
+ }
+}
+%extend lldb::SBFileSpec {
+ PyObject *lldb::SBFileSpec::__repr__ (){
+ lldb::SBStream description;
+ $self->GetDescription (description);
+ return PyString_FromString (description.GetData());
+ }
+}
+%extend lldb::SBFrame {
+ PyObject *lldb::SBFrame::__repr__ (){
+ lldb::SBStream description;
+ $self->GetDescription (description);
+ return PyString_FromString (description.GetData());
+ }
+}
+%extend lldb::SBFunction {
+ PyObject *lldb::SBFunction::__repr__ (){
+ lldb::SBStream description;
+ $self->GetDescription (description);
+ return PyString_FromString (description.GetData());
+ }
+}
+%extend lldb::SBLineEntry {
+ PyObject *lldb::SBLineEntry::__repr__ (){
+ lldb::SBStream description;
+ $self->GetDescription (description);
+ return PyString_FromString (description.GetData());
+ }
+}
+%extend lldb::SBModule {
+ PyObject *lldb::SBModule::__repr__ (){
+ lldb::SBStream description;
+ $self->GetDescription (description);
+ return PyString_FromString (description.GetData());
+ }
+}
+%extend lldb::SBProcess {
+ PyObject *lldb::SBProcess::__repr__ (){
+ lldb::SBStream description;
+ $self->GetDescription (description);
+ return PyString_FromString (description.GetData());
+ }
+}
+%extend lldb::SBSymbol {
+ PyObject *lldb::SBSymbol::__repr__ (){
+ lldb::SBStream description;
+ $self->GetDescription (description);
+ return PyString_FromString (description.GetData());
+ }
+}
+%extend lldb::SBSymbolContext {
+ PyObject *lldb::SBSymbolContext::__repr__ (){
+ lldb::SBStream description;
+ $self->GetDescription (description);
+ return PyString_FromString (description.GetData());
+ }
+}
+%extend lldb::SBTarget {
+ PyObject *lldb::SBTarget::__repr__ (){
+ lldb::SBStream description;
+ $self->GetDescription (description);
+ return PyString_FromString (description.GetData());
+ }
+}
+%extend lldb::SBThread {
+ PyObject *lldb::SBThread::__repr__ (){
+ lldb::SBStream description;
+ $self->GetDescription (description);
+ return PyString_FromString (description.GetData());
+ }
+}
+%extend lldb::SBValue {
+ PyObject *lldb::SBValue::__repr__ (){
+ lldb::SBStream description;
+ $self->GetDescription (description);
+ return PyString_FromString (description.GetData());
+ }
+}
+
diff --git a/lldb/scripts/lldb.swig b/lldb/scripts/lldb.swig
index 6c505d2426f..d4c0220d559 100644
--- a/lldb/scripts/lldb.swig
+++ b/lldb/scripts/lldb.swig
@@ -156,4 +156,4 @@ typedef int StopReason;
%include "lldb/API/SBValueList.h"
%include "lldb/lldb-types.h"
-
+%include "./Python/python-extensions.swig"
diff --git a/lldb/source/API/SBAddress.cpp b/lldb/source/API/SBAddress.cpp
index 0afe914e6df..7f21cf79fca 100644
--- a/lldb/source/API/SBAddress.cpp
+++ b/lldb/source/API/SBAddress.cpp
@@ -140,6 +140,7 @@ SBAddress::operator*() const
bool
SBAddress::GetDescription (SBStream &description)
{
+ description.ref();
if (m_opaque_ap.get())
{
m_opaque_ap->DumpDebug (description.get());
@@ -149,12 +150,3 @@ SBAddress::GetDescription (SBStream &description)
return true;
}
-
-PyObject *
-SBAddress::__repr__ ()
-{
- SBStream description;
- description.ref(); // Make sure it contains a valid StreamString.
- GetDescription (description);
- return PyString_FromString (description.GetData());
-}
diff --git a/lldb/source/API/SBBlock.cpp b/lldb/source/API/SBBlock.cpp
index 02db9b2237a..b57936d9fe0 100644
--- a/lldb/source/API/SBBlock.cpp
+++ b/lldb/source/API/SBBlock.cpp
@@ -158,12 +158,3 @@ SBBlock::GetDescription (SBStream &description)
return true;
}
-
-PyObject *
-SBBlock::__repr__ ()
-{
- SBStream description;
- description.ref();
- GetDescription (description);
- return PyString_FromString (description.GetData());
-}
diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp
index aa84575be2e..70a70458b36 100644
--- a/lldb/source/API/SBBreakpoint.cpp
+++ b/lldb/source/API/SBBreakpoint.cpp
@@ -337,7 +337,7 @@ SBBreakpoint::GetDescription (const char *description_level, SBStream &descripti
else
level = eDescriptionLevelBrief;
-
+ description.ref();
m_opaque_sp->GetDescription (description.get(), level);
description.get()->EOL();
}
@@ -347,15 +347,6 @@ SBBreakpoint::GetDescription (const char *description_level, SBStream &descripti
return true;
}
-PyObject *
-SBBreakpoint::__repr__ ()
-{
- SBStream description;
- description.ref();
- GetDescription ("full", description);
- return PyString_FromString (description.GetData());
-}
-
bool
SBBreakpoint::PrivateBreakpointHitCallback
(
diff --git a/lldb/source/API/SBBreakpointLocation.cpp b/lldb/source/API/SBBreakpointLocation.cpp
index f7e059ba967..07300eabac4 100644
--- a/lldb/source/API/SBBreakpointLocation.cpp
+++ b/lldb/source/API/SBBreakpointLocation.cpp
@@ -212,6 +212,7 @@ SBBreakpointLocation::GetDescription (const char *description_level, SBStream &d
else
level = eDescriptionLevelBrief;
+ description.ref();
m_opaque_sp->GetDescription (description.get(), level);
description.get()->EOL();
}
@@ -221,15 +222,6 @@ SBBreakpointLocation::GetDescription (const char *description_level, SBStream &d
return true;
}
-PyObject *
-SBBreakpointLocation::__repr__ ()
-{
- SBStream description;
- description.ref();
- GetDescription ("full", description);
- return PyString_FromString (description.GetData());
-}
-
SBBreakpoint
SBBreakpointLocation::GetBreakpoint ()
{
diff --git a/lldb/source/API/SBCommandReturnObject.cpp b/lldb/source/API/SBCommandReturnObject.cpp
index 458ce504e3d..35195f6da23 100644
--- a/lldb/source/API/SBCommandReturnObject.cpp
+++ b/lldb/source/API/SBCommandReturnObject.cpp
@@ -188,11 +188,3 @@ SBCommandReturnObject::GetDescription (SBStream &description)
return true;
}
-
-PyObject *
-SBCommandReturnObject::__repr__ ()
-{
- SBStream description;
- GetDescription (description);
- return PyString_FromString (description.GetData());
-}
diff --git a/lldb/source/API/SBCompileUnit.cpp b/lldb/source/API/SBCompileUnit.cpp
index 9e68e28c01d..42bbf82a7e5 100644
--- a/lldb/source/API/SBCompileUnit.cpp
+++ b/lldb/source/API/SBCompileUnit.cpp
@@ -125,6 +125,7 @@ SBCompileUnit::GetDescription (SBStream &description)
{
if (m_opaque_ptr)
{
+ description.ref();
m_opaque_ptr->Dump (description.get(), false);
}
else
@@ -132,12 +133,3 @@ SBCompileUnit::GetDescription (SBStream &description)
return true;
}
-
-PyObject *
-SBCompileUnit::__repr__ ()
-{
- SBStream description;
- description.ref();
- GetDescription (description);
- return PyString_FromString (description.GetData());
-}
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 0a48e69cb79..81658d5ab59 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -695,12 +695,3 @@ SBDebugger::GetDescription (SBStream &description)
return true;
}
-
-
-PyObject *
-SBDebugger::__repr__ ()
-{
- SBStream description;
- GetDescription (description);
- return PyString_FromString (description.GetData());
-}
diff --git a/lldb/source/API/SBError.cpp b/lldb/source/API/SBError.cpp
index 136561981b6..9553b6f4166 100644
--- a/lldb/source/API/SBError.cpp
+++ b/lldb/source/API/SBError.cpp
@@ -198,11 +198,3 @@ SBError::GetDescription (SBStream &description)
return true;
}
-
-PyObject *
-SBError::__repr__ ()
-{
- SBStream description;
- GetDescription (description);
- return PyString_FromString (description.GetData());
-}
diff --git a/lldb/source/API/SBEvent.cpp b/lldb/source/API/SBEvent.cpp
index d77f0020835..d1123e7f858 100644
--- a/lldb/source/API/SBEvent.cpp
+++ b/lldb/source/API/SBEvent.cpp
@@ -156,6 +156,7 @@ SBEvent::GetDescription (SBStream &description)
{
if (m_opaque)
{
+ description.ref();
m_opaque->Dump (description.get());
}
else
@@ -163,12 +164,3 @@ SBEvent::GetDescription (SBStream &description)
return true;
}
-
-PyObject *
-SBEvent::__repr__ ()
-{
- SBStream description;
- description.ref();
- GetDescription (description);
- return PyString_FromString (description.GetData());
-}
diff --git a/lldb/source/API/SBFileSpec.cpp b/lldb/source/API/SBFileSpec.cpp
index 1edd9468b50..36fcf1bbf2e 100644
--- a/lldb/source/API/SBFileSpec.cpp
+++ b/lldb/source/API/SBFileSpec.cpp
@@ -158,11 +158,3 @@ SBFileSpec::GetDescription (SBStream &description)
return true;
}
-
-PyObject *
-SBFileSpec::__repr__ ()
-{
- SBStream description;
- GetDescription (description);
- return PyString_FromString (description.GetData());
-}
diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp
index 90952691df0..9e0f35d0a1d 100644
--- a/lldb/source/API/SBFrame.cpp
+++ b/lldb/source/API/SBFrame.cpp
@@ -394,6 +394,7 @@ SBFrame::GetDescription (SBStream &description)
{
if (m_opaque_sp)
{
+ description.ref();
m_opaque_sp->Dump (description.get(), true, false);
}
else
@@ -401,12 +402,3 @@ SBFrame::GetDescription (SBStream &description)
return true;
}
-
-PyObject *
-SBFrame::__repr__ ()
-{
- SBStream description;
- description.ref();
- GetDescription (description);
- return PyString_FromString (description.GetData());
-}
diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp
index 4c5f64e23ca..38e349bd3f9 100644
--- a/lldb/source/API/SBFunction.cpp
+++ b/lldb/source/API/SBFunction.cpp
@@ -69,6 +69,7 @@ SBFunction::GetDescription (SBStream &description)
{
if (m_opaque_ptr)
{
+ description.ref();
m_opaque_ptr->Dump (description.get(), false);
}
else
@@ -76,12 +77,3 @@ SBFunction::GetDescription (SBStream &description)
return true;
}
-
-PyObject *
-SBFunction::__repr__ ()
-{
- SBStream description;
- description.ref();
- GetDescription (description);
- return PyString_FromString (description.GetData());
-}
diff --git a/lldb/source/API/SBLineEntry.cpp b/lldb/source/API/SBLineEntry.cpp
index 27f01d5a2da..023afb94aad 100644
--- a/lldb/source/API/SBLineEntry.cpp
+++ b/lldb/source/API/SBLineEntry.cpp
@@ -172,11 +172,3 @@ SBLineEntry::GetDescription (SBStream &description)
return true;
}
-
-PyObject *
-SBLineEntry::__repr__ ()
-{
- SBStream description;
- GetDescription (description);
- return PyString_FromString (description.GetData());
-}
diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index a0b340a9cb7..b59a6002925 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -133,6 +133,7 @@ SBModule::GetDescription (SBStream &description)
{
if (m_opaque_sp)
{
+ description.ref();
m_opaque_sp->Dump (description.get());
}
else
@@ -140,12 +141,3 @@ SBModule::GetDescription (SBStream &description)
return true;
}
-
-PyObject *
-SBModule::__repr__ ()
-{
- SBStream description;
- description.ref();
- GetDescription (description);
- return PyString_FromString (description.GetData());
-}
diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp
index d2c85ba9031..2d6e6b03a92 100644
--- a/lldb/source/API/SBProcess.cpp
+++ b/lldb/source/API/SBProcess.cpp
@@ -485,11 +485,3 @@ SBProcess::GetDescription (SBStream &description)
return true;
}
-
-PyObject *
-SBProcess::__repr__ ()
-{
- SBStream description;
- GetDescription (description);
- return PyString_FromString (description.GetData());
-}
diff --git a/lldb/source/API/SBSymbol.cpp b/lldb/source/API/SBSymbol.cpp
index 3c700e17035..017df4394ca 100644
--- a/lldb/source/API/SBSymbol.cpp
+++ b/lldb/source/API/SBSymbol.cpp
@@ -69,19 +69,12 @@ SBSymbol::GetDescription (SBStream &description)
{
if (m_opaque_ptr)
{
- m_opaque_ptr->GetDescription (description.get(), lldb::eDescriptionLevelFull, NULL);
+ description.ref();
+ m_opaque_ptr->GetDescription (description.get(),
+ lldb::eDescriptionLevelFull, NULL);
}
else
description.Printf ("No value");
return true;
}
-
-PyObject *
-SBSymbol::__repr__ ()
-{
- SBStream description;
- description.ref();
- GetDescription (description);
- return PyString_FromString (description.GetData());
-}
diff --git a/lldb/source/API/SBSymbolContext.cpp b/lldb/source/API/SBSymbolContext.cpp
index 4381994c70f..ecd7d6677ff 100644
--- a/lldb/source/API/SBSymbolContext.cpp
+++ b/lldb/source/API/SBSymbolContext.cpp
@@ -32,7 +32,12 @@ SBSymbolContext::SBSymbolContext (const SBSymbolContext& rhs) :
m_opaque_ap ()
{
if (rhs.IsValid())
- *m_opaque_ap = *rhs.m_opaque_ap;
+ {
+ if (m_opaque_ap.get())
+ *m_opaque_ap = *rhs.m_opaque_ap;
+ else
+ ref() = *rhs.m_opaque_ap;
+ }
}
SBSymbolContext::~SBSymbolContext ()
@@ -141,6 +146,14 @@ SBSymbolContext::operator*()
return *m_opaque_ap.get();
}
+lldb_private::SymbolContext&
+SBSymbolContext::ref()
+{
+ if (m_opaque_ap.get() == NULL)
+ m_opaque_ap.reset (new SymbolContext);
+ return *m_opaque_ap.get();
+}
+
lldb_private::SymbolContext *
SBSymbolContext::get() const
{
@@ -152,6 +165,7 @@ SBSymbolContext::GetDescription (SBStream &description)
{
if (m_opaque_ap.get())
{
+ description.ref();
m_opaque_ap->GetDescription (description.get(), lldb::eDescriptionLevelFull, NULL);
}
else
@@ -159,12 +173,3 @@ SBSymbolContext::GetDescription (SBStream &description)
return true;
}
-
-PyObject *
-SBSymbolContext::__repr__ ()
-{
- SBStream description;
- description.ref();
- GetDescription (description);
- return PyString_FromString (description.GetData());
-}
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index cc544db9088..f34b0142cb2 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -507,6 +507,7 @@ SBTarget::GetDescription (SBStream &description)
{
if (m_opaque_sp)
{
+ description.ref();
m_opaque_sp->Dump (description.get());
}
else
@@ -514,12 +515,3 @@ SBTarget::GetDescription (SBStream &description)
return true;
}
-
-PyObject *
-SBTarget::__repr__ ()
-{
- SBStream description;
- description.ref();
- GetDescription (description);
- return PyString_FromString (description.GetData());
-}
diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp
index aa621fb13c0..8c74a34cdbe 100644
--- a/lldb/source/API/SBThread.cpp
+++ b/lldb/source/API/SBThread.cpp
@@ -428,11 +428,3 @@ SBThread::GetDescription (SBStream &description)
return true;
}
-
-PyObject *
-SBThread::__repr__ ()
-{
- SBStream description;
- GetDescription (description);
- return PyString_FromString (description.GetData());
-}
diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index d34e94a1460..5c3e97381ad 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -185,14 +185,6 @@ SBType::GetDescription (SBStream &description)
return true;
}
-PyObject *
-SBType::__repr__ ()
-{
- SBStream description;
- GetDescription (description);
- return PyString_FromString (description.GetData());
-}
-
SBTypeMember::SBTypeMember () :
m_ast (NULL),
m_parent_type (NULL),
diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp
index e2fdffab592..4b437f4e1b5 100644
--- a/lldb/source/API/SBValue.cpp
+++ b/lldb/source/API/SBValue.cpp
@@ -293,11 +293,3 @@ SBValue::GetDescription (SBStream &description)
return true;
}
-
-PyObject *
-SBValue::__repr__ ()
-{
- SBStream description;
- GetDescription (description);
- return PyString_FromString (description.GetData());
-}
OpenPOWER on IntegriCloud