[Lldb-commits] [lldb] r223819 - This patch does a few things:

Enrico Granata egranata at apple.com
Tue Dec 9 11:51:21 PST 2014


Author: enrico
Date: Tue Dec  9 13:51:20 2014
New Revision: 223819

URL: http://llvm.org/viewvc/llvm-project?rev=223819&view=rev
Log:
This patch does a few things:
- adds a new flag to mark ValueObjects as "synthetic children generated"
- vends new Create functions as part of the SyntheticChildrenFrontEnd that set the flag automatically
- moves synthetic child providers over to using these new functions

No visible feature change, but preparatory work for feature change


Modified:
    lldb/trunk/include/lldb/Core/ValueObject.h
    lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h
    lldb/trunk/source/Core/ValueObject.cpp
    lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp
    lldb/trunk/source/DataFormatters/LibCxx.cpp
    lldb/trunk/source/DataFormatters/LibCxxInitializerList.cpp
    lldb/trunk/source/DataFormatters/LibCxxList.cpp
    lldb/trunk/source/DataFormatters/LibCxxMap.cpp
    lldb/trunk/source/DataFormatters/LibCxxVector.cpp
    lldb/trunk/source/DataFormatters/LibStdcpp.cpp
    lldb/trunk/source/DataFormatters/NSArray.cpp
    lldb/trunk/source/DataFormatters/NSDictionary.cpp
    lldb/trunk/source/DataFormatters/NSSet.cpp
    lldb/trunk/source/DataFormatters/TypeSynthetic.cpp

Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=223819&r1=223818&r2=223819&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Tue Dec  9 13:51:20 2014
@@ -779,6 +779,12 @@ public:
         return false;
     }
     
+    bool
+    IsSyntheticChildrenGenerated ();
+    
+    void
+    SetSyntheticChildrenGenerated (bool b);
+    
     virtual SymbolContextScope *
     GetSymbolContextScope();
     
@@ -1106,7 +1112,8 @@ protected:
                         m_is_bitfield_for_scalar:1,
                         m_is_child_at_offset:1,
                         m_is_getting_summary:1,
-                        m_did_calculate_complete_objc_class_type:1;
+                        m_did_calculate_complete_objc_class_type:1,
+                        m_is_synthetic_children_generated:1;
     
     friend class ClangExpressionDeclMap;  // For GetValue
     friend class ClangExpressionVariable; // For SetName

