diff options
author | Enrico Granata <egranata@apple.com> | 2016-07-06 21:24:28 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2016-07-06 21:24:28 +0000 |
commit | 106aae51083a9c389f050ca0491ba1c291059a23 (patch) | |
tree | 7ff417838e3a0d4361a3d7c589a15df2456da94d /lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp | |
parent | 710c13167f2b1d37bf95487841bbc7a7034bdfd8 (diff) | |
download | bcm5719-llvm-106aae51083a9c389f050ca0491ba1c291059a23.tar.gz bcm5719-llvm-106aae51083a9c389f050ca0491ba1c291059a23.zip |
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
llvm-svn: 274683
Diffstat (limited to 'lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp')
-rw-r--r-- | lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp index b39ea51d193..ed26eaea121 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp @@ -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::LibcxxStdVectorSyntheticFrontEnd::LibcxxStdVectorSynth 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::LibcxxStdVectorSyntheticFrontEnd::GetChildAtIndex (siz 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; |