[Lldb-commits] [lldb] r274683 - Because of our lifetime rules w.r.t. ValueObjects and ClusterManagers, synthetic children caching is a tricky area:
Enrico Granata via lldb-commits
lldb-commits at lists.llvm.org
Wed Jul 6 14:24:29 PDT 2016
Author: enrico
Date: Wed Jul 6 16:24:28 2016
New Revision: 274683
URL: http://llvm.org/viewvc/llvm-project?rev=274683&view=rev
Log:
Because of our lifetime rules w.r.t. ValueObjects and ClusterManagers, synthetic children caching is a tricky area:
- if a synthetic child comes from the same hierarchy as its parent object, then it can't be cached by SharedPointer inside the synthetic provider, or it will cause a reference loop;
- but, if a synthetic child is made from whole cloth (e.g. from an expression, a memory region, ...), then it better be cached by SharedPointer, or it will be cleared out and cause an assert() to fail if used at a later point
For most cases of self-rooted synthetic children, we have a flag we set "IsSyntheticChildrenGenerated", but we were not using it to track caching. So, what ended up happening is each provider would set up its own cache, and if it got it wrong, a hard to diagnose crash would ensue
This patch fixes that by centralizing caching in ValueObjectSynthetic - if a provider returns a self-rooted child (as per the flag), then it gets cached centrally by the ValueObject itself
This cache is used only for lifetime management and not later retrieval of child values - a different cache handles that (because we might have a mix of self-rooted and properly nested child values for the same parent, we can't trivially use this lifetime cache for retrieval)
Fixes rdar://26480007
Added:
lldb/trunk/include/lldb/Core/ThreadSafeSTLVector.h
Modified:
lldb/trunk/include/lldb/API/SBValue.h
lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h
lldb/trunk/include/lldb/Utility/SharedCluster.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/scripts/interface/SBValue.i
lldb/trunk/source/API/SBValue.cpp
lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
lldb/trunk/source/Plugins/Language/ObjC/NSArray.cpp
lldb/trunk/source/Plugins/Language/ObjC/NSError.cpp
lldb/trunk/source/Plugins/Language/ObjC/NSException.cpp
Modified: lldb/trunk/include/lldb/API/SBValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=274683&r1=274682&r2=274683&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBValue.h (original)
+++ lldb/trunk/include/lldb/API/SBValue.h Wed Jul 6 16:24:28 2016
@@ -125,6 +125,12 @@ public:
bool
IsSynthetic ();
+
+ bool
+ IsSyntheticChildrenGenerated ();
+
+ void
+ SetSyntheticChildrenGenerated (bool);
const char *
GetLocation ();
Added: lldb/trunk/include/lldb/Core/ThreadSafeSTLVector.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ThreadSafeSTLVector.h?rev=274683&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Core/ThreadSafeSTLVector.h (added)
+++ lldb/trunk/include/lldb/Core/ThreadSafeSTLVector.h Wed Jul 6 16:24:28 2016
@@ -0,0 +1,99 @@
+//===-- ThreadSafeSTLVector.h ------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_ThreadSafeSTLVector_h_
+#define liblldb_ThreadSafeSTLVector_h_
+
+// C Includes
+// C++ Includes
+#include <vector>
+#include <mutex>
+
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-defines.h"
+
+namespace lldb_private {
+
+ template <typename _Object>
+ class ThreadSafeSTLVector
+ {
+ public:
+ typedef std::vector<_Object> collection;
+ typedef typename collection::iterator iterator;
+ typedef typename collection::const_iterator const_iterator;
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ ThreadSafeSTLVector() : m_collection(), m_mutex() {}
+
+ ~ThreadSafeSTLVector() = default;
+
+ bool
+ IsEmpty() const
+ {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_collection.empty();
+ }
+
+ void
+ Clear()
+ {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_collection.clear();
+ }
+
+ size_t
+ GetCount()
+ {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_collection.size();
+ }
+
+ void
+ AppendObject (_Object& object)
+ {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ m_collection.push_back(object);
+ }
+
+ _Object
+ GetObject (size_t index)
+ {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_collection.at(index);
+ }
+
+ void
+ SetObject (size_t index, const _Object& object)
+ {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ m_collection.at(index) = object;
+ }
+
+ std::recursive_mutex &
+ GetMutex()
+ {
+ return m_mutex;
+ }
+
+ private:
+ collection m_collection;
+ mutable std::recursive_mutex m_mutex;
+
+ //------------------------------------------------------------------
+ // For ThreadSafeSTLVector only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN (ThreadSafeSTLVector);
+ };
+
+
+} // namespace lldb_private
+
+#endif // liblldb_ThreadSafeSTLVector_h_
Modified: lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h?rev=274683&r1=274682&r2=274683&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h Wed Jul 6 16:24:28 2016
@@ -17,6 +17,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/ThreadSafeSTLMap.h"
+#include "lldb/Core/ThreadSafeSTLVector.h"
#include "lldb/Core/ValueObject.h"
namespace lldb_private {
@@ -177,6 +178,7 @@ protected:
typedef ThreadSafeSTLMap<uint32_t, ValueObject*> ByIndexMap;
typedef ThreadSafeSTLMap<const char*, uint32_t> NameToIndexMap;
+ typedef ThreadSafeSTLVector<lldb::ValueObjectSP> SyntheticChildrenCache;
typedef ByIndexMap::iterator ByIndexIterator;
typedef NameToIndexMap::iterator NameToIndexIterator;
@@ -184,6 +186,7 @@ protected:
ByIndexMap m_children_byindex;
NameToIndexMap m_name_toindex;
uint32_t m_synthetic_children_count; // FIXME use the ValueObject's ChildrenManager instead of a special purpose solution
+ SyntheticChildrenCache m_synthetic_children_cache;
ConstString m_parent_type_name;
Modified: lldb/trunk/include/lldb/Utility/SharedCluster.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/SharedCluster.h?rev=274683&r1=274682&r2=274683&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/SharedCluster.h (original)
+++ lldb/trunk/include/lldb/Utility/SharedCluster.h Wed Jul 6 16:24:28 2016
@@ -10,6 +10,7 @@
#ifndef utility_SharedCluster_h_
#define utility_SharedCluster_h_
+#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/SharingPtr.h"
#include "llvm/ADT/SmallPtrSet.h"
@@ -75,7 +76,11 @@ public:
{
std::lock_guard<std::mutex> guard(m_mutex);
m_external_ref++;
- assert(m_objects.count(desired_object));
+ if (0 == m_objects.count(desired_object))
+ {
+ lldbassert(false && "object not found in shared cluster when expected");
+ desired_object = nullptr;
+ }
}
return typename lldb_private::SharingPtr<T>(desired_object, new imp::shared_ptr_refcount<ClusterManager>(this));
}
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=274683&r1=274682&r2=274683&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Jul 6 16:24:28 2016
@@ -2532,6 +2532,7 @@
940495791BEC497E00926025 /* NSException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NSException.cpp; path = Language/ObjC/NSException.cpp; sourceTree = "<group>"; };
94094C68163B6CCC0083A547 /* ValueObjectCast.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ValueObjectCast.h; path = include/lldb/Core/ValueObjectCast.h; sourceTree = "<group>"; };
94094C69163B6CD90083A547 /* ValueObjectCast.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectCast.cpp; path = source/Core/ValueObjectCast.cpp; sourceTree = "<group>"; };
+ 940B01FE1D2D82220058795E /* ThreadSafeSTLVector.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ThreadSafeSTLVector.h; path = include/lldb/Core/ThreadSafeSTLVector.h; sourceTree = "<group>"; };
940B02F419DC96CB00AD0F52 /* SBExecutionContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBExecutionContext.h; path = include/lldb/API/SBExecutionContext.h; sourceTree = "<group>"; };
940B02F519DC96E700AD0F52 /* SBExecutionContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBExecutionContext.cpp; path = source/API/SBExecutionContext.cpp; sourceTree = "<group>"; };
940B02F719DC970900AD0F52 /* SBExecutionContext.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBExecutionContext.i; sourceTree = "<group>"; };
@@ -4422,6 +4423,7 @@
AFEC3361194A8ABA00FF05C6 /* StructuredData.cpp */,
26B167A41123BF5500DC7B4F /* ThreadSafeValue.h */,
263FEDA5112CC1DA00E4C208 /* ThreadSafeSTLMap.h */,
+ 940B01FE1D2D82220058795E /* ThreadSafeSTLVector.h */,
26BC7D7E10F1B77400F91463 /* Timer.h */,
26BC7E9610F1B85900F91463 /* Timer.cpp */,
94ED54A119C8A822007BE2EA /* ThreadSafeDenseMap.h */,
Modified: lldb/trunk/scripts/interface/SBValue.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBValue.i?rev=274683&r1=274682&r2=274683&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBValue.i (original)
+++ lldb/trunk/scripts/interface/SBValue.i Wed Jul 6 16:24:28 2016
@@ -157,6 +157,12 @@ public:
bool
IsSynthetic ();
+
+ bool
+ IsSyntheticChildrenGenerated ();
+
+ void
+ SetSyntheticChildrenGenerated (bool);
const char *
GetLocation ();
@@ -533,6 +539,23 @@ public:
__swig_getmethods__["path"] = get_expr_path
if _newclass: path = property(get_expr_path, None, doc='''A read only property that returns the expression path that one can use to reach this value in an expression.''')
+
+ def synthetic_child_from_expression(self, name, expr, options=None):
+ if options is None: options = lldb.SBExpressionOptions()
+ child = self.CreateValueFromExpression(name, expr, options)
+ child.SetSyntheticChildrenGenerated(True)
+ return child
+
+ def synthetic_child_from_data(self, name, data, type):
+ child = self.CreateValueFromData(name, data, type)
+ child.SetSyntheticChildrenGenerated(True)
+ return child
+
+ def synthetic_child_from_address(self, name, addr, type):
+ child = self.CreateValueFromAddress(name, addr, type)
+ child.SetSyntheticChildrenGenerated(True)
+ return child
+
%}
};
Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=274683&r1=274682&r2=274683&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Wed Jul 6 16:24:28 2016
@@ -1145,6 +1145,25 @@ SBValue::IsSynthetic ()
return false;
}
+bool
+SBValue::IsSyntheticChildrenGenerated ()
+{
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp)
+ return value_sp->IsSyntheticChildrenGenerated();
+ return false;
+}
+
+void
+SBValue::SetSyntheticChildrenGenerated (bool is)
+{
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp)
+ return value_sp->SetSyntheticChildrenGenerated(is);
+}
+
lldb::SBValue
SBValue::GetValueForExpressionPath(const char* expr_path)
{
Modified: lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp?rev=274683&r1=274682&r2=274683&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp Wed Jul 6 16:24:28 2016
@@ -63,6 +63,7 @@ ValueObjectSynthetic::ValueObjectSynthet
m_children_byindex(),
m_name_toindex(),
m_synthetic_children_count(UINT32_MAX),
+ m_synthetic_children_cache(),
m_parent_type_name(parent.GetTypeName()),
m_might_have_children(eLazyBoolCalculate),
m_provides_value(eLazyBoolCalculate)
@@ -212,6 +213,7 @@ ValueObjectSynthetic::UpdateValue ()
// for a synthetic VO that might indeed happen, so we need to tell the upper echelons
// that they need to come back to us asking for children
m_children_count_valid = false;
+ m_synthetic_children_cache.Clear();
m_synthetic_children_count = UINT32_MAX;
m_might_have_children = eLazyBoolCalculate;
}
@@ -271,13 +273,17 @@ ValueObjectSynthetic::GetChildAtIndex (s
lldb::ValueObjectSP synth_guy = m_synth_filter_ap->GetChildAtIndex (idx);
if (log)
- log->Printf("[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at index %zu created as %p",
+ log->Printf("[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at index %zu created as %p (is synthetic: %s)",
GetName().AsCString(),
idx,
- synth_guy.get());
+ synth_guy.get(),
+ synth_guy.get() ? (synth_guy->IsSyntheticChildrenGenerated() ? "yes" : "no") : "no");
if (!synth_guy)
return synth_guy;
+
+ if (synth_guy->IsSyntheticChildrenGenerated())
+ m_synthetic_children_cache.AppendObject(synth_guy);
m_children_byindex.SetValueForKey(idx, synth_guy.get());
synth_guy->SetPreferredDisplayLanguageIfNeeded(GetPreferredDisplayLanguage());
return synth_guy;
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp?rev=274683&r1=274682&r2=274683&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp Wed Jul 6 16:24:28 2016
@@ -50,7 +50,6 @@ namespace lldb_private {
CompilerType m_element_type;
uint32_t m_element_size;
size_t m_num_elements;
- std::map<size_t,lldb::ValueObjectSP> m_children;
};
} // namespace formatters
} // namespace lldb_private
@@ -60,8 +59,7 @@ lldb_private::formatters::LibcxxInitiali
m_start(nullptr),
m_element_type(),
m_element_size(0),
- m_num_elements(0),
- m_children()
+ m_num_elements(0)
{
if (valobj_sp)
Update();
@@ -90,17 +88,11 @@ lldb_private::formatters::LibcxxInitiali
if (!m_start)
return lldb::ValueObjectSP();
- auto cached = m_children.find(idx);
- if (cached != m_children.end())
- return cached->second;
-
uint64_t offset = idx * m_element_size;
offset = offset + m_start->GetValueAsUnsigned(0);
StreamString name;
name.Printf("[%" PRIu64 "]", (uint64_t)idx);
- ValueObjectSP child_sp = CreateValueObjectFromAddress(name.GetData(), offset, m_backend.GetExecutionContextRef(), m_element_type);
- m_children[idx] = child_sp;
- return child_sp;
+ return CreateValueObjectFromAddress(name.GetData(), offset, m_backend.GetExecutionContextRef(), m_element_type);
}
bool
@@ -110,7 +102,6 @@ lldb_private::formatters::LibcxxInitiali
m_start = nullptr;
m_num_elements = 0;
- m_children.clear();
lldb::TemplateArgumentKind kind;
m_element_type = m_backend.GetCompilerType().GetTemplateArgument(0, kind);
if (kind != lldb::eTemplateArgumentKindType || !m_element_type.IsValid())
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp?rev=274683&r1=274682&r2=274683&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp Wed Jul 6 16:24:28 2016
@@ -200,7 +200,6 @@ namespace lldb_private {
ValueObject* m_tail;
CompilerType m_element_type;
size_t m_count;
- std::map<size_t,lldb::ValueObjectSP> m_children;
std::map<size_t, ListIterator> m_iterators;
};
} // namespace formatters
@@ -215,7 +214,6 @@ lldb_private::formatters::LibcxxStdListS
m_tail(nullptr),
m_element_type(),
m_count(UINT32_MAX),
- m_children(),
m_iterators()
{
if (valobj_sp)
@@ -312,10 +310,6 @@ lldb_private::formatters::LibcxxStdListS
if (!m_head || !m_tail || m_node_address == 0)
return lldb::ValueObjectSP();
- auto cached = m_children.find(idx);
- if (cached != m_children.end())
- return cached->second;
-
if (HasLoop(idx+1))
return lldb::ValueObjectSP();
@@ -350,13 +344,15 @@ lldb_private::formatters::LibcxxStdListS
StreamString name;
name.Printf("[%" PRIu64 "]", (uint64_t)idx);
- return (m_children[idx] = CreateValueObjectFromData(name.GetData(), data, m_backend.GetExecutionContextRef(), m_element_type));
+ return CreateValueObjectFromData(name.GetData(),
+ data,
+ m_backend.GetExecutionContextRef(),
+ m_element_type);
}
bool
lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::Update()
{
- m_children.clear();
m_iterators.clear();
m_head = m_tail = nullptr;
m_node_address = 0;
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp?rev=274683&r1=274682&r2=274683&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp Wed Jul 6 16:24:28 2016
@@ -246,7 +246,6 @@ namespace lldb_private {
CompilerType m_element_type;
uint32_t m_skip_size;
size_t m_count;
- std::map<size_t, lldb::ValueObjectSP> m_children;
std::map<size_t, MapIterator> m_iterators;
};
} // namespace formatters
@@ -259,7 +258,6 @@ lldb_private::formatters::LibcxxStdMapSy
m_element_type(),
m_skip_size(UINT32_MAX),
m_count(UINT32_MAX),
- m_children(),
m_iterators()
{
if (valobj_sp)
@@ -332,10 +330,6 @@ lldb_private::formatters::LibcxxStdMapSy
if (m_tree == nullptr || m_root_node == nullptr)
return lldb::ValueObjectSP();
- auto cached = m_children.find(idx);
- if (cached != m_children.end())
- return cached->second;
-
MapIterator iterator(m_root_node, CalculateNumChildren());
const bool need_to_skip = (idx > 0);
@@ -437,7 +431,7 @@ lldb_private::formatters::LibcxxStdMapSy
potential_child_sp->SetName(ConstString(name.GetData()));
}
m_iterators[idx] = iterator;
- return (m_children[idx] = potential_child_sp);
+ return potential_child_sp;
}
bool
@@ -447,7 +441,6 @@ lldb_private::formatters::LibcxxStdMapSy
static ConstString g___begin_node_("__begin_node_");
m_count = UINT32_MAX;
m_tree = m_root_node = nullptr;
- m_children.clear();
m_iterators.clear();
m_tree = m_backend.GetChildMemberWithName(g___tree_, true).get();
if (!m_tree)
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp?rev=274683&r1=274682&r2=274683&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp Wed Jul 6 16:24:28 2016
@@ -55,7 +55,6 @@ namespace lldb_private {
ValueObject* m_tree;
size_t m_num_elements;
ValueObject* m_next_element;
- std::map<size_t,lldb::ValueObjectSP> m_children;
std::vector<std::pair<ValueObject*, uint64_t> > m_elements_cache;
};
} // namespace formatters
@@ -66,7 +65,6 @@ lldb_private::formatters::LibcxxStdUnord
m_tree(nullptr),
m_num_elements(0),
m_next_element(nullptr),
- m_children(),
m_elements_cache()
{
if (valobj_sp)
@@ -89,10 +87,6 @@ lldb_private::formatters::LibcxxStdUnord
if (m_tree == nullptr)
return lldb::ValueObjectSP();
- auto cached = m_children.find(idx);
- if (cached != m_children.end())
- return cached->second;
-
while (idx >= m_elements_cache.size())
{
if (m_next_element == nullptr)
@@ -125,13 +119,10 @@ lldb_private::formatters::LibcxxStdUnord
return lldb::ValueObjectSP();
const bool thread_and_frame_only_if_stopped = true;
ExecutionContext exe_ctx = val_hash.first->GetExecutionContextRef().Lock(thread_and_frame_only_if_stopped);
- ValueObjectSP child_sp(val_hash.first->CreateValueObjectFromData(stream.GetData(),
- data,
- exe_ctx,
- val_hash.first->GetCompilerType()));
- if (child_sp)
- m_children.emplace(idx, child_sp);
- return child_sp;
+ return CreateValueObjectFromData(stream.GetData(),
+ data,
+ exe_ctx,
+ val_hash.first->GetCompilerType());
}
bool
@@ -140,7 +131,6 @@ lldb_private::formatters::LibcxxStdUnord
m_num_elements = UINT32_MAX;
m_next_element = nullptr;
m_elements_cache.clear();
- m_children.clear();
ValueObjectSP table_sp = m_backend.GetChildMemberWithName(ConstString("__table_"), true);
if (!table_sp)
return false;
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp?rev=274683&r1=274682&r2=274683&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp Wed Jul 6 16:24:28 2016
@@ -50,7 +50,6 @@ namespace lldb_private {
ValueObject* m_finish;
CompilerType m_element_type;
uint32_t m_element_size;
- std::map<size_t,lldb::ValueObjectSP> m_children;
};
} // namespace formatters
} // namespace lldb_private
@@ -60,8 +59,7 @@ lldb_private::formatters::LibcxxStdVecto
m_start(nullptr),
m_finish(nullptr),
m_element_type(),
- m_element_size(0),
- m_children()
+ m_element_size(0)
{
if (valobj_sp)
Update();
@@ -100,24 +98,20 @@ lldb_private::formatters::LibcxxStdVecto
if (!m_start || !m_finish)
return lldb::ValueObjectSP();
- auto cached = m_children.find(idx);
- if (cached != m_children.end())
- return cached->second;
-
uint64_t offset = idx * m_element_size;
offset = offset + m_start->GetValueAsUnsigned(0);
StreamString name;
name.Printf("[%" PRIu64 "]", (uint64_t)idx);
- ValueObjectSP child_sp = CreateValueObjectFromAddress(name.GetData(), offset, m_backend.GetExecutionContextRef(), m_element_type);
- m_children[idx] = child_sp;
- return child_sp;
+ return CreateValueObjectFromAddress(name.GetData(),
+ offset,
+ m_backend.GetExecutionContextRef(),
+ m_element_type);
}
bool
lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::Update()
{
m_start = m_finish = nullptr;
- m_children.clear();
ValueObjectSP data_type_finder_sp(m_backend.GetChildMemberWithName(ConstString("__end_cap_"),true));
if (!data_type_finder_sp)
return false;
Modified: lldb/trunk/source/Plugins/Language/ObjC/NSArray.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/NSArray.cpp?rev=274683&r1=274682&r2=274683&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/ObjC/NSArray.cpp (original)
+++ lldb/trunk/source/Plugins/Language/ObjC/NSArray.cpp Wed Jul 6 16:24:28 2016
@@ -87,7 +87,6 @@ namespace lldb_private {
ExecutionContextRef m_exe_ctx_ref;
uint8_t m_ptr_size;
CompilerType m_id_type;
- std::vector<lldb::ValueObjectSP> m_children;
};
class NSArrayMSyntheticFrontEnd_109 : public NSArrayMSyntheticFrontEnd
@@ -216,7 +215,6 @@ namespace lldb_private {
uint64_t m_items;
lldb::addr_t m_data_ptr;
CompilerType m_id_type;
- std::vector<lldb::ValueObjectSP> m_children;
};
class NSArray0SyntheticFrontEnd : public SyntheticChildrenFrontEnd
@@ -368,8 +366,7 @@ lldb_private::formatters::NSArrayMSynthe
SyntheticChildrenFrontEnd(*valobj_sp),
m_exe_ctx_ref(),
m_ptr_size(8),
-m_id_type(),
-m_children()
+m_id_type()
{
if (valobj_sp)
{
@@ -414,18 +411,15 @@ 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 = CreateValueObjectFromAddress(idx_name.GetData(),
- object_at_idx,
- m_exe_ctx_ref,
- m_id_type);
- m_children.push_back(retval_sp);
- return retval_sp;
+ return CreateValueObjectFromAddress(idx_name.GetData(),
+ object_at_idx,
+ m_exe_ctx_ref,
+ m_id_type);
}
bool
lldb_private::formatters::NSArrayMSyntheticFrontEnd_109::Update()
{
- m_children.clear();
ValueObjectSP valobj_sp = m_backend.GetSP();
m_ptr_size = 0;
delete m_data_32;
@@ -460,7 +454,6 @@ lldb_private::formatters::NSArrayMSynthe
bool
lldb_private::formatters::NSArrayMSyntheticFrontEnd_1010::Update()
{
- m_children.clear();
ValueObjectSP valobj_sp = m_backend.GetSP();
m_ptr_size = 0;
delete m_data_32;
@@ -637,7 +630,6 @@ lldb_private::formatters::NSArrayISynthe
m_ptr_size = 0;
m_items = 0;
m_data_ptr = 0;
- m_children.clear();
ValueObjectSP valobj_sp = m_backend.GetSP();
if (!valobj_sp)
return false;
@@ -677,12 +669,10 @@ lldb_private::formatters::NSArrayISynthe
return lldb::ValueObjectSP();
StreamString idx_name;
idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
- 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;
+ return CreateValueObjectFromAddress(idx_name.GetData(),
+ object_at_idx,
+ m_exe_ctx_ref,
+ m_id_type);
}
lldb_private::formatters::NSArray0SyntheticFrontEnd::NSArray0SyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
Modified: lldb/trunk/source/Plugins/Language/ObjC/NSError.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/NSError.cpp?rev=274683&r1=274682&r2=274683&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/ObjC/NSError.cpp (original)
+++ lldb/trunk/source/Plugins/Language/ObjC/NSError.cpp Wed Jul 6 16:24:28 2016
@@ -169,10 +169,10 @@ public:
if (userinfo == LLDB_INVALID_ADDRESS || error.Fail())
return false;
InferiorSizedWord isw(userinfo,*process_sp);
- m_child_sp = ValueObject::CreateValueObjectFromData("_userInfo",
- isw.GetAsData(process_sp->GetByteOrder()),
- m_backend.GetExecutionContextRef(),
- process_sp->GetTarget().GetScratchClangASTContext()->GetBasicType(lldb::eBasicTypeObjCID));
+ m_child_sp = CreateValueObjectFromData("_userInfo",
+ isw.GetAsData(process_sp->GetByteOrder()),
+ m_backend.GetExecutionContextRef(),
+ process_sp->GetTarget().GetScratchClangASTContext()->GetBasicType(lldb::eBasicTypeObjCID));
return false;
}
Modified: lldb/trunk/source/Plugins/Language/ObjC/NSException.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/NSException.cpp?rev=274683&r1=274682&r2=274683&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/ObjC/NSException.cpp (original)
+++ lldb/trunk/source/Plugins/Language/ObjC/NSException.cpp Wed Jul 6 16:24:28 2016
@@ -157,10 +157,10 @@ public:
if (userinfo == LLDB_INVALID_ADDRESS || error.Fail())
return false;
InferiorSizedWord isw(userinfo,*process_sp);
- m_child_sp = ValueObject::CreateValueObjectFromData("userInfo",
- isw.GetAsData(process_sp->GetByteOrder()),
- m_backend.GetExecutionContextRef(),
- process_sp->GetTarget().GetScratchClangASTContext()->GetBasicType(lldb::eBasicTypeObjCID));
+ m_child_sp = CreateValueObjectFromData("userInfo",
+ isw.GetAsData(process_sp->GetByteOrder()),
+ m_backend.GetExecutionContextRef(),
+ process_sp->GetTarget().GetScratchClangASTContext()->GetBasicType(lldb::eBasicTypeObjCID));
return false;
}
More information about the lldb-commits
mailing list