[Lldb-commits] [lldb] r174638 - <rdar://problem/13107151>

Enrico Granata egranata at apple.com
Thu Feb 7 10:23:56 PST 2013


Author: enrico
Date: Thu Feb  7 12:23:56 2013
New Revision: 174638

URL: http://llvm.org/viewvc/llvm-project?rev=174638&view=rev
Log:
<rdar://problem/13107151>

SBValueList was backed by a ValueObjectList. This caused us to lose track of the additional metadata in the ValueImpl that backs SBValue.
This checkin fixes that by backing SBValueList with ValueListImpl (that essentially wraps a vector<SBValue>).


Modified:
    lldb/trunk/include/lldb/API/SBValueList.h
    lldb/trunk/source/API/SBFrame.cpp
    lldb/trunk/source/API/SBModule.cpp
    lldb/trunk/source/API/SBTarget.cpp
    lldb/trunk/source/API/SBValueList.cpp

Modified: lldb/trunk/include/lldb/API/SBValueList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValueList.h?rev=174638&r1=174637&r2=174638&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBValueList.h (original)
+++ lldb/trunk/include/lldb/API/SBValueList.h Thu Feb  7 12:23:56 2013
@@ -12,6 +12,10 @@
 
 #include "lldb/API/SBDefines.h"
 
+namespace {
+    class ValueListImpl;
+}
+
 namespace lldb {
 
 class SBValueList
@@ -48,28 +52,8 @@ public:
     const lldb::SBValueList &
     operator = (const lldb::SBValueList &rhs);
 
-    lldb_private::ValueObjectList *
-    operator -> ();
-
-    lldb_private::ValueObjectList &
-    operator* ();
-
-    const lldb_private::ValueObjectList *
-    operator -> () const;
-
-    const lldb_private::ValueObjectList &
-    operator* () const;
-    
-    lldb_private::ValueObjectList *
-    get ();
-
-    lldb_private::ValueObjectList &
-    ref ();
-
 private:
-    friend class SBFrame;
-
-    SBValueList (const lldb_private::ValueObjectList *lldb_object_ptr);
+    SBValueList (const ValueListImpl *lldb_object_ptr);
 
     void
     Append (lldb::ValueObjectSP& val_obj_sp);
@@ -77,7 +61,25 @@ private:
     void
     CreateIfNeeded ();
 
-    std::auto_ptr<lldb_private::ValueObjectList> m_opaque_ap;
+    ValueListImpl *
+    operator -> ();
+    
+    ValueListImpl &
+    operator* ();
+    
+    const ValueListImpl *
+    operator -> () const;
+    
+    const ValueListImpl &
+    operator* () const;
+    
+    ValueListImpl *
+    get ();
+    
+    ValueListImpl &
+    ref ();
+    
+    std::auto_ptr<ValueListImpl> m_opaque_ap;
 };
 
 

Modified: lldb/trunk/source/API/SBFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=174638&r1=174637&r2=174638&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFrame.cpp (original)
+++ lldb/trunk/source/API/SBFrame.cpp Thu Feb  7 12:23:56 2013
@@ -1159,8 +1159,7 @@ SBFrame::GetVariables (bool arguments,
 
     if (log)
     {
-        log->Printf ("SBFrame(%p)::GetVariables (...) => SBValueList(%p)", frame,
-                     value_list.get());
+        log->Printf ("SBFrame(%p)::GetVariables (...) => SBValueList", frame);
     }
 
     return value_list;
@@ -1210,7 +1209,7 @@ SBFrame::GetRegisters ()
     }
 
     if (log)
-        log->Printf ("SBFrame(%p)::GetRegisters () => SBValueList(%p)", frame, value_list.get());
+        log->Printf ("SBFrame(%p)::GetRegisters () => SBValueList", frame);
 
     return value_list;
 }