Modified: lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h?rev=223819&r1=223818&r2=223819&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h Tue Dec  9 13:51:20 2014
@@ -89,6 +89,24 @@ namespace lldb_private {
         typedef std::shared_ptr<SyntheticChildrenFrontEnd> SharedPointer;
         typedef std::unique_ptr<SyntheticChildrenFrontEnd> AutoPointer;
         
+    protected:
+        lldb::ValueObjectSP
+        CreateValueObjectFromExpression (const char* name,
+                                         const char* expression,
+                                         const ExecutionContext& exe_ctx);
+        
+        lldb::ValueObjectSP
+        CreateValueObjectFromAddress (const char* name,
+                                      uint64_t address,
+                                      const ExecutionContext& exe_ctx,
+                                      ClangASTType type);
+        
+        lldb::ValueObjectSP
+        CreateValueObjectFromData (const char* name,
+                                   const DataExtractor& data,
+                                   const ExecutionContext& exe_ctx,
+                                   ClangASTType type);
+        
     private:
         bool m_valid;
         DISALLOW_COPY_AND_ASSIGN(SyntheticChildrenFrontEnd);

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=223819&r1=223818&r2=223819&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Tue Dec  9 13:51:20 2014
@@ -107,7 +107,8 @@ ValueObject::ValueObject (ValueObject &p
     m_is_bitfield_for_scalar(false),
     m_is_child_at_offset(false),
     m_is_getting_summary(false),
-    m_did_calculate_complete_objc_class_type(false)
+    m_did_calculate_complete_objc_class_type(false),
+    m_is_synthetic_children_generated(parent.m_is_synthetic_children_generated)
 {
     m_manager->ManageObject(this);
 }
@@ -155,7 +156,8 @@ ValueObject::ValueObject (ExecutionConte
     m_is_bitfield_for_scalar(false),
     m_is_child_at_offset(false),
     m_is_getting_summary(false),
-    m_did_calculate_complete_objc_class_type(false)
+    m_did_calculate_complete_objc_class_type(false),
+    m_is_synthetic_children_generated(false)
 {
     m_manager = new ValueObjectManager();
     m_manager->ManageObject (this);
@@ -4206,3 +4208,15 @@ ValueObject::Persist ()
     
     return clang_var_sp->GetValueObject();
 }
+
+bool
+ValueObject::IsSyntheticChildrenGenerated ()
+{
+    return m_is_synthetic_children_generated;
+}
+
+void
+ValueObject::SetSyntheticChildrenGenerated (bool b)
+{
+    m_is_synthetic_children_generated = b;
+}

Modified: lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp?rev=223819&r1=223818&r2=223819&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp (original)
+++ lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp Tue Dec  9 13:51:20 2014
@@ -1130,7 +1130,7 @@ lldb_private::formatters::VectorIterator
         return false;
     Error err;
     m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
-    m_item_sp = ValueObject::CreateValueObjectFromAddress("item", item_ptr->GetValueAsUnsigned(0), m_exe_ctx_ref, item_ptr->GetClangType().GetPointeeType());
+    m_item_sp = CreateValueObjectFromAddress("item", item_ptr->GetValueAsUnsigned(0), m_exe_ctx_ref, item_ptr->GetClangType().GetPointeeType());
     if (err.Fail())
         m_item_sp.reset();
     return false;

Modified: lldb/trunk/source/DataFormatters/LibCxx.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/LibCxx.cpp?rev=223819&r1=223818&r2=223819&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/LibCxx.cpp (original)
+++ lldb/trunk/source/DataFormatters/LibCxx.cpp Tue Dec  9 13:51:20 2014
@@ -143,7 +143,7 @@ lldb_private::formatters::LibcxxVectorBo
     if (bit_set && buffer_sp && buffer_sp->GetBytes())
         *(buffer_sp->GetBytes()) = 1; // regardless of endianness, anything non-zero is true
     StreamString name; name.Printf("[%" PRIu64 "]", (uint64_t)idx);
-    ValueObjectSP retval_sp(ValueObject::CreateValueObjectFromData(name.GetData(), DataExtractor(buffer_sp, process_sp->GetByteOrder(), process_sp->GetAddressByteSize()), m_exe_ctx_ref, m_bool_type));
+    ValueObjectSP retval_sp(CreateValueObjectFromData(name.GetData(), DataExtractor(buffer_sp, process_sp->GetByteOrder(), process_sp->GetAddressByteSize()), m_exe_ctx_ref, m_bool_type));
     if (retval_sp)
         m_children[idx] = retval_sp;
     return retval_sp;
@@ -378,7 +378,7 @@ lldb_private::formatters::LibcxxSharedPt
                 return lldb::ValueObjectSP();
             uint64_t count = 1 + shared_owners_sp->GetValueAsUnsigned(0);
             DataExtractor data(&count, 8, m_byte_order, m_ptr_size);
-            m_count_sp = ValueObject::CreateValueObjectFromData("count", data, valobj_sp->GetExecutionContextRef(), shared_owners_sp->GetClangType());
+            m_count_sp = CreateValueObjectFromData("count", data, valobj_sp->GetExecutionContextRef(), shared_owners_sp->GetClangType());
         }
         return m_count_sp;
     }
@@ -391,7 +391,7 @@ lldb_private::formatters::LibcxxSharedPt
                 return lldb::ValueObjectSP();
             uint64_t count = 1 + shared_weak_owners_sp->GetValueAsUnsigned(0);
             DataExtractor data(&count, 8, m_byte_order, m_ptr_size);
-            m_weak_count_sp = ValueObject::CreateValueObjectFromData("count", data, valobj_sp->GetExecutionContextRef(), shared_weak_owners_sp->GetClangType());
+            m_weak_count_sp = CreateValueObjectFromData("count", data, valobj_sp->GetExecutionContextRef(), shared_weak_owners_sp->GetClangType());
         }
         return m_weak_count_sp;
     }

