Index: lldb/scripts/Python/python-extensions.swig =================================================================== --- lldb/scripts/Python/python-extensions.swig +++ lldb/scripts/Python/python-extensions.swig @@ -502,18 +502,6 @@ } %extend lldb::SBTarget { - %nothreadallow; - PyObject *lldb::SBTarget::__str__ (){ - lldb::SBStream description; - $self->GetDescription (description, lldb::eDescriptionLevelBrief); - 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)): Index: lldb/scripts/extensions.swig =================================================================== --- /dev/null +++ lldb/scripts/extensions.swig @@ -0,0 +1,21 @@ +%{ +#include "../include/lldb/Utility/ConstString.h" +%} + +%extend lldb::SBTarget { + %nothreadallow; + const char *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; + + lldb_private::ConstString str(desc, desc_len); + return str.GetCString(); + } + %clearnothreadallow; +} + Index: lldb/scripts/lldb.swig =================================================================== --- lldb/scripts/lldb.swig +++ lldb/scripts/lldb.swig @@ -105,6 +105,7 @@ %} %include "./interfaces.swig" +%include "./extensions.swig" %include "./Python/python-extensions.swig" %include "./Python/python-wrapper.swig" Index: lldb/scripts/lldb_lua.swig =================================================================== --- lldb/scripts/lldb_lua.swig +++ lldb/scripts/lldb_lua.swig @@ -15,4 +15,5 @@ using namespace lldb; %} +%include "./extensions.swig" %include "./interfaces.swig"