[Lldb-commits] [lldb] 51bdd98 - [lldb/SWIG] Refactor extensions to be non Python-specific (3/3)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed Jan 8 21:03:07 PST 2020


Author: Jonas Devlieghere
Date: 2020-01-08T21:02:59-08:00
New Revision: 51bdd98b8a52d07004bcaddff26caf376a1c32bf

URL: https://github.com/llvm/llvm-project/commit/51bdd98b8a52d07004bcaddff26caf376a1c32bf
DIFF: https://github.com/llvm/llvm-project/commit/51bdd98b8a52d07004bcaddff26caf376a1c32bf.diff

LOG: [lldb/SWIG] Refactor extensions to be non Python-specific (3/3)

The current SWIG extensions for the string conversion operator is Python
specific because it uses the PythonObjects. This means that the code
cannot be reused for other SWIG supported languages such as Lua.

This reimplements the extensions in a more generic way that can be
reused. It uses a SWIG macro to reduce code duplication.

Differential revision: https://reviews.llvm.org/D72377

Added: 
    

Modified: 
    lldb/scripts/Python/python-extensions.swig
    lldb/scripts/interface/SBProcess.i
    lldb/scripts/interface/SBSection.i
    lldb/scripts/interface/SBSymbol.i
    lldb/scripts/interface/SBSymbolContext.i
    lldb/scripts/interface/SBSymbolContextList.i
    lldb/scripts/interface/SBThread.i
    lldb/scripts/interface/SBType.i
    lldb/scripts/interface/SBTypeCategory.i
    lldb/scripts/interface/SBTypeEnumMember.i
    lldb/scripts/interface/SBTypeFilter.i
    lldb/scripts/interface/SBTypeFormat.i
    lldb/scripts/interface/SBTypeNameSpecifier.i
    lldb/scripts/interface/SBTypeSummary.i
    lldb/scripts/interface/SBTypeSynthetic.i
    lldb/scripts/interface/SBValue.i
    lldb/scripts/interface/SBValueList.i
    lldb/scripts/interface/SBWatchpoint.i

Removed: 
    


################################################################################
diff  --git a/lldb/scripts/Python/python-extensions.swig b/lldb/scripts/Python/python-extensions.swig
index 36dac19644bd..0b23fdd40006 100644
--- a/lldb/scripts/Python/python-extensions.swig
+++ b/lldb/scripts/Python/python-extensions.swig
@@ -125,32 +125,7 @@
     %}
 }
 
-%extend lldb::SBProcess {
-        %nothreadallow;
-        PyObject *lldb::SBProcess::__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::SBSection {
-        %nothreadallow;
-        PyObject *lldb::SBSection::__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)):
@@ -180,17 +155,6 @@
         {}
 }
 %extend lldb::SBSymbol {
-        %nothreadallow;
-        PyObject *lldb::SBSymbol::__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)):
@@ -205,32 +169,6 @@
             return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
     %}
 }
-%extend lldb::SBSymbolContext {
-        %nothreadallow;
-        PyObject *lldb::SBSymbolContext::__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::SBSymbolContextList {
-        %nothreadallow;
-        PyObject *lldb::SBSymbolContextList::__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::SBTarget {
     %pythoncode %{
@@ -248,44 +186,7 @@
     %}
 }
 
-%extend lldb::SBType {
-        %nothreadallow;
-        PyObject *lldb::SBType::__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;
-}
-%extend lldb::SBTypeCategory {
-        %nothreadallow;
-        PyObject *lldb::SBTypeCategory::__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;
-}
 %extend lldb::SBTypeFilter {
-        %nothreadallow;
-        PyObject *lldb::SBTypeFilter::__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)):
@@ -300,70 +201,8 @@
             return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
     %}
 }
-%extend lldb::SBTypeFormat {
-        %nothreadallow;
-        PyObject *lldb::SBTypeFormat::__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;
-}
-%extend lldb::SBTypeMember {
-        %nothreadallow;
-        PyObject *lldb::SBTypeMember::__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;
-}
-%extend lldb::SBTypeMemberFunction {
-        %nothreadallow;
-        PyObject *lldb::SBTypeMemberFunction::__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;
-}
-%extend lldb::SBTypeEnumMember {
-        %nothreadallow;
-        PyObject *lldb::SBTypeEnumMember::__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;
-}
+
 %extend lldb::SBTypeNameSpecifier {
-        %nothreadallow;
-        PyObject *lldb::SBTypeNameSpecifier::__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)):
@@ -378,18 +217,8 @@
             return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
     %}
 }