Modified: lldb/trunk/source/DataFormatters/LibCxxInitializerList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/LibCxxInitializerList.cpp?rev=223819&r1=223818&r2=223819&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/LibCxxInitializerList.cpp (original)
+++ lldb/trunk/source/DataFormatters/LibCxxInitializerList.cpp Tue Dec  9 13:51:20 2014
@@ -89,7 +89,7 @@ lldb_private::formatters::LibcxxInitiali
     offset = offset + m_start->GetValueAsUnsigned(0);
     StreamString name;
     name.Printf("[%" PRIu64 "]", (uint64_t)idx);
-    ValueObjectSP child_sp = ValueObject::CreateValueObjectFromAddress(name.GetData(), offset, m_backend.GetExecutionContextRef(), m_element_type);
+    ValueObjectSP child_sp = CreateValueObjectFromAddress(name.GetData(), offset, m_backend.GetExecutionContextRef(), m_element_type);
     m_children[idx] = child_sp;
     return child_sp;
 }

Modified: lldb/trunk/source/DataFormatters/LibCxxList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/LibCxxList.cpp?rev=223819&r1=223818&r2=223819&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/LibCxxList.cpp (original)
+++ lldb/trunk/source/DataFormatters/LibCxxList.cpp Tue Dec  9 13:51:20 2014
@@ -308,7 +308,7 @@ lldb_private::formatters::LibcxxStdListS
     
     StreamString name;
     name.Printf("[%" PRIu64 "]", (uint64_t)idx);
-    return (m_children[idx] = ValueObject::CreateValueObjectFromData(name.GetData(), data, m_backend.GetExecutionContextRef(), m_element_type));
+    return (m_children[idx] = CreateValueObjectFromData(name.GetData(), data, m_backend.GetExecutionContextRef(), m_element_type));
 }
 
 bool

Modified: lldb/trunk/source/DataFormatters/LibCxxMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/LibCxxMap.cpp?rev=223819&r1=223818&r2=223819&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/LibCxxMap.cpp (original)
+++ lldb/trunk/source/DataFormatters/LibCxxMap.cpp Tue Dec  9 13:51:20 2014
@@ -420,7 +420,7 @@ lldb_private::formatters::LibcxxStdMapSy
     }
     StreamString name;
     name.Printf("[%" PRIu64 "]", (uint64_t)idx);
-    auto potential_child_sp = ValueObject::CreateValueObjectFromData(name.GetData(), data, m_backend.GetExecutionContextRef(), m_element_type);
+    auto potential_child_sp = CreateValueObjectFromData(name.GetData(), data, m_backend.GetExecutionContextRef(), m_element_type);
     if (potential_child_sp)
     {
         switch (potential_child_sp->GetNumChildren())

Modified: lldb/trunk/source/DataFormatters/LibCxxVector.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/LibCxxVector.cpp?rev=223819&r1=223818&r2=223819&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/LibCxxVector.cpp (original)
+++ lldb/trunk/source/DataFormatters/LibCxxVector.cpp Tue Dec  9 13:51:20 2014
@@ -98,7 +98,7 @@ lldb_private::formatters::LibcxxStdVecto
     offset = offset + m_start->GetValueAsUnsigned(0);
     StreamString name;
     name.Printf("[%" PRIu64 "]", (uint64_t)idx);
-    ValueObjectSP child_sp = ValueObject::CreateValueObjectFromAddress(name.GetData(), offset, m_backend.GetExecutionContextRef(), m_element_type);
+    ValueObjectSP child_sp = CreateValueObjectFromAddress(name.GetData(), offset, m_backend.GetExecutionContextRef(), m_element_type);
     m_children[idx] = child_sp;
     return child_sp;
 }