Modified: lldb/trunk/source/API/SBModule.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBModule.cpp?rev=174638&r1=174637&r2=174638&view=diff
==============================================================================
--- lldb/trunk/source/API/SBModule.cpp (original)
+++ lldb/trunk/source/API/SBModule.cpp Thu Feb  7 12:23:56 2013
@@ -467,14 +467,13 @@ SBModule::FindGlobalVariables (SBTarget
 
         if (match_count > 0)
         {
-            ValueObjectList &value_object_list = sb_value_list.ref();
             for (uint32_t i=0; i<match_count; ++i)
             {
                 lldb::ValueObjectSP valobj_sp;
                 TargetSP target_sp (target.GetSP());
                 valobj_sp = ValueObjectVariable::Create (target_sp.get(), variable_list.GetVariableAtIndex(i));
                 if (valobj_sp)
-                    value_object_list.Append(valobj_sp);
+                    sb_value_list.Append(SBValue(valobj_sp));
             }
         }
     }

Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=174638&r1=174637&r2=174638&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Thu Feb  7 12:23:56 2013
@@ -2219,12 +2219,11 @@ SBTarget::FindGlobalVariables (const cha
             ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
             if (exe_scope == NULL)
                 exe_scope = target_sp.get();
-            ValueObjectList &value_object_list = sb_value_list.ref();
             for (uint32_t i=0; i<match_count; ++i)
             {
                 lldb::ValueObjectSP valobj_sp (ValueObjectVariable::Create (exe_scope, variable_list.GetVariableAtIndex(i)));
                 if (valobj_sp)
-                    value_object_list.Append(valobj_sp);
+                    sb_value_list.Append(SBValue(valobj_sp));
             }
         }
     }

Modified: lldb/trunk/source/API/SBValueList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValueList.cpp?rev=174638&r1=174637&r2=174638&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValueList.cpp (original)
+++ lldb/trunk/source/API/SBValueList.cpp Thu Feb  7 12:23:56 2013
@@ -14,9 +14,78 @@
 #include "lldb/Core/Log.h"
 #include "lldb/Core/ValueObjectList.h"
 
+#include <vector>
+
 using namespace lldb;
 using namespace lldb_private;
 