+
 %extend lldb::SBTypeSummary {
-        %nothreadallow;
-        PyObject *lldb::SBTypeSummary::__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)):
@@ -404,18 +233,8 @@
             return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
     %}
 }
+
 %extend lldb::SBTypeSynthetic {
-        %nothreadallow;
-        PyObject *lldb::SBTypeSynthetic::__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)):
@@ -430,18 +249,8 @@
             return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
     %}
 }
+
 %extend lldb::SBThread {
-        %nothreadallow;
-        PyObject *lldb::SBThread::__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)):
@@ -456,64 +265,6 @@
             return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
     %}
 }
-%extend lldb::SBValue {
-        %nothreadallow;
-        PyObject *lldb::SBValue::__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::SBValueList {
-        %nothreadallow;
-        PyObject *lldb::SBValueList::__str__ (){
-                lldb::SBStream description;
-                const size_t n = $self->GetSize();
-                if (n)
-                {
-                    for (size_t i=0; i<n; ++i)
-                        $self->GetValueAtIndex(i).GetDescription(description);
-                }
-                else
-                {
-                    description.Printf("<empty> lldb.SBValueList()");
-                }
-                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::SBWatchpoint {
-        %nothreadallow;
-        PyObject *lldb::SBWatchpoint::__str__ (){
-                lldb::SBStream description;
-                $self->GetDescription (description, lldb::eDescriptionLevelVerbose);
-                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 {
-//         // FIXME: We can't get the callback and baton
-//         PyObject *lldb::SBDebugger (){
-//             // Only call Py_XDECREF if we have a Python object (or NULL)
-//             if (LLDBSwigPythonCallPythonLogOutputCallback == $self->GetLogOutPutCallback())
-//                 Py_XDECREF($self->GetCallbackBaton());
-//         }
-// }
 
 %pythoncode %{
 

diff  --git a/lldb/scripts/interface/SBProcess.i b/lldb/scripts/interface/SBProcess.i
index c5ebc2468615..ac6a265faec9 100644
--- a/lldb/scripts/interface/SBProcess.i
+++ b/lldb/scripts/interface/SBProcess.i
@@ -417,6 +417,8 @@ public:
     lldb::SBProcessInfo
     GetProcessInfo();
 
+    STRING_EXTENSION(SBProcess)
+
 #ifdef SWIGPYTHON
     %pythoncode %{
         def __get_is_alive__(self):

diff  --git a/lldb/scripts/interface/SBSection.i b/lldb/scripts/interface/SBSection.i
index c1a84acc4f14..3d1c900917fd 100644
--- a/lldb/scripts/interface/SBSection.i
+++ b/lldb/scripts/interface/SBSection.i
@@ -114,6 +114,8 @@ public:
     bool
     operator != (const lldb::SBSection &rhs);
 
+    STRING_EXTENSION(SBSection)
+
 #ifdef SWIGPYTHON
     %pythoncode %{
         def __iter__(self):

diff  --git a/lldb/scripts/interface/SBSymbol.i b/lldb/scripts/interface/SBSymbol.i
index e5880e66d300..4e17ab5af0fd 100644
--- a/lldb/scripts/interface/SBSymbol.i
+++ b/lldb/scripts/interface/SBSymbol.i
@@ -72,6 +72,8 @@ public:
     bool
     operator != (const lldb::SBSymbol &rhs) const;
 
+    STRING_EXTENSION(SBSymbol)
+
 #ifdef SWIGPYTHON
     %pythoncode %{
         def get_instructions_from_current_target (self):

diff  --git a/lldb/scripts/interface/SBSymbolContext.i b/lldb/scripts/interface/SBSymbolContext.i
index a6aa4d78bfe3..b6b336516c94 100644
--- a/lldb/scripts/interface/SBSymbolContext.i
+++ b/lldb/scripts/interface/SBSymbolContext.i
@@ -81,6 +81,7 @@ public:
     bool
     GetDescription (lldb::SBStream &description);
 
+    STRING_EXTENSION(SBSymbolContext)
 
 #ifdef SWIGPYTHON
     %pythoncode %{

diff  --git a/lldb/scripts/interface/SBSymbolContextList.i b/lldb/scripts/interface/SBSymbolContextList.i
index 54adc659fa21..f5adcfcebfb5 100644
--- a/lldb/scripts/interface/SBSymbolContextList.i
+++ b/lldb/scripts/interface/SBSymbolContextList.i
@@ -60,6 +60,8 @@ public:
     void
     Clear();
 
+    STRING_EXTENSION(SBSymbolContextList)
+
 #ifdef SWIGPYTHON
     %pythoncode %{
         def __iter__(self):

diff  --git a/lldb/scripts/interface/SBThread.i b/lldb/scripts/interface/SBThread.i
index c1c045487fc1..95b15b182ec2 100644
--- a/lldb/scripts/interface/SBThread.i
+++ b/lldb/scripts/interface/SBThread.i
@@ -402,6 +402,8 @@ public:
     bool
     SafeToCallFunctions ();
 
+    STRING_EXTENSION(SBThread)
+
 #ifdef SWIGPYTHON
     %pythoncode %{
         def __iter__(self):

diff  --git a/lldb/scripts/interface/SBType.i b/lldb/scripts/interface/SBType.i
index d9da9e39b956..3cd82452084b 100644
--- a/lldb/scripts/interface/SBType.i
+++ b/lldb/scripts/interface/SBType.i
@@ -43,6 +43,8 @@ public:
     uint32_t
     GetBitfieldSizeInBits();
 
+    STRING_EXTENSION_LEVEL(SBTypeMember, lldb::eDescriptionLevelBrief)
+
 #ifdef SWIGPYTHON
     %pythoncode %{
         name = property(GetName, None, doc='''A read only property that returns the name for this member as a string.''')
@@ -100,6 +102,7 @@ public:
     GetDescription (lldb::SBStream &description,
                     lldb::DescriptionLevel description_level);
 
+    STRING_EXTENSION_LEVEL(SBTypeMemberFunction, lldb::eDescriptionLevelBrief)
 protected:
     lldb::TypeMemberFunctionImplSP m_opaque_sp;
 };
@@ -314,6 +317,8 @@ public:
 
     bool operator!=(lldb::SBType &rhs);
 
+    STRING_EXTENSION_LEVEL(SBType, lldb::eDescriptionLevelBrief)
+
 #ifdef SWIGPYTHON
     %pythoncode %{
         def template_arg_array(self):

diff  --git a/lldb/scripts/interface/SBTypeCategory.i b/lldb/scripts/interface/SBTypeCategory.i
index 43fe9faf70f5..b762bf8a95a3 100644
--- a/lldb/scripts/interface/SBTypeCategory.i
+++ b/lldb/scripts/interface/SBTypeCategory.i
@@ -124,6 +124,8 @@ namespace lldb {
         bool
         DeleteTypeSynthetic (lldb::SBTypeNameSpecifier);
 
+        STRING_EXTENSION_LEVEL(SBTypeCategory, lldb::eDescriptionLevelBrief)
+
 #ifdef SWIGPYTHON
         %pythoncode %{
 

diff  --git a/lldb/scripts/interface/SBTypeEnumMember.i b/lldb/scripts/interface/SBTypeEnumMember.i
index b2d861711782..006bdeaa8cee 100644
--- a/lldb/scripts/interface/SBTypeEnumMember.i
+++ b/lldb/scripts/interface/SBTypeEnumMember.i
@@ -43,6 +43,7 @@ public:
     GetDescription (lldb::SBStream &description,
                     lldb::DescriptionLevel description_level);
 
+    STRING_EXTENSION_LEVEL(SBTypeEnumMember, lldb::eDescriptionLevelBrief)
 #ifdef SWIGPYTHON
     %pythoncode %{
         name = property(GetName, None, doc='''A read only property that returns the name for this enum member as a string.''')

diff  --git a/lldb/scripts/interface/SBTypeFilter.i b/lldb/scripts/interface/SBTypeFilter.i
index 3759e0a23d41..c1d282c6d4fb 100644
--- a/lldb/scripts/interface/SBTypeFilter.i
+++ b/lldb/scripts/interface/SBTypeFilter.i
@@ -61,6 +61,8 @@ namespace lldb {
         bool
         operator != (lldb::SBTypeFilter &rhs);
 
+        STRING_EXTENSION_LEVEL(SBTypeFilter, lldb::eDescriptionLevelBrief)
+
 #ifdef SWIGPYTHON
         %pythoncode %{
             options = property(GetOptions, SetOptions)

diff  --git a/lldb/scripts/interface/SBTypeFormat.i b/lldb/scripts/interface/SBTypeFormat.i
index 5efd135b7326..765a2a7bb99d 100644
--- a/lldb/scripts/interface/SBTypeFormat.i
+++ b/lldb/scripts/interface/SBTypeFormat.i
@@ -61,6 +61,8 @@ namespace lldb {
         bool
         operator != (lldb::SBTypeFormat &rhs);
 
+        STRING_EXTENSION_LEVEL(SBTypeFormat, lldb::eDescriptionLevelBrief)
+
 #ifdef SWIGPYTHON
         %pythoncode %{
             format = property(GetFormat, SetFormat)

diff  --git a/lldb/scripts/interface/SBTypeNameSpecifier.i b/lldb/scripts/interface/SBTypeNameSpecifier.i
index bb16e86b0bc5..772f7c174093 100644
--- a/lldb/scripts/interface/SBTypeNameSpecifier.i
+++ b/lldb/scripts/interface/SBTypeNameSpecifier.i
@@ -53,6 +53,8 @@ namespace lldb {
         bool
         operator != (lldb::SBTypeNameSpecifier &rhs);
 
+        STRING_EXTENSION_LEVEL(SBTypeNameSpecifier, lldb::eDescriptionLevelBrief)
+
 #ifdef SWIGPYTHON
         %pythoncode %{
             name = property(GetName)

diff  --git a/lldb/scripts/interface/SBTypeSummary.i b/lldb/scripts/interface/SBTypeSummary.i
index 225a404cf73c..adcc79b5a6ee 100644
--- a/lldb/scripts/interface/SBTypeSummary.i
+++ b/lldb/scripts/interface/SBTypeSummary.i
@@ -101,6 +101,8 @@ namespace lldb {
         bool
         operator != (lldb::SBTypeSummary &rhs);
 
+        STRING_EXTENSION_LEVEL(SBTypeSummary, lldb::eDescriptionLevelBrief)
+
 #ifdef SWIGPYTHON
         %pythoncode %{
             options = property(GetOptions, SetOptions)

diff  --git a/lldb/scripts/interface/SBTypeSynthetic.i b/lldb/scripts/interface/SBTypeSynthetic.i
index d9d75e4c9efa..f57139ebf9f1 100644
--- a/lldb/scripts/interface/SBTypeSynthetic.i
+++ b/lldb/scripts/interface/SBTypeSynthetic.i
@@ -63,6 +63,8 @@ namespace lldb {
         bool
         operator != (lldb::SBTypeSynthetic &rhs);
 
+        STRING_EXTENSION_LEVEL(SBTypeSynthetic, lldb::eDescriptionLevelBrief)
+
 #ifdef SWIGPYTHON
         %pythoncode %{
             options = property(GetOptions, SetOptions)

diff  --git a/lldb/scripts/interface/SBValue.i b/lldb/scripts/interface/SBValue.i
index 8647854e89c1..fb899805c395 100644
--- a/lldb/scripts/interface/SBValue.i
+++ b/lldb/scripts/interface/SBValue.i
@@ -440,6 +440,8 @@ public:
                        const SBExpressionOptions &options,
                        const char *name) const;
 
+    STRING_EXTENSION(SBValue)
+
 #ifdef SWIGPYTHON
     %pythoncode %{
         def __get_dynamic__ (self):

diff  --git a/lldb/scripts/interface/SBValueList.i b/lldb/scripts/interface/SBValueList.i
index 56ef19054e4c..17ba2056f0c2 100644
--- a/lldb/scripts/interface/SBValueList.i
+++ b/lldb/scripts/interface/SBValueList.i
@@ -101,6 +101,29 @@ public:
     lldb::SBValue
     GetFirstValueByName (const char* name) const;
 
+    %extend {
+       %nothreadallow;
+       std::string lldb::SBValueList::__str__ (){
+           lldb::SBStream description;
+           const size_t n = $self->GetSize();
+           if (n)
+           {
+               for (size_t i=0; i<n; ++i)
+                   $self->GetValueAtIndex(i).GetDescription(description);
+           }
+           else
+           {
+               description.Printf("<empty> lldb.SBValueList()");
+           }
+           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 std::string(desc, desc_len);
+       }
+       %clearnothreadallow;
+    }
+
 #ifdef SWIGPYTHON
     %pythoncode %{
         def __iter__(self):

diff  --git a/lldb/scripts/interface/SBWatchpoint.i b/lldb/scripts/interface/SBWatchpoint.i
index e11c4f213ca2..cb0bc5f9859a 100644
--- a/lldb/scripts/interface/SBWatchpoint.i
+++ b/lldb/scripts/interface/SBWatchpoint.i
@@ -90,6 +90,7 @@ public:
     static lldb::SBWatchpoint
     GetWatchpointFromEvent (const lldb::SBEvent& event);
 
+    STRING_EXTENSION_LEVEL(SBWatchpoint, lldb::eDescriptionLevelVerbose)
 };
 
 } // namespace lldb


        


More information about the lldb-commits mailing list