diff options
author | dim <dim@FreeBSD.org> | 2017-04-02 17:24:58 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2017-04-02 17:24:58 +0000 |
commit | 60b571e49a90d38697b3aca23020d9da42fc7d7f (patch) | |
tree | 99351324c24d6cb146b6285b6caffa4d26fce188 /contrib/llvm/tools/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp | |
parent | bea1b22c7a9bce1dfdd73e6e5b65bc4752215180 (diff) | |
download | FreeBSD-src-60b571e49a90d38697b3aca23020d9da42fc7d7f.zip FreeBSD-src-60b571e49a90d38697b3aca23020d9da42fc7d7f.tar.gz |
Update clang, llvm, lld, lldb, compiler-rt and libc++ to 4.0.0 release:
MFC r309142 (by emaste):
Add WITH_LLD_AS_LD build knob
If set it installs LLD as /usr/bin/ld. LLD (as of version 3.9) is not
capable of linking the world and kernel, but can self-host and link many
substantial applications. GNU ld continues to be used for the world and
kernel build, regardless of how this knob is set.
It is on by default for arm64, and off for all other CPU architectures.
Sponsored by: The FreeBSD Foundation
MFC r310840:
Reapply 310775, now it also builds correctly if lldb is disabled:
Move llvm-objdump from CLANG_EXTRAS to installed by default
We currently install three tools from binutils 2.17.50: as, ld, and
objdump. Work is underway to migrate to a permissively-licensed
tool-chain, with one goal being the retirement of binutils 2.17.50.
LLVM's llvm-objdump is intended to be compatible with GNU objdump
although it is currently missing some options and may have formatting
differences. Enable it by default for testing and further investigation.
It may later be changed to install as /usr/bin/objdump, it becomes a
fully viable replacement.
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D8879
MFC r312855 (by emaste):
Rename LLD_AS_LD to LLD_IS_LD, for consistency with CLANG_IS_CC
Reported by: Dan McGregor <dan.mcgregor usask.ca>
MFC r313559 | glebius | 2017-02-10 18:34:48 +0100 (Fri, 10 Feb 2017) | 5 lines
Don't check struct rtentry on FreeBSD, it is an internal kernel structure.
On other systems it may be API structure for SIOCADDRT/SIOCDELRT.
Reviewed by: emaste, dim
MFC r314152 (by jkim):
Remove an assembler flag, which is redundant since r309124. The upstream
took care of it by introducing a macro NO_EXEC_STACK_DIRECTIVE.
http://llvm.org/viewvc/llvm-project?rev=273500&view=rev
Reviewed by: dim
MFC r314564:
Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
4.0.0 (branches/release_40 296509). The release will follow soon.
Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11
support to build; see UPDATING for more information.
Also note that as of 4.0.0, lld should be able to link the base system
on amd64 and aarch64. See the WITH_LLD_IS_LLD setting in src.conf(5).
Though please be aware that this is work in progress.
Release notes for llvm, clang and lld will be available here:
<http://releases.llvm.org/4.0.0/docs/ReleaseNotes.html>
<http://releases.llvm.org/4.0.0/tools/clang/docs/ReleaseNotes.html>
<http://releases.llvm.org/4.0.0/tools/lld/docs/ReleaseNotes.html>
Thanks to Ed Maste, Jan Beich, Antoine Brodin and Eric Fiselier for
their help.
Relnotes: yes
Exp-run: antoine
PR: 215969, 216008
MFC r314708:
For now, revert r287232 from upstream llvm trunk (by Daniil Fukalov):
[SCEV] limit recursion depth of CompareSCEVComplexity
Summary:
CompareSCEVComplexity goes too deep (50+ on a quite a big unrolled
loop) and runs almost infinite time.
Added cache of "equal" SCEV pairs to earlier cutoff of further
estimation. Recursion depth limit was also introduced as a parameter.
Reviewers: sanjoy
Subscribers: mzolotukhin, tstellarAMD, llvm-commits
Differential Revision: https://reviews.llvm.org/D26389
This commit is the cause of excessive compile times on skein_block.c
(and possibly other files) during kernel builds on amd64.
We never saw the problematic behavior described in this upstream commit,
so for now it is better to revert it. An upstream bug has been filed
here: https://bugs.llvm.org/show_bug.cgi?id=32142
Reported by: mjg
MFC r314795:
Reapply r287232 from upstream llvm trunk (by Daniil Fukalov):
[SCEV] limit recursion depth of CompareSCEVComplexity
Summary:
CompareSCEVComplexity goes too deep (50+ on a quite a big unrolled
loop) and runs almost infinite time.
Added cache of "equal" SCEV pairs to earlier cutoff of further
estimation. Recursion depth limit was also introduced as a parameter.
Reviewers: sanjoy
Subscribers: mzolotukhin, tstellarAMD, llvm-commits
Differential Revision: https://reviews.llvm.org/D26389
Pull in r296992 from upstream llvm trunk (by Sanjoy Das):
[SCEV] Decrease the recursion threshold for CompareValueComplexity
Fixes PR32142.
r287232 accidentally increased the recursion threshold for
CompareValueComplexity from 2 to 32. This change reverses that
change by introducing a separate flag for CompareValueComplexity's
threshold.
The latter revision fixes the excessive compile times for skein_block.c.
MFC r314907 | mmel | 2017-03-08 12:40:27 +0100 (Wed, 08 Mar 2017) | 7 lines
Unbreak ARMv6 world.
The new compiler_rt library imported with clang 4.0.0 have several fatal
issues (non-functional __udivsi3 for example) with ARM specific instrict
functions. As temporary workaround, until upstream solve these problems,
disable all thumb[1][2] related feature.
MFC r315016:
Update clang, llvm, lld, lldb, compiler-rt and libc++ to 4.0.0 release.
We were already very close to the last release candidate, so this is a
pretty minor update.
Relnotes: yes
MFC r316005:
Revert r314907, and pull in r298713 from upstream compiler-rt trunk (by
Weiming Zhao):
builtins: Select correct code fragments when compiling for Thumb1/Thum2/ARM ISA.
Summary:
Value of __ARM_ARCH_ISA_THUMB isn't based on the actual compilation
mode (-mthumb, -marm), it reflect's capability of given CPU.
Due to this:
- use __tbumb__ and __thumb2__ insteand of __ARM_ARCH_ISA_THUMB
- use '.thumb' directive consistently in all affected files
- decorate all thumb functions using
DEFINE_COMPILERRT_THUMB_FUNCTION()
---------
Note: This patch doesn't fix broken Thumb1 variant of __udivsi3 !
Reviewers: weimingz, rengolin, compnerd
Subscribers: aemerson, dim
Differential Revision: https://reviews.llvm.org/D30938
Discussed with: mmel
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp')
-rw-r--r-- | contrib/llvm/tools/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp | 772 |
1 files changed, 379 insertions, 393 deletions
diff --git a/contrib/llvm/tools/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp b/contrib/llvm/tools/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp index d898692..759a700 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp +++ b/contrib/llvm/tools/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp @@ -1,4 +1,4 @@ -//===-- LibCxxList.cpp ------------------------------------------*- C++ -*-===// +//===-- LibCxxMap.cpp -------------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -27,442 +27,428 @@ using namespace lldb; using namespace lldb_private; using namespace lldb_private::formatters; -class MapEntry -{ +class MapEntry { public: - MapEntry() = default; - explicit MapEntry (ValueObjectSP entry_sp) : m_entry_sp(entry_sp) {} - MapEntry(const MapEntry& rhs) = default; - explicit MapEntry (ValueObject* entry) : m_entry_sp(entry ? entry->GetSP() : ValueObjectSP()) {} - - ValueObjectSP - left () const - { - static ConstString g_left("__left_"); - if (!m_entry_sp) - return m_entry_sp; - return m_entry_sp->GetChildMemberWithName(g_left, true); - } - - ValueObjectSP - right () const - { - static ConstString g_right("__right_"); - if (!m_entry_sp) - return m_entry_sp; - return m_entry_sp->GetChildMemberWithName(g_right, true); - } - - ValueObjectSP - parent () const - { - static ConstString g_parent("__parent_"); - if (!m_entry_sp) - return m_entry_sp; - return m_entry_sp->GetChildMemberWithName(g_parent, true); - } - - uint64_t - value () const - { - if (!m_entry_sp) - return 0; - return m_entry_sp->GetValueAsUnsigned(0); - } - - bool - error () const - { - if (!m_entry_sp) - return true; - return m_entry_sp->GetError().Fail(); - } - - bool - null() const - { - return (value() == 0); - } - - ValueObjectSP - GetEntry () const - { - return m_entry_sp; - } - - void - SetEntry (ValueObjectSP entry) - { - m_entry_sp = entry; - } - - bool - operator == (const MapEntry& rhs) const - { - return (rhs.m_entry_sp.get() == m_entry_sp.get()); - } - + MapEntry() = default; + explicit MapEntry(ValueObjectSP entry_sp) : m_entry_sp(entry_sp) {} + MapEntry(const MapEntry &rhs) = default; + explicit MapEntry(ValueObject *entry) + : m_entry_sp(entry ? entry->GetSP() : ValueObjectSP()) {} + + ValueObjectSP left() const { + static ConstString g_left("__left_"); + if (!m_entry_sp) + return m_entry_sp; + return m_entry_sp->GetSyntheticChildAtOffset( + 0, m_entry_sp->GetCompilerType(), true); + } + + ValueObjectSP right() const { + static ConstString g_right("__right_"); + if (!m_entry_sp) + return m_entry_sp; + return m_entry_sp->GetSyntheticChildAtOffset( + m_entry_sp->GetProcessSP()->GetAddressByteSize(), + m_entry_sp->GetCompilerType(), true); + } + + ValueObjectSP parent() const { + static ConstString g_parent("__parent_"); + if (!m_entry_sp) + return m_entry_sp; + return m_entry_sp->GetSyntheticChildAtOffset( + 2 * m_entry_sp->GetProcessSP()->GetAddressByteSize(), + m_entry_sp->GetCompilerType(), true); + } + + uint64_t value() const { + if (!m_entry_sp) + return 0; + return m_entry_sp->GetValueAsUnsigned(0); + } + + bool error() const { + if (!m_entry_sp) + return true; + return m_entry_sp->GetError().Fail(); + } + + bool null() const { return (value() == 0); } + + ValueObjectSP GetEntry() const { return m_entry_sp; } + + void SetEntry(ValueObjectSP entry) { m_entry_sp = entry; } + + bool operator==(const MapEntry &rhs) const { + return (rhs.m_entry_sp.get() == m_entry_sp.get()); + } + private: - ValueObjectSP m_entry_sp; + ValueObjectSP m_entry_sp; }; -class MapIterator -{ +class MapIterator { public: - MapIterator() = default; - MapIterator (MapEntry entry, size_t depth = 0) : m_entry(entry), m_max_depth(depth), m_error(false) {} - MapIterator (ValueObjectSP entry, size_t depth = 0) : m_entry(entry), m_max_depth(depth), m_error(false) {} - MapIterator (const MapIterator& rhs) : m_entry(rhs.m_entry),m_max_depth(rhs.m_max_depth), m_error(false) {} - MapIterator (ValueObject* entry, size_t depth = 0) : m_entry(entry), m_max_depth(depth), m_error(false) {} - - ValueObjectSP - value () - { - return m_entry.GetEntry(); - } - - ValueObjectSP - advance (size_t count) - { - ValueObjectSP fail; - if (m_error) - return fail; - size_t steps = 0; - while (count > 0) - { - next(); - count--, steps++; - if (m_error || - m_entry.null() || - (steps > m_max_depth)) - return fail; - } - return m_entry.GetEntry(); + MapIterator() = default; + MapIterator(MapEntry entry, size_t depth = 0) + : m_entry(entry), m_max_depth(depth), m_error(false) {} + MapIterator(ValueObjectSP entry, size_t depth = 0) + : m_entry(entry), m_max_depth(depth), m_error(false) {} + MapIterator(const MapIterator &rhs) + : m_entry(rhs.m_entry), m_max_depth(rhs.m_max_depth), m_error(false) {} + MapIterator(ValueObject *entry, size_t depth = 0) + : m_entry(entry), m_max_depth(depth), m_error(false) {} + + ValueObjectSP value() { return m_entry.GetEntry(); } + + ValueObjectSP advance(size_t count) { + ValueObjectSP fail; + if (m_error) + return fail; + size_t steps = 0; + while (count > 0) { + next(); + count--, steps++; + if (m_error || m_entry.null() || (steps > m_max_depth)) + return fail; } - + return m_entry.GetEntry(); + } + protected: - void - next () - { - if (m_entry.null()) - return; - MapEntry right(m_entry.right()); - if (!right.null()) - { - m_entry = tree_min(std::move(right)); - return; - } - size_t steps = 0; - while (!is_left_child(m_entry)) - { - if (m_entry.error()) - { - m_error = true; - return; - } - m_entry.SetEntry(m_entry.parent()); - steps++; - if (steps > m_max_depth) - { - m_entry = MapEntry(); - return; - } - } - m_entry = MapEntry(m_entry.parent()); + void next() { + if (m_entry.null()) + return; + MapEntry right(m_entry.right()); + if (!right.null()) { + m_entry = tree_min(std::move(right)); + return; } - -private: - MapEntry - tree_min (MapEntry&& x) - { - if (x.null()) - return MapEntry(); - MapEntry left(x.left()); - size_t steps = 0; - while (!left.null()) - { - if (left.error()) - { - m_error = true; - return MapEntry(); - } - x = left; - left.SetEntry(x.left()); - steps++; - if (steps > m_max_depth) - return MapEntry(); - } - return x; + size_t steps = 0; + while (!is_left_child(m_entry)) { + if (m_entry.error()) { + m_error = true; + return; + } + m_entry.SetEntry(m_entry.parent()); + steps++; + if (steps > m_max_depth) { + m_entry = MapEntry(); + return; + } } - - bool - is_left_child (const MapEntry& x) - { - if (x.null()) - return false; - MapEntry rhs(x.parent()); - rhs.SetEntry(rhs.left()); - return x.value() == rhs.value(); + m_entry = MapEntry(m_entry.parent()); + } + +private: + MapEntry tree_min(MapEntry &&x) { + if (x.null()) + return MapEntry(); + MapEntry left(x.left()); + size_t steps = 0; + while (!left.null()) { + if (left.error()) { + m_error = true; + return MapEntry(); + } + x = left; + left.SetEntry(x.left()); + steps++; + if (steps > m_max_depth) + return MapEntry(); } - - MapEntry m_entry; - size_t m_max_depth; - bool m_error; + return x; + } + + bool is_left_child(const MapEntry &x) { + if (x.null()) + return false; + MapEntry rhs(x.parent()); + rhs.SetEntry(rhs.left()); + return x.value() == rhs.value(); + } + + MapEntry m_entry; + size_t m_max_depth; + bool m_error; }; namespace lldb_private { - namespace formatters { - class LibcxxStdMapSyntheticFrontEnd : public SyntheticChildrenFrontEnd - { - public: - LibcxxStdMapSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp); - - ~LibcxxStdMapSyntheticFrontEnd() override = default; - - size_t - CalculateNumChildren() override; - - lldb::ValueObjectSP - GetChildAtIndex(size_t idx) override; - - bool - Update() override; - - bool - MightHaveChildren() override; - - size_t - GetIndexOfChildWithName(const ConstString &name) override; - - private: - bool - GetDataType(); - - void - GetValueOffset (const lldb::ValueObjectSP& node); - - ValueObject* m_tree; - ValueObject* m_root_node; - CompilerType m_element_type; - uint32_t m_skip_size; - size_t m_count; - std::map<size_t, MapIterator> m_iterators; - }; - } // namespace formatters +namespace formatters { +class LibcxxStdMapSyntheticFrontEnd : public SyntheticChildrenFrontEnd { +public: + LibcxxStdMapSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); + + ~LibcxxStdMapSyntheticFrontEnd() override = default; + + size_t CalculateNumChildren() override; + + lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; + + bool Update() override; + + bool MightHaveChildren() override; + + size_t GetIndexOfChildWithName(const ConstString &name) override; + +private: + bool GetDataType(); + + void GetValueOffset(const lldb::ValueObjectSP &node); + + ValueObject *m_tree; + ValueObject *m_root_node; + CompilerType m_element_type; + uint32_t m_skip_size; + size_t m_count; + std::map<size_t, MapIterator> m_iterators; +}; +} // namespace formatters } // namespace lldb_private -lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::LibcxxStdMapSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) : - SyntheticChildrenFrontEnd(*valobj_sp), - m_tree(nullptr), - m_root_node(nullptr), - m_element_type(), - m_skip_size(UINT32_MAX), - m_count(UINT32_MAX), - m_iterators() -{ - if (valobj_sp) - Update(); +lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd:: + LibcxxStdMapSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) + : SyntheticChildrenFrontEnd(*valobj_sp), m_tree(nullptr), + m_root_node(nullptr), m_element_type(), m_skip_size(UINT32_MAX), + m_count(UINT32_MAX), m_iterators() { + if (valobj_sp) + Update(); } -size_t -lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::CalculateNumChildren () -{ - static ConstString g___pair3_("__pair3_"); - static ConstString g___first_("__first_"); - - if (m_count != UINT32_MAX) - return m_count; - if (m_tree == nullptr) - return 0; - ValueObjectSP m_item(m_tree->GetChildMemberWithName(g___pair3_, true)); - if (!m_item) - return 0; - m_item = m_item->GetChildMemberWithName(g___first_, true); - if (!m_item) - return 0; - m_count = m_item->GetValueAsUnsigned(0); +size_t lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd:: + CalculateNumChildren() { + static ConstString g___pair3_("__pair3_"); + static ConstString g___first_("__first_"); + + if (m_count != UINT32_MAX) return m_count; + if (m_tree == nullptr) + return 0; + ValueObjectSP m_item(m_tree->GetChildMemberWithName(g___pair3_, true)); + if (!m_item) + return 0; + m_item = m_item->GetChildMemberWithName(g___first_, true); + if (!m_item) + return 0; + m_count = m_item->GetValueAsUnsigned(0); + return m_count; } -bool -lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetDataType() -{ - static ConstString g___value_("__value_"); - - if (m_element_type.GetOpaqueQualType() && m_element_type.GetTypeSystem()) - return true; - m_element_type.Clear(); - ValueObjectSP deref; - Error error; - deref = m_root_node->Dereference(error); - if (!deref || error.Fail()) - return false; - deref = deref->GetChildMemberWithName(g___value_, true); - if (!deref) - return false; +bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetDataType() { + static ConstString g___value_("__value_"); + static ConstString g_tree_("__tree_"); + static ConstString g_pair3("__pair3_"); + + if (m_element_type.GetOpaqueQualType() && m_element_type.GetTypeSystem()) + return true; + m_element_type.Clear(); + ValueObjectSP deref; + Error error; + deref = m_root_node->Dereference(error); + if (!deref || error.Fail()) + return false; + deref = deref->GetChildMemberWithName(g___value_, true); + if (deref) { m_element_type = deref->GetCompilerType(); return true; + } + lldb::TemplateArgumentKind kind; + deref = m_backend.GetChildAtNamePath({g_tree_, g_pair3}); + if (!deref) + return false; + m_element_type = + deref->GetCompilerType().GetTemplateArgument(1, kind).GetTemplateArgument( + 1, kind); + if (m_element_type) { + std::string name; + uint64_t bit_offset_ptr; + uint32_t bitfield_bit_size_ptr; + bool is_bitfield_ptr; + m_element_type = m_element_type.GetFieldAtIndex( + 0, name, &bit_offset_ptr, &bitfield_bit_size_ptr, &is_bitfield_ptr); + m_element_type = m_element_type.GetTypedefedType(); + return m_element_type.IsValid(); + } else { + m_element_type = m_backend.GetCompilerType().GetTemplateArgument(0, kind); + return m_element_type.IsValid(); + } } -void -lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetValueOffset (const lldb::ValueObjectSP& node) -{ - if (m_skip_size != UINT32_MAX) - return; - if (!node) - return; - CompilerType node_type(node->GetCompilerType()); - uint64_t bit_offset; - if (node_type.GetIndexOfFieldWithName("__value_", nullptr, &bit_offset) == UINT32_MAX) - return; +void lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetValueOffset( + const lldb::ValueObjectSP &node) { + if (m_skip_size != UINT32_MAX) + return; + if (!node) + return; + CompilerType node_type(node->GetCompilerType()); + uint64_t bit_offset; + if (node_type.GetIndexOfFieldWithName("__value_", nullptr, &bit_offset) != + UINT32_MAX) { m_skip_size = bit_offset / 8u; + } else { + ClangASTContext *ast_ctx = + llvm::dyn_cast_or_null<ClangASTContext>(node_type.GetTypeSystem()); + if (!ast_ctx) + return; + CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier( + ConstString(), + {{"ptr0", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, + {"ptr1", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, + {"ptr2", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, + {"cw", ast_ctx->GetBasicType(lldb::eBasicTypeBool)}, + {"payload", (m_element_type.GetCompleteType(), m_element_type)}}); + std::string child_name; + uint32_t child_byte_size; + int32_t child_byte_offset = 0; + uint32_t child_bitfield_bit_size; + uint32_t child_bitfield_bit_offset; + bool child_is_base_class; + bool child_is_deref_of_parent; + uint64_t language_flags; + if (tree_node_type + .GetChildCompilerTypeAtIndex( + nullptr, 4, true, true, true, child_name, child_byte_size, + child_byte_offset, child_bitfield_bit_size, + child_bitfield_bit_offset, child_is_base_class, + child_is_deref_of_parent, nullptr, language_flags) + .IsValid()) + m_skip_size = (uint32_t)child_byte_offset; + } } lldb::ValueObjectSP -lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex (size_t idx) -{ - static ConstString g___cc("__cc"); - static ConstString g___nc("__nc"); - static ConstString g___value_("__value_"); +lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex( + size_t idx) { + static ConstString g___cc("__cc"); + static ConstString g___nc("__nc"); + static ConstString g___value_("__value_"); + + if (idx >= CalculateNumChildren()) + return lldb::ValueObjectSP(); + if (m_tree == nullptr || m_root_node == nullptr) + return lldb::ValueObjectSP(); + + MapIterator iterator(m_root_node, CalculateNumChildren()); - if (idx >= CalculateNumChildren()) + const bool need_to_skip = (idx > 0); + size_t actual_advancde = idx; + if (need_to_skip) { + auto cached_iterator = m_iterators.find(idx - 1); + if (cached_iterator != m_iterators.end()) { + iterator = cached_iterator->second; + actual_advancde = 1; + } + } + + ValueObjectSP iterated_sp(iterator.advance(actual_advancde)); + if (!iterated_sp) { + // this tree is garbage - stop + m_tree = + nullptr; // this will stop all future searches until an Update() happens + return iterated_sp; + } + if (GetDataType()) { + if (!need_to_skip) { + Error error; + iterated_sp = iterated_sp->Dereference(error); + if (!iterated_sp || error.Fail()) { + m_tree = nullptr; return lldb::ValueObjectSP(); - if (m_tree == nullptr || m_root_node == nullptr) + } + GetValueOffset(iterated_sp); + auto child_sp = iterated_sp->GetChildMemberWithName(g___value_, true); + if (child_sp) + iterated_sp = child_sp; + else + iterated_sp = iterated_sp->GetSyntheticChildAtOffset( + m_skip_size, m_element_type, true); + if (!iterated_sp) { + m_tree = nullptr; return lldb::ValueObjectSP(); - - MapIterator iterator(m_root_node, CalculateNumChildren()); - - const bool need_to_skip = (idx > 0); - size_t actual_advancde = idx; - if (need_to_skip) - { - auto cached_iterator = m_iterators.find(idx-1); - if (cached_iterator != m_iterators.end()) - { - iterator = cached_iterator->second; - actual_advancde = 1; - } - } - - ValueObjectSP iterated_sp(iterator.advance(actual_advancde)); - if (!iterated_sp) - { - // this tree is garbage - stop - m_tree = nullptr; // this will stop all future searches until an Update() happens - return iterated_sp; - } - if (GetDataType()) - { - if (!need_to_skip) - { - Error error; - iterated_sp = iterated_sp->Dereference(error); - if (!iterated_sp || error.Fail()) - { - m_tree = nullptr; - return lldb::ValueObjectSP(); - } - GetValueOffset(iterated_sp); - iterated_sp = iterated_sp->GetChildMemberWithName(g___value_, true); - if (!iterated_sp) - { - m_tree = nullptr; - return lldb::ValueObjectSP(); - } - } - else - { - // because of the way our debug info is made, we need to read item 0 first - // so that we can cache information used to generate other elements - if (m_skip_size == UINT32_MAX) - GetChildAtIndex(0); - if (m_skip_size == UINT32_MAX) - { - m_tree = nullptr; - return lldb::ValueObjectSP(); - } - iterated_sp = iterated_sp->GetSyntheticChildAtOffset(m_skip_size, m_element_type, true); - if (!iterated_sp) - { - m_tree = nullptr; - return lldb::ValueObjectSP(); - } - } - } - else - { + } + } else { + // because of the way our debug info is made, we need to read item 0 first + // so that we can cache information used to generate other elements + if (m_skip_size == UINT32_MAX) + GetChildAtIndex(0); + if (m_skip_size == UINT32_MAX) { m_tree = nullptr; return lldb::ValueObjectSP(); - } - // at this point we have a valid - // we need to copy current_sp into a new object otherwise we will end up with all items named __value_ - DataExtractor data; - Error error; - iterated_sp->GetData(data, error); - if (error.Fail()) - { + } + iterated_sp = iterated_sp->GetSyntheticChildAtOffset( + m_skip_size, m_element_type, true); + if (!iterated_sp) { m_tree = nullptr; return lldb::ValueObjectSP(); + } } - StreamString name; - name.Printf("[%" PRIu64 "]", (uint64_t)idx); - auto potential_child_sp = CreateValueObjectFromData(name.GetData(), data, m_backend.GetExecutionContextRef(), m_element_type); - if (potential_child_sp) - { - switch (potential_child_sp->GetNumChildren()) - { - case 1: - { - auto child0_sp = potential_child_sp->GetChildAtIndex(0, true); - if (child0_sp && child0_sp->GetName() == g___cc) - potential_child_sp = child0_sp; - break; - } - case 2: - { - auto child0_sp = potential_child_sp->GetChildAtIndex(0, true); - auto child1_sp = potential_child_sp->GetChildAtIndex(1, true); - if (child0_sp && child0_sp->GetName() == g___cc && - child1_sp && child1_sp->GetName() == g___nc) - potential_child_sp = child0_sp; - break; - } - } - potential_child_sp->SetName(ConstString(name.GetData())); + } else { + m_tree = nullptr; + return lldb::ValueObjectSP(); + } + // at this point we have a valid + // we need to copy current_sp into a new object otherwise we will end up with + // all items named __value_ + DataExtractor data; + Error error; + iterated_sp->GetData(data, error); + if (error.Fail()) { + m_tree = nullptr; + return lldb::ValueObjectSP(); + } + StreamString name; + name.Printf("[%" PRIu64 "]", (uint64_t)idx); + auto potential_child_sp = CreateValueObjectFromData( + name.GetString(), data, m_backend.GetExecutionContextRef(), + m_element_type); + if (potential_child_sp) { + switch (potential_child_sp->GetNumChildren()) { + case 1: { + auto child0_sp = potential_child_sp->GetChildAtIndex(0, true); + if (child0_sp && child0_sp->GetName() == g___cc) + potential_child_sp = child0_sp; + break; } - m_iterators[idx] = iterator; - return potential_child_sp; + case 2: { + auto child0_sp = potential_child_sp->GetChildAtIndex(0, true); + auto child1_sp = potential_child_sp->GetChildAtIndex(1, true); + if (child0_sp && child0_sp->GetName() == g___cc && child1_sp && + child1_sp->GetName() == g___nc) + potential_child_sp = child0_sp; + break; + } + } + potential_child_sp->SetName(ConstString(name.GetString())); + } + m_iterators[idx] = iterator; + return potential_child_sp; } -bool -lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::Update() -{ - static ConstString g___tree_("__tree_"); - static ConstString g___begin_node_("__begin_node_"); - m_count = UINT32_MAX; - m_tree = m_root_node = nullptr; - m_iterators.clear(); - m_tree = m_backend.GetChildMemberWithName(g___tree_, true).get(); - if (!m_tree) - return false; - m_root_node = m_tree->GetChildMemberWithName(g___begin_node_, true).get(); +bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::Update() { + static ConstString g___tree_("__tree_"); + static ConstString g___begin_node_("__begin_node_"); + m_count = UINT32_MAX; + m_tree = m_root_node = nullptr; + m_iterators.clear(); + m_tree = m_backend.GetChildMemberWithName(g___tree_, true).get(); + if (!m_tree) return false; + m_root_node = m_tree->GetChildMemberWithName(g___begin_node_, true).get(); + return false; } -bool -lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::MightHaveChildren () -{ - return true; +bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd:: + MightHaveChildren() { + return true; } -size_t -lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name) -{ - return ExtractIndexFromString(name.GetCString()); +size_t lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd:: + GetIndexOfChildWithName(const ConstString &name) { + return ExtractIndexFromString(name.GetCString()); } -SyntheticChildrenFrontEnd* -lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp) -{ - return (valobj_sp ? new LibcxxStdMapSyntheticFrontEnd(valobj_sp) : nullptr); +SyntheticChildrenFrontEnd * +lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator( + CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) { + return (valobj_sp ? new LibcxxStdMapSyntheticFrontEnd(valobj_sp) : nullptr); } |