+namespace {
+    class ValueListImpl
+    {
+    public:
+        ValueListImpl () :
+        m_values()
+        {
+        }
+        
+        ValueListImpl (const ValueListImpl& rhs) :
+        m_values(rhs.m_values)
+        {
+        }
+        
+        ValueListImpl&
+        operator = (const ValueListImpl& rhs)
+        {
+            if (this == &rhs)
+                return *this;
+            m_values = rhs.m_values;
+            return *this;
+        };
+        
+        uint32_t
+        GetSize ()
+        {
+            return m_values.size();
+        }
+        
+        void
+        Append (const lldb::SBValue& sb_value)
+        {
+            m_values.push_back(sb_value);
+        }
+        
+        void
+        Append (const ValueListImpl& list)
+        {
+            for (auto val : list.m_values)
+                Append (val);
+        }
+        
+        lldb::SBValue
+        GetValueAtIndex (uint32_t index)
+        {
+            if (index >= GetSize())
+                return lldb::SBValue();
+            return m_values[index];
+        }
+        
+        lldb::SBValue
+        FindValueByUID (lldb::user_id_t uid)
+        {
+            for (auto val : m_values)
+            {
+                if (val.IsValid() && val.GetID() == uid)
+                    return val;
+            }
+            return lldb::SBValue();
+        }
+
+    private:
+        std::vector<lldb::SBValue> m_values;
+    };
+}
+
+
 SBValueList::SBValueList () :
     m_opaque_ap ()
 {
@@ -28,7 +97,7 @@ SBValueList::SBValueList (const SBValueL
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     if (rhs.IsValid())
-        m_opaque_ap.reset (new ValueObjectList (*rhs));
+        m_opaque_ap.reset (new ValueListImpl (*rhs));
 
     if (log)
     {
@@ -38,13 +107,13 @@ SBValueList::SBValueList (const SBValueL
     }
 }
 
-SBValueList::SBValueList (const ValueObjectList *lldb_object_ptr) :
+SBValueList::SBValueList (const ValueListImpl *lldb_object_ptr) :
     m_opaque_ap ()
 {
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     if (lldb_object_ptr)
-        m_opaque_ap.reset (new ValueObjectList (*lldb_object_ptr));
+        m_opaque_ap.reset (new ValueListImpl (*lldb_object_ptr));
 
     if (log)
     {
@@ -76,32 +145,32 @@ SBValueList::operator = (const SBValueLi
     if (this != &rhs)
     {
         if (rhs.IsValid())
-            m_opaque_ap.reset (new ValueObjectList (*rhs));
+            m_opaque_ap.reset (new ValueListImpl (*rhs));
         else
             m_opaque_ap.reset ();
     }
     return *this;
 }
 
-ValueObjectList *
+ValueListImpl *
 SBValueList::operator->()
 {
     return m_opaque_ap.get();
 }
 
-ValueObjectList &
+ValueListImpl &
 SBValueList::operator*()
 {
     return *m_opaque_ap;
 }
 
-const ValueObjectList *
+const ValueListImpl *
 SBValueList::operator->() const
 {
     return m_opaque_ap.get();
 }
 
-const ValueObjectList &
+const ValueListImpl &
 SBValueList::operator*() const
 {
     return *m_opaque_ap;
@@ -110,12 +179,8 @@ SBValueList::operator*() const
 void
 SBValueList::Append (const SBValue &val_obj)
 {
-    ValueObjectSP value_sp (val_obj.GetSP());
-    if (value_sp)
-    {
-        CreateIfNeeded ();
-        m_opaque_ap->Append (value_sp);
-    }
+    CreateIfNeeded ();
+    m_opaque_ap->Append (val_obj);
 }
 
 void
@@ -124,7 +189,7 @@ SBValueList::Append (lldb::ValueObjectSP
     if (val_obj_sp)
     {
         CreateIfNeeded ();
-        m_opaque_ap->Append (val_obj_sp);
+        m_opaque_ap->Append (SBValue(val_obj_sp));
     }
 }
 
@@ -148,19 +213,15 @@ SBValueList::GetValueAtIndex (uint32_t i
     //    log->Printf ("SBValueList::GetValueAtIndex (uint32_t idx) idx = %d", idx);
 
     SBValue sb_value;
-    ValueObjectSP value_sp;
     if (m_opaque_ap.get())
-    {
-        value_sp = m_opaque_ap->GetValueObjectAtIndex (idx);
-        sb_value.SetSP (value_sp);
-    }
+        sb_value = m_opaque_ap->GetValueAtIndex (idx);
 
     if (log)
     {
         SBStream sstr;
         sb_value.GetDescription (sstr);
         log->Printf ("SBValueList::GetValueAtIndex (this.ap=%p, idx=%d) => SBValue (this.sp = %p, '%s')", 
-                     m_opaque_ap.get(), idx, value_sp.get(), sstr.GetData());
+                     m_opaque_ap.get(), idx, sb_value.GetSP().get(), sstr.GetData());
     }
 
     return sb_value;
@@ -188,7 +249,7 @@ void
 SBValueList::CreateIfNeeded ()
 {
     if (m_opaque_ap.get() == NULL)
-        m_opaque_ap.reset (new ValueObjectList());
+        m_opaque_ap.reset (new ValueListImpl());
 }
 
 
@@ -197,17 +258,17 @@ SBValueList::FindValueObjectByUID (lldb:
 {
     SBValue sb_value;
     if (m_opaque_ap.get())
-        sb_value.SetSP (m_opaque_ap->FindValueObjectByUID (uid));
+        sb_value = m_opaque_ap->FindValueByUID(uid);
     return sb_value;
 }
 
-ValueObjectList *
+ValueListImpl *
 SBValueList::get ()
 {
     return m_opaque_ap.get();
 }
 
-ValueObjectList &
+ValueListImpl &
 SBValueList::ref ()
 {
     CreateIfNeeded();





More information about the lldb-commits mailing list