Modified: lldb/trunk/source/DataFormatters/LibStdcpp.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/LibStdcpp.cpp?rev=223819&r1=223818&r2=223819&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/LibStdcpp.cpp (original)
+++ lldb/trunk/source/DataFormatters/LibStdcpp.cpp Tue Dec  9 13:51:20 2014
@@ -276,7 +276,7 @@ lldb_private::formatters::LibstdcppMapIt
     if (m_pair_address != 0 && m_pair_type)
     {
         if (!m_pair_sp)
-            m_pair_sp = ValueObject::CreateValueObjectFromAddress("pair", m_pair_address, m_exe_ctx_ref, m_pair_type);
+            m_pair_sp = CreateValueObjectFromAddress("pair", m_pair_address, m_exe_ctx_ref, m_pair_type);
         if (m_pair_sp)
             return m_pair_sp->GetChildAtIndex(idx, true);
     }

Modified: lldb/trunk/source/DataFormatters/NSArray.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/NSArray.cpp?rev=223819&r1=223818&r2=223819&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/NSArray.cpp (original)
+++ lldb/trunk/source/DataFormatters/NSArray.cpp Tue Dec  9 13:51:20 2014
@@ -341,10 +341,10 @@ lldb_private::formatters::NSArrayMSynthe
     object_at_idx += (pyhs_idx * m_ptr_size);
     StreamString idx_name;
     idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
-    lldb::ValueObjectSP retval_sp = ValueObject::CreateValueObjectFromAddress(idx_name.GetData(),
-                                                                              object_at_idx,
-                                                                              m_exe_ctx_ref,
-                                                                              m_id_type);
+    lldb::ValueObjectSP retval_sp = CreateValueObjectFromAddress(idx_name.GetData(),
+                                                                 object_at_idx,
+                                                                 m_exe_ctx_ref,
+                                                                 m_id_type);
     m_children.push_back(retval_sp);
     return retval_sp;
 }
@@ -604,7 +604,10 @@ lldb_private::formatters::NSArrayISynthe
         return lldb::ValueObjectSP();
     StreamString idx_name;
     idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
-    lldb::ValueObjectSP retval_sp = ValueObject::CreateValueObjectFromAddress(idx_name.GetData(), object_at_idx, m_exe_ctx_ref, m_id_type);
+    lldb::ValueObjectSP retval_sp = CreateValueObjectFromAddress(idx_name.GetData(),
+                                                                 object_at_idx,
+                                                                 m_exe_ctx_ref,
+                                                                 m_id_type);
     m_children.push_back(retval_sp);
     return retval_sp;
 }

Modified: lldb/trunk/source/DataFormatters/NSDictionary.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/NSDictionary.cpp?rev=223819&r1=223818&r2=223819&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/NSDictionary.cpp (original)
+++ lldb/trunk/source/DataFormatters/NSDictionary.cpp Tue Dec  9 13:51:20 2014
@@ -522,7 +522,10 @@ lldb_private::formatters::NSDictionaryIS
         StreamString idx_name;
         idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
         DataExtractor data(buffer_sp, m_order, m_ptr_size);
-        dict_item.valobj_sp = ValueObject::CreateValueObjectFromData(idx_name.GetData(), data, m_exe_ctx_ref, m_pair_type);
+        dict_item.valobj_sp = CreateValueObjectFromData(idx_name.GetData(),
+                                                        data,
+                                                        m_exe_ctx_ref,
+                                                        m_pair_type);
     }
     return dict_item.valobj_sp;
 }
@@ -686,7 +689,10 @@ lldb_private::formatters::NSDictionaryMS
         StreamString idx_name;
         idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
         DataExtractor data(buffer_sp, m_order, m_ptr_size);
-        dict_item.valobj_sp = ValueObject::CreateValueObjectFromData(idx_name.GetData(), data, m_exe_ctx_ref, m_pair_type);
+        dict_item.valobj_sp = CreateValueObjectFromData(idx_name.GetData(),
+                                                        data,
+                                                        m_exe_ctx_ref,
+                                                        m_pair_type);
     }
     return dict_item.valobj_sp;
 }

Modified: lldb/trunk/source/DataFormatters/NSSet.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/NSSet.cpp?rev=223819&r1=223818&r2=223819&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/NSSet.cpp (original)
+++ lldb/trunk/source/DataFormatters/NSSet.cpp Tue Dec  9 13:51:20 2014
@@ -469,10 +469,10 @@ lldb_private::formatters::NSSetISyntheti
                            process_sp->GetAddressByteSize());
         
         set_item.valobj_sp =
-            ValueObject::CreateValueObjectFromData(idx_name.GetData(),
-                                                   data,
-                                                   m_exe_ctx_ref,
-                                                   m_backend.GetClangType().GetBasicTypeFromAST(lldb::eBasicTypeObjCID));
+            CreateValueObjectFromData(idx_name.GetData(),
+                                      data,
+                                      m_exe_ctx_ref,
+                                      m_backend.GetClangType().GetBasicTypeFromAST(lldb::eBasicTypeObjCID));
     }
     return set_item.valobj_sp;
 }
@@ -637,10 +637,10 @@ lldb_private::formatters::NSSetMSyntheti
                            process_sp->GetAddressByteSize());
         
         set_item.valobj_sp =
-            ValueObject::CreateValueObjectFromData(idx_name.GetData(),
-                                                   data,
-                                                   m_exe_ctx_ref,
-                                                   m_backend.GetClangType().GetBasicTypeFromAST(lldb::eBasicTypeObjCID));
+            CreateValueObjectFromData(idx_name.GetData(),
+                                      data,
+                                      m_exe_ctx_ref,
+                                      m_backend.GetClangType().GetBasicTypeFromAST(lldb::eBasicTypeObjCID));
     }
     return set_item.valobj_sp;
 }

Modified: lldb/trunk/source/DataFormatters/TypeSynthetic.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeSynthetic.cpp?rev=223819&r1=223818&r2=223819&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/TypeSynthetic.cpp (original)
+++ lldb/trunk/source/DataFormatters/TypeSynthetic.cpp Tue Dec  9 13:51:20 2014
@@ -111,4 +111,39 @@ ScriptedSyntheticChildren::GetDescriptio
     return sstr.GetString();
 }
 
+lldb::ValueObjectSP
+SyntheticChildrenFrontEnd::CreateValueObjectFromExpression (const char* name,
+                                                            const char* expression,
+                                                            const ExecutionContext& exe_ctx)
+{
+    ValueObjectSP valobj_sp(ValueObject::CreateValueObjectFromExpression(name, expression, exe_ctx));
+    if (valobj_sp)
+        valobj_sp->SetSyntheticChildrenGenerated(true);
+    return valobj_sp;
+}
+
+lldb::ValueObjectSP
+SyntheticChildrenFrontEnd::CreateValueObjectFromAddress (const char* name,
+                                                         uint64_t address,
+                                                         const ExecutionContext& exe_ctx,
+                                                         ClangASTType type)
+{
+    ValueObjectSP valobj_sp(ValueObject::CreateValueObjectFromAddress(name, address, exe_ctx, type));
+    if (valobj_sp)
+        valobj_sp->SetSyntheticChildrenGenerated(true);
+    return valobj_sp;
+}
+
+lldb::ValueObjectSP
+SyntheticChildrenFrontEnd::CreateValueObjectFromData (const char* name,
+                                                      const DataExtractor& data,
+                                                      const ExecutionContext& exe_ctx,
+                                                      ClangASTType type)
+{
+    ValueObjectSP valobj_sp(ValueObject::CreateValueObjectFromData(name, data, exe_ctx, type));
+    if (valobj_sp)
+        valobj_sp->SetSyntheticChildrenGenerated(true);
+    return valobj_sp;
+}
+
 #endif // #ifndef LLDB_DISABLE_PYTHON





More information about the lldb-commits mailing list