Author: Michael Buch Date: 2024-02-08T11:09:45Z New Revision: d7fb94b6daa643a764e9a756bc544f26c248dafd
URL: https://github.com/llvm/llvm-project/commit/d7fb94b6daa643a764e9a756bc544f26c248dafd DIFF: https://github.com/llvm/llvm-project/commit/d7fb94b6daa643a764e9a756bc544f26c248dafd.diff LOG: [lldb][TypeSynthetic][NFC] Make SyntheticChildrenFrontend::Update() return an enum (#80167) This patch changes the return value of `SyntheticChildrenFrontend::Update` to a scoped enum that aims to describe what the return value means. Added: Modified: lldb/include/lldb/DataFormatters/TypeSynthetic.h lldb/include/lldb/DataFormatters/VectorIterator.h lldb/include/lldb/lldb-enumerations.h lldb/source/Core/ValueObjectSyntheticFilter.cpp lldb/source/DataFormatters/TypeSynthetic.cpp lldb/source/DataFormatters/VectorType.cpp lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp lldb/source/Plugins/Language/CPlusPlus/Coroutines.h lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxx.h lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxRangesRefView.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxSpan.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp lldb/source/Plugins/Language/ObjC/Cocoa.cpp lldb/source/Plugins/Language/ObjC/NSArray.cpp lldb/source/Plugins/Language/ObjC/NSDictionary.cpp lldb/source/Plugins/Language/ObjC/NSError.cpp lldb/source/Plugins/Language/ObjC/NSException.cpp lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp lldb/source/Plugins/Language/ObjC/NSSet.cpp Removed: ################################################################################ diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h b/lldb/include/lldb/DataFormatters/TypeSynthetic.h index 41be9b7efda8fd..23cc054b399a67 100644 --- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h +++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h @@ -49,14 +49,15 @@ class SyntheticChildrenFrontEnd { virtual size_t GetIndexOfChildWithName(ConstString name) = 0; - // this function is assumed to always succeed and it if fails, the front-end - // should know to deal with it in the correct way (most probably, by refusing - // to return any children) the return value of Update() should actually be - // interpreted as "ValueObjectSyntheticFilter cache is good/bad" if =true, - // ValueObjectSyntheticFilter is allowed to use the children it fetched - // previously and cached if =false, ValueObjectSyntheticFilter must throw - // away its cache, and query again for children - virtual bool Update() = 0; + /// This function is assumed to always succeed and if it fails, the front-end + /// should know to deal with it in the correct way (most probably, by refusing + /// to return any children). The return value of \ref Update should actually + /// be interpreted as "ValueObjectSyntheticFilter cache is good/bad". If this + /// function returns \ref lldb::ChildCacheState::eReuse, \ref + /// ValueObjectSyntheticFilter is allowed to use the children it fetched + /// previously and cached. Otherwise, \ref ValueObjectSyntheticFilter must + /// throw away its cache, and query again for children. + virtual lldb::ChildCacheState Update() = 0; // if this function returns false, then CalculateNumChildren() MUST return 0 // since UI frontends might validly decide not to inquire for children given @@ -116,7 +117,9 @@ class SyntheticValueProviderFrontEnd : public SyntheticChildrenFrontEnd { return UINT32_MAX; } - bool Update() override { return false; } + lldb::ChildCacheState Update() override { + return lldb::ChildCacheState::eRefetch; + } bool MightHaveChildren() override { return false; } @@ -328,7 +331,9 @@ class TypeFilterImpl : public SyntheticChildren { filter->GetExpressionPathAtIndex(idx), true); } - bool Update() override { return false; } + lldb::ChildCacheState Update() override { + return lldb::ChildCacheState::eRefetch; + } bool MightHaveChildren() override { return filter->GetCount() > 0; } @@ -427,7 +432,7 @@ class ScriptedSyntheticChildren : public SyntheticChildren { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; diff --git a/lldb/include/lldb/DataFormatters/VectorIterator.h b/lldb/include/lldb/DataFormatters/VectorIterator.h index 3414298f255b6a..5f774bb72c3a3a 100644 --- a/lldb/include/lldb/DataFormatters/VectorIterator.h +++ b/lldb/include/lldb/DataFormatters/VectorIterator.h @@ -28,7 +28,7 @@ class VectorIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index 392d333c23a447..7e9b538aa8372b 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -1305,6 +1305,15 @@ enum CompletionType { eTerminatorCompletion = (1ul << 27) }; +/// Specifies if children need to be re-computed +/// after a call to \ref SyntheticChildrenFrontEnd::Update. +enum class ChildCacheState { + eRefetch = 0, ///< Children need to be recomputed dynamically. + + eReuse = 1, ///< Children did not change and don't need to be recomputed; + ///< re-use what we computed the last time we called Update. +}; + } // namespace lldb #endif // LLDB_LLDB_ENUMERATIONS_H diff --git a/lldb/source/Core/ValueObjectSyntheticFilter.cpp b/lldb/source/Core/ValueObjectSyntheticFilter.cpp index 43bc532c4a0410..e8b4b02d11a0bb 100644 --- a/lldb/source/Core/ValueObjectSyntheticFilter.cpp +++ b/lldb/source/Core/ValueObjectSyntheticFilter.cpp @@ -43,7 +43,9 @@ class DummySyntheticFrontEnd : public SyntheticChildrenFrontEnd { bool MightHaveChildren() override { return m_backend.MightHaveChildren(); } - bool Update() override { return false; } + lldb::ChildCacheState Update() override { + return lldb::ChildCacheState::eRefetch; + } }; ValueObjectSynthetic::ValueObjectSynthetic(ValueObject &parent, @@ -177,7 +179,7 @@ bool ValueObjectSynthetic::UpdateValue() { } // let our backend do its update - if (!m_synth_filter_up->Update()) { + if (m_synth_filter_up->Update() == lldb::ChildCacheState::eRefetch) { LLDB_LOGF(log, "[ValueObjectSynthetic::UpdateValue] name=%s, synthetic " "filter said caches are stale - clearing", diff --git a/lldb/source/DataFormatters/TypeSynthetic.cpp b/lldb/source/DataFormatters/TypeSynthetic.cpp index de042e474903e5..8a6f132a39577a 100644 --- a/lldb/source/DataFormatters/TypeSynthetic.cpp +++ b/lldb/source/DataFormatters/TypeSynthetic.cpp @@ -190,11 +190,13 @@ size_t ScriptedSyntheticChildren::FrontEnd::CalculateNumChildren(uint32_t max) { return m_interpreter->CalculateNumChildren(m_wrapper_sp, max); } -bool ScriptedSyntheticChildren::FrontEnd::Update() { +lldb::ChildCacheState ScriptedSyntheticChildren::FrontEnd::Update() { if (!m_wrapper_sp || m_interpreter == nullptr) - return false; + return lldb::ChildCacheState::eRefetch; - return m_interpreter->UpdateSynthProviderInstance(m_wrapper_sp); + return m_interpreter->UpdateSynthProviderInstance(m_wrapper_sp) + ? lldb::ChildCacheState::eReuse + : lldb::ChildCacheState::eRefetch; } bool ScriptedSyntheticChildren::FrontEnd::MightHaveChildren() { diff --git a/lldb/source/DataFormatters/VectorType.cpp b/lldb/source/DataFormatters/VectorType.cpp index 57dae0b2c71f0f..c94ca68319ee2c 100644 --- a/lldb/source/DataFormatters/VectorType.cpp +++ b/lldb/source/DataFormatters/VectorType.cpp @@ -245,7 +245,7 @@ class VectorTypeSyntheticFrontEnd : public SyntheticChildrenFrontEnd { return child_sp; } - bool Update() override { + lldb::ChildCacheState Update() override { m_parent_format = m_backend.GetFormat(); CompilerType parent_type(m_backend.GetCompilerType()); CompilerType element_type; @@ -258,7 +258,7 @@ class VectorTypeSyntheticFrontEnd : public SyntheticChildrenFrontEnd { ::CalculateNumChildren(element_type, num_elements, m_child_type) .value_or(0); m_item_format = GetItemFormatForFormat(m_parent_format, m_child_type); - return false; + return lldb::ChildCacheState::eRefetch; } bool MightHaveChildren() override { return true; } diff --git a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp index 314a4aca8d2663..2e43aa3fa1d8bf 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp @@ -136,7 +136,9 @@ class BlockPointerSyntheticFrontEnd : public SyntheticChildrenFrontEnd { // return true if this object is now safe to use forever without ever // updating again; the typical (and tested) answer here is 'false' - bool Update() override { return false; } + lldb::ChildCacheState Update() override { + return lldb::ChildCacheState::eRefetch; + } // maybe return false if the block pointer is, say, null bool MightHaveChildren() override { return true; } diff --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp index 6aeae97667c168..742017438bcf4a 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp @@ -125,24 +125,24 @@ lldb::ValueObjectSP lldb_private::formatters:: return lldb::ValueObjectSP(); } -bool lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd:: - Update() { +lldb::ChildCacheState +lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::Update() { m_resume_ptr_sp.reset(); m_destroy_ptr_sp.reset(); m_promise_ptr_sp.reset(); ValueObjectSP valobj_sp = m_backend.GetNonSyntheticValue(); if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; lldb::addr_t frame_ptr_addr = GetCoroFramePtrFromHandle(valobj_sp); if (frame_ptr_addr == 0 || frame_ptr_addr == LLDB_INVALID_ADDRESS) - return false; + return lldb::ChildCacheState::eRefetch; auto ts = valobj_sp->GetCompilerType().GetTypeSystem(); auto ast_ctx = ts.dyn_cast_or_null<TypeSystemClang>(); if (!ast_ctx) - return false; + return lldb::ChildCacheState::eRefetch; // Create the `resume` and `destroy` children. lldb::TargetSP target_sp = m_backend.GetTargetSP(); @@ -165,7 +165,7 @@ bool lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd:: CompilerType promise_type( valobj_sp->GetCompilerType().GetTypeTemplateArgument(0)); if (!promise_type) - return false; + return lldb::ChildCacheState::eRefetch; // Try to infer the promise_type if it was type-erased if (promise_type.IsVoidType()) { @@ -180,7 +180,7 @@ bool lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd:: // If we don't know the promise type, we don't display the `promise` member. // `CreateValueObjectFromAddress` below would fail for `void` types. if (promise_type.IsVoidType()) { - return false; + return lldb::ChildCacheState::eRefetch; } // Add the `promise` member. We intentionally add `promise` as a pointer type @@ -194,7 +194,7 @@ bool lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd:: if (error.Success()) m_promise_ptr_sp = promisePtr->Clone(ConstString("promise")); - return false; + return lldb::ChildCacheState::eRefetch; } bool lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd:: diff --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.h b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.h index b26cc9ed6132d4..d38c7ecefa6e13 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.h +++ b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.h @@ -38,7 +38,7 @@ class StdlibCoroutineHandleSyntheticFrontEnd lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; diff --git a/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp b/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp index 2876efc5c41a55..ac316638523584 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp @@ -33,7 +33,7 @@ class GenericBitsetFrontEnd : public SyntheticChildrenFrontEnd { } bool MightHaveChildren() override { return true; } - bool Update() override; + lldb::ChildCacheState Update() override; size_t CalculateNumChildren() override { return m_elements.size(); } ValueObjectSP GetChildAtIndex(size_t idx) override; @@ -78,13 +78,13 @@ llvm::StringRef GenericBitsetFrontEnd::GetDataContainerMemberName() { llvm_unreachable("Unknown StdLib enum"); } -bool GenericBitsetFrontEnd::Update() { +lldb::ChildCacheState GenericBitsetFrontEnd::Update() { m_elements.clear(); m_first = nullptr; TargetSP target_sp = m_backend.GetTargetSP(); if (!target_sp) - return false; + return lldb::ChildCacheState::eRefetch; size_t size = 0; @@ -94,7 +94,7 @@ bool GenericBitsetFrontEnd::Update() { m_elements.assign(size, ValueObjectSP()); m_first = m_backend.GetChildMemberWithName(GetDataContainerMemberName()).get(); - return false; + return lldb::ChildCacheState::eRefetch; } ValueObjectSP GenericBitsetFrontEnd::GetChildAtIndex(size_t idx) { diff --git a/lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp b/lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp index 7415e915844fcd..57331eaa986890 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp @@ -44,7 +44,7 @@ class GenericOptionalFrontend : public SyntheticChildrenFrontEnd { size_t CalculateNumChildren() override { return m_has_value ? 1U : 0U; } ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; private: bool m_has_value = false; @@ -61,7 +61,7 @@ GenericOptionalFrontend::GenericOptionalFrontend(ValueObject &valobj, } } -bool GenericOptionalFrontend::Update() { +lldb::ChildCacheState GenericOptionalFrontend::Update() { ValueObjectSP engaged_sp; if (m_stdlib == StdLib::LibCxx) @@ -71,14 +71,14 @@ bool GenericOptionalFrontend::Update() { ->GetChildMemberWithName("_M_engaged"); if (!engaged_sp) - return false; + return lldb::ChildCacheState::eRefetch; // _M_engaged/__engaged is a bool flag and is true if the optional contains a // value. Converting it to unsigned gives us a size of 1 if it contains a // value and 0 if not. m_has_value = engaged_sp->GetValueAsUnsigned(0) != 0; - return false; + return lldb::ChildCacheState::eRefetch; } ValueObjectSP GenericOptionalFrontend::GetChildAtIndex(size_t _idx) { diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index d0bdbe1fd4d91a..a7d7066bb2c11d 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -231,21 +231,22 @@ lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd:: Update(); } -bool lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() { +lldb::ChildCacheState +lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() { m_pair_sp.reset(); m_pair_ptr = nullptr; ValueObjectSP valobj_sp = m_backend.GetSP(); if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; TargetSP target_sp(valobj_sp->GetTargetSP()); if (!target_sp) - return false; + return lldb::ChildCacheState::eRefetch; if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; // this must be a ValueObject* because it is a child of the ValueObject we // are producing children for it if were a ValueObjectSP, we would end up @@ -278,7 +279,7 @@ bool lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() { auto __i_(valobj_sp->GetChildMemberWithName("__i_")); if (!__i_) { m_pair_ptr = nullptr; - return false; + return lldb::ChildCacheState::eRefetch; } CompilerType pair_type( __i_->GetCompilerType().GetTypeTemplateArgument(0)); @@ -290,7 +291,7 @@ bool lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() { 0, name, &bit_offset_ptr, &bitfield_bit_size_ptr, &is_bitfield_ptr); if (!pair_type) { m_pair_ptr = nullptr; - return false; + return lldb::ChildCacheState::eRefetch; } auto addr(m_pair_ptr->GetValueAsUnsigned(LLDB_INVALID_ADDRESS)); @@ -299,7 +300,7 @@ bool lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() { auto ts = pair_type.GetTypeSystem(); auto ast_ctx = ts.dyn_cast_or_null<TypeSystemClang>(); if (!ast_ctx) - return false; + return lldb::ChildCacheState::eRefetch; // Mimick layout of std::__tree_iterator::__ptr_ and read it in // from process memory. @@ -328,14 +329,14 @@ bool lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() { {"payload", pair_type}}); std::optional<uint64_t> size = tree_node_type.GetByteSize(nullptr); if (!size) - return false; + return lldb::ChildCacheState::eRefetch; WritableDataBufferSP buffer_sp(new DataBufferHeap(*size, 0)); ProcessSP process_sp(target_sp->GetProcessSP()); Status error; process_sp->ReadMemory(addr, buffer_sp->GetBytes(), buffer_sp->GetByteSize(), error); if (error.Fail()) - return false; + return lldb::ChildCacheState::eRefetch; DataExtractor extractor(buffer_sp, process_sp->GetByteOrder(), process_sp->GetAddressByteSize()); auto pair_sp = CreateValueObjectFromData( @@ -347,7 +348,7 @@ bool lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() { } } - return false; + return lldb::ChildCacheState::eRefetch; } size_t lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd:: @@ -399,22 +400,22 @@ lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd:: Update(); } -bool lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd:: - Update() { +lldb::ChildCacheState lldb_private::formatters:: + LibCxxUnorderedMapIteratorSyntheticFrontEnd::Update() { m_pair_sp.reset(); m_iter_ptr = nullptr; ValueObjectSP valobj_sp = m_backend.GetSP(); if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; TargetSP target_sp(valobj_sp->GetTargetSP()); if (!target_sp) - return false; + return lldb::ChildCacheState::eRefetch; if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; auto exprPathOptions = ValueObject::GetValueForExpressionPathOptions() .DontCheckDotVsArrowSyntax() @@ -437,7 +438,7 @@ bool lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd:: auto iter_child(valobj_sp->GetChildMemberWithName("__i_")); if (!iter_child) { m_iter_ptr = nullptr; - return false; + return lldb::ChildCacheState::eRefetch; } CompilerType node_type(iter_child->GetCompilerType() @@ -455,19 +456,19 @@ bool lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd:: 0, name, &bit_offset_ptr, &bitfield_bit_size_ptr, &is_bitfield_ptr); if (!pair_type) { m_iter_ptr = nullptr; - return false; + return lldb::ChildCacheState::eRefetch; } uint64_t addr = m_iter_ptr->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); m_iter_ptr = nullptr; if (addr == 0 || addr == LLDB_INVALID_ADDRESS) - return false; + return lldb::ChildCacheState::eRefetch; auto ts = pair_type.GetTypeSystem(); auto ast_ctx = ts.dyn_cast_or_null<TypeSystemClang>(); if (!ast_ctx) - return false; + return lldb::ChildCacheState::eRefetch; // Mimick layout of std::__hash_iterator::__node_ and read it in // from process memory. @@ -489,14 +490,14 @@ bool lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd:: {"__value_", pair_type}}); std::optional<uint64_t> size = tree_node_type.GetByteSize(nullptr); if (!size) - return false; + return lldb::ChildCacheState::eRefetch; WritableDataBufferSP buffer_sp(new DataBufferHeap(*size, 0)); ProcessSP process_sp(target_sp->GetProcessSP()); Status error; process_sp->ReadMemory(addr, buffer_sp->GetBytes(), buffer_sp->GetByteSize(), error); if (error.Fail()) - return false; + return lldb::ChildCacheState::eRefetch; DataExtractor extractor(buffer_sp, process_sp->GetByteOrder(), process_sp->GetAddressByteSize()); auto pair_sp = CreateValueObjectFromData( @@ -505,7 +506,7 @@ bool lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd:: m_pair_sp = pair_sp->GetChildAtIndex(2); } - return false; + return lldb::ChildCacheState::eRefetch; } size_t lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd:: @@ -600,22 +601,23 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex( return lldb::ValueObjectSP(); } -bool lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() { +lldb::ChildCacheState +lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() { m_cntrl = nullptr; ValueObjectSP valobj_sp = m_backend.GetSP(); if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; TargetSP target_sp(valobj_sp->GetTargetSP()); if (!target_sp) - return false; + return lldb::ChildCacheState::eRefetch; lldb::ValueObjectSP cntrl_sp(valobj_sp->GetChildMemberWithName("__cntrl_")); m_cntrl = cntrl_sp.get(); // need to store the raw pointer to avoid a circular // dependency - return false; + return lldb::ChildCacheState::eRefetch; } bool lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd:: @@ -689,14 +691,15 @@ lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::GetChildAtIndex( return lldb::ValueObjectSP(); } -bool lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::Update() { +lldb::ChildCacheState +lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::Update() { ValueObjectSP valobj_sp = m_backend.GetSP(); if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName("__ptr_")); if (!ptr_sp) - return false; + return lldb::ChildCacheState::eRefetch; // Retrieve the actual pointer and the deleter, and clone them to give them // user-friendly names. @@ -708,7 +711,7 @@ bool lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::Update() { if (deleter_sp) m_deleter_sp = deleter_sp->Clone(ConstString("deleter")); - return false; + return lldb::ChildCacheState::eRefetch; } bool lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd:: diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h index 72da6b2426efec..cc8e13d10d39ce 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h @@ -91,7 +91,7 @@ class LibCxxMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -139,7 +139,7 @@ class LibCxxUnorderedMapIteratorSyntheticFrontEnd lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -170,7 +170,7 @@ class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -190,7 +190,7 @@ class LibcxxUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp index eacc60886c6eba..c81b1e8012f6a9 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp @@ -94,7 +94,7 @@ class LibcxxStdAtomicSyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -110,12 +110,13 @@ lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd:: LibcxxStdAtomicSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) : SyntheticChildrenFrontEnd(*valobj_sp) {} -bool lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::Update() { +lldb::ChildCacheState +lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::Update() { ValueObjectSP atomic_value = GetLibCxxAtomicValue(m_backend); if (atomic_value) m_real_child = GetLibCxxAtomicValue(m_backend).get(); - return false; + return lldb::ChildCacheState::eRefetch; } bool lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd:: diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp index bfd7b881a7288a..3c33f94f923734 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp @@ -30,7 +30,7 @@ class LibcxxInitializerListSyntheticFrontEnd lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -82,13 +82,13 @@ lldb::ValueObjectSP lldb_private::formatters:: m_element_type); } -bool lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd:: - Update() { +lldb::ChildCacheState +lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::Update() { m_start = nullptr; m_num_elements = 0; m_element_type = m_backend.GetCompilerType().GetTypeTemplateArgument(0); if (!m_element_type.IsValid()) - return false; + return lldb::ChildCacheState::eRefetch; if (std::optional<uint64_t> size = m_element_type.GetByteSize(nullptr)) { m_element_size = *size; @@ -96,7 +96,7 @@ bool lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd:: m_start = m_backend.GetChildMemberWithName("__begin_").get(); } - return false; + return lldb::ChildCacheState::eRefetch; } bool lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd:: diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp index 2e2e2a8b0515a9..e28ef818b10faf 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp @@ -109,7 +109,7 @@ class AbstractListFrontEnd : public SyntheticChildrenFrontEnd { return ExtractIndexFromString(name.GetCString()); } bool MightHaveChildren() override { return true; } - bool Update() override; + lldb::ChildCacheState Update() override; protected: AbstractListFrontEnd(ValueObject &valobj) @@ -138,7 +138,7 @@ class ForwardListFrontEnd : public AbstractListFrontEnd { size_t CalculateNumChildren() override; ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; }; class ListFrontEnd : public AbstractListFrontEnd { @@ -151,7 +151,7 @@ class ListFrontEnd : public AbstractListFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; private: lldb::addr_t m_node_address = 0; @@ -160,7 +160,7 @@ class ListFrontEnd : public AbstractListFrontEnd { } // end anonymous namespace -bool AbstractListFrontEnd::Update() { +lldb::ChildCacheState AbstractListFrontEnd::Update() { m_loop_detected = 0; m_count = UINT32_MAX; m_head = nullptr; @@ -180,10 +180,10 @@ bool AbstractListFrontEnd::Update() { list_type = list_type.GetNonReferenceType(); if (list_type.GetNumTemplateArguments() == 0) - return false; + return lldb::ChildCacheState::eRefetch; m_element_type = list_type.GetTypeTemplateArgument(0); - return false; + return lldb::ChildCacheState::eRefetch; } bool AbstractListFrontEnd::HasLoop(size_t count) { @@ -284,22 +284,22 @@ ValueObjectSP ForwardListFrontEnd::GetChildAtIndex(size_t idx) { m_element_type); } -bool ForwardListFrontEnd::Update() { +lldb::ChildCacheState ForwardListFrontEnd::Update() { AbstractListFrontEnd::Update(); Status err; ValueObjectSP backend_addr(m_backend.AddressOf(err)); if (err.Fail() || !backend_addr) - return false; + return lldb::ChildCacheState::eRefetch; ValueObjectSP impl_sp(m_backend.GetChildMemberWithName("__before_begin_")); if (!impl_sp) - return false; + return lldb::ChildCacheState::eRefetch; impl_sp = GetFirstValueOfLibCXXCompressedPair(*impl_sp); if (!impl_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_head = impl_sp->GetChildMemberWithName("__next_").get(); - return false; + return lldb::ChildCacheState::eRefetch; } ListFrontEnd::ListFrontEnd(lldb::ValueObjectSP valobj_sp) @@ -394,7 +394,7 @@ lldb::ValueObjectSP ListFrontEnd::GetChildAtIndex(size_t idx) { m_element_type); } -bool ListFrontEnd::Update() { +lldb::ChildCacheState ListFrontEnd::Update() { AbstractListFrontEnd::Update(); m_tail = nullptr; m_node_address = 0; @@ -402,16 +402,16 @@ bool ListFrontEnd::Update() { Status err; ValueObjectSP backend_addr(m_backend.AddressOf(err)); if (err.Fail() || !backend_addr) - return false; + return lldb::ChildCacheState::eRefetch; m_node_address = backend_addr->GetValueAsUnsigned(0); if (!m_node_address || m_node_address == LLDB_INVALID_ADDRESS) - return false; + return lldb::ChildCacheState::eRefetch; ValueObjectSP impl_sp(m_backend.GetChildMemberWithName("__end_")); if (!impl_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_head = impl_sp->GetChildMemberWithName("__next_").get(); m_tail = impl_sp->GetChildMemberWithName("__prev_").get(); - return false; + return lldb::ChildCacheState::eRefetch; } SyntheticChildrenFrontEnd *formatters::LibcxxStdListSyntheticFrontEndCreator( diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp index d3ee63a35e107c..d208acfc9da47e 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp @@ -181,7 +181,7 @@ class LibcxxStdMapSyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -405,15 +405,16 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex( return potential_child_sp; } -bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::Update() { +lldb::ChildCacheState +lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::Update() { m_count = UINT32_MAX; m_tree = m_root_node = nullptr; m_iterators.clear(); m_tree = m_backend.GetChildMemberWithName("__tree_").get(); if (!m_tree) - return false; + return lldb::ChildCacheState::eRefetch; m_root_node = m_tree->GetChildMemberWithName("__begin_node_").get(); - return false; + return lldb::ChildCacheState::eRefetch; } bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd:: diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp index c31940af08813b..83f93b16fc9a2d 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp @@ -26,7 +26,7 @@ class QueueFrontEnd : public SyntheticChildrenFrontEnd { } bool MightHaveChildren() override { return true; } - bool Update() override; + lldb::ChildCacheState Update() override; size_t CalculateNumChildren() override { return m_container_sp ? m_container_sp->GetNumChildren() : 0; @@ -47,13 +47,13 @@ class QueueFrontEnd : public SyntheticChildrenFrontEnd { }; } // namespace -bool QueueFrontEnd::Update() { +lldb::ChildCacheState QueueFrontEnd::Update() { m_container_sp = nullptr; ValueObjectSP c_sp = m_backend.GetChildMemberWithName("c"); if (!c_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_container_sp = c_sp->GetSyntheticValue().get(); - return false; + return lldb::ChildCacheState::eRefetch; } SyntheticChildrenFrontEnd * diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxRangesRefView.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxRangesRefView.cpp index 6aeb557a95ff38..c032d67c66cb47 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxRangesRefView.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxRangesRefView.cpp @@ -38,7 +38,7 @@ class LibcxxStdRangesRefViewSyntheticFrontEnd return m_range_sp; } - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override { return true; } @@ -59,17 +59,18 @@ lldb_private::formatters::LibcxxStdRangesRefViewSyntheticFrontEnd:: Update(); } -bool lldb_private::formatters::LibcxxStdRangesRefViewSyntheticFrontEnd:: - Update() { +lldb::ChildCacheState +lldb_private::formatters::LibcxxStdRangesRefViewSyntheticFrontEnd::Update() { ValueObjectSP range_ptr = GetChildMemberWithName(m_backend, {ConstString("__range_")}); if (!range_ptr) - return false; + return lldb::ChildCacheState::eRefetch; lldb_private::Status error; m_range_sp = range_ptr->Dereference(error); - return error.Success(); + return error.Success() ? lldb::ChildCacheState::eReuse + : lldb::ChildCacheState::eRefetch; } lldb_private::SyntheticChildrenFrontEnd * diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxSpan.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxSpan.cpp index ec062ed21ee405..4ddfaef9c0ad54 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxSpan.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxSpan.cpp @@ -53,7 +53,7 @@ class LibcxxStdSpanSyntheticFrontEnd : public SyntheticChildrenFrontEnd { // This function checks for a '__size' member to determine the number // of elements in the span. If no such member exists, we get the size // from the only other place it can be: the template argument. - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -93,12 +93,13 @@ lldb_private::formatters::LibcxxStdSpanSyntheticFrontEnd::GetChildAtIndex( m_element_type); } -bool lldb_private::formatters::LibcxxStdSpanSyntheticFrontEnd::Update() { +lldb::ChildCacheState +lldb_private::formatters::LibcxxStdSpanSyntheticFrontEnd::Update() { // Get element type. ValueObjectSP data_type_finder_sp = GetChildMemberWithName( m_backend, {ConstString("__data_"), ConstString("__data")}); if (!data_type_finder_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_element_type = data_type_finder_sp->GetCompilerType().GetPointeeType(); @@ -122,7 +123,7 @@ bool lldb_private::formatters::LibcxxStdSpanSyntheticFrontEnd::Update() { } } - return true; + return lldb::ChildCacheState::eReuse; } bool lldb_private::formatters::LibcxxStdSpanSyntheticFrontEnd:: diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp index 9024ed4dba45fd..546871012d2b38 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp @@ -25,7 +25,7 @@ class TupleFrontEnd: public SyntheticChildrenFrontEnd { } bool MightHaveChildren() override { return true; } - bool Update() override; + lldb::ChildCacheState Update() override; size_t CalculateNumChildren() override { return m_elements.size(); } ValueObjectSP GetChildAtIndex(size_t idx) override; @@ -40,7 +40,7 @@ class TupleFrontEnd: public SyntheticChildrenFrontEnd { }; } -bool TupleFrontEnd::Update() { +lldb::ChildCacheState TupleFrontEnd::Update() { m_elements.clear(); m_base = nullptr; @@ -51,11 +51,11 @@ bool TupleFrontEnd::Update() { base_sp = m_backend.GetChildMemberWithName("base_"); } if (!base_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_base = base_sp.get(); m_elements.assign(base_sp->GetCompilerType().GetNumDirectBaseClasses(), nullptr); - return false; + return lldb::ChildCacheState::eRefetch; } ValueObjectSP TupleFrontEnd::GetChildAtIndex(size_t idx) { diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp index 1a85d37ebf0cca..4cac52f235a19a 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp @@ -37,7 +37,7 @@ class LibcxxStdUnorderedMapSyntheticFrontEnd lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -193,41 +193,41 @@ lldb::ValueObjectSP lldb_private::formatters:: m_element_type); } -bool lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd:: - Update() { +lldb::ChildCacheState +lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::Update() { m_num_elements = 0; m_next_element = nullptr; m_elements_cache.clear(); ValueObjectSP table_sp = m_backend.GetChildMemberWithName("__table_"); if (!table_sp) - return false; + return lldb::ChildCacheState::eRefetch; ValueObjectSP p2_sp = table_sp->GetChildMemberWithName("__p2_"); if (!p2_sp) - return false; + return lldb::ChildCacheState::eRefetch; ValueObjectSP num_elements_sp = GetFirstValueOfLibCXXCompressedPair(*p2_sp); if (!num_elements_sp) - return false; + return lldb::ChildCacheState::eRefetch; ValueObjectSP p1_sp = table_sp->GetChildMemberWithName("__p1_"); if (!p1_sp) - return false; + return lldb::ChildCacheState::eRefetch; ValueObjectSP value_sp = GetFirstValueOfLibCXXCompressedPair(*p1_sp); if (!value_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_tree = value_sp->GetChildMemberWithName("__next_").get(); if (m_tree == nullptr) - return false; + return lldb::ChildCacheState::eRefetch; m_num_elements = num_elements_sp->GetValueAsUnsigned(0); if (m_num_elements > 0) m_next_element = m_tree; - return false; + return lldb::ChildCacheState::eRefetch; } bool lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd:: diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp index e863ccca2be839..ecbb7cf0ca2b46 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp @@ -204,7 +204,7 @@ class VariantFrontEnd : public SyntheticChildrenFrontEnd { } bool MightHaveChildren() override { return true; } - bool Update() override; + lldb::ChildCacheState Update() override; size_t CalculateNumChildren() override { return m_size; } ValueObjectSP GetChildAtIndex(size_t idx) override; @@ -213,24 +213,24 @@ class VariantFrontEnd : public SyntheticChildrenFrontEnd { }; } // namespace -bool VariantFrontEnd::Update() { +lldb::ChildCacheState VariantFrontEnd::Update() { m_size = 0; ValueObjectSP impl_sp = formatters::GetChildMemberWithName( m_backend, {ConstString("__impl_"), ConstString("__impl")}); if (!impl_sp) - return false; + return lldb::ChildCacheState::eRefetch; LibcxxVariantIndexValidity validity = LibcxxVariantGetIndexValidity(impl_sp); if (validity == LibcxxVariantIndexValidity::Invalid) - return false; + return lldb::ChildCacheState::eRefetch; if (validity == LibcxxVariantIndexValidity::NPos) - return true; + return lldb::ChildCacheState::eReuse; m_size = 1; - return false; + return lldb::ChildCacheState::eRefetch; } ValueObjectSP VariantFrontEnd::GetChildAtIndex(size_t idx) { diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp index 9d88fcf9953092..0c3c3f02b60c7b 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp @@ -29,7 +29,7 @@ class LibcxxStdVectorSyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -50,7 +50,7 @@ class LibcxxVectorBoolSyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override { return true; } @@ -116,17 +116,18 @@ lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::GetChildAtIndex( m_element_type); } -bool lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::Update() { +lldb::ChildCacheState +lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::Update() { m_start = m_finish = nullptr; ValueObjectSP data_type_finder_sp( m_backend.GetChildMemberWithName("__end_cap_")); if (!data_type_finder_sp) - return false; + return lldb::ChildCacheState::eRefetch; data_type_finder_sp = GetFirstValueOfLibCXXCompressedPair(*data_type_finder_sp); if (!data_type_finder_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_element_type = data_type_finder_sp->GetCompilerType().GetPointeeType(); if (std::optional<uint64_t> size = m_element_type.GetByteSize(nullptr)) { @@ -138,7 +139,7 @@ bool lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::Update() { m_finish = m_backend.GetChildMemberWithName("__end_").get(); } } - return false; + return lldb::ChildCacheState::eRefetch; } bool lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd:: @@ -226,29 +227,30 @@ lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::GetChildAtIndex( } }*/ -bool lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::Update() { +lldb::ChildCacheState +lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::Update() { m_children.clear(); ValueObjectSP valobj_sp = m_backend.GetSP(); if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_exe_ctx_ref = valobj_sp->GetExecutionContextRef(); ValueObjectSP size_sp(valobj_sp->GetChildMemberWithName("__size_")); if (!size_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_count = size_sp->GetValueAsUnsigned(0); if (!m_count) - return true; + return lldb::ChildCacheState::eReuse; ValueObjectSP begin_sp(valobj_sp->GetChildMemberWithName("__begin_")); if (!begin_sp) { m_count = 0; - return false; + return lldb::ChildCacheState::eRefetch; } m_base_data_address = begin_sp->GetValueAsUnsigned(0); if (!m_base_data_address) { m_count = 0; - return false; + return lldb::ChildCacheState::eRefetch; } - return false; + return lldb::ChildCacheState::eRefetch; } size_t lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd:: diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp index 23af50fdb7124e..411551839e1e61 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp @@ -47,7 +47,7 @@ class LibstdcppMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -68,7 +68,7 @@ class LibStdcppSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -94,29 +94,29 @@ LibstdcppMapIteratorSyntheticFrontEnd::LibstdcppMapIteratorSyntheticFrontEnd( Update(); } -bool LibstdcppMapIteratorSyntheticFrontEnd::Update() { +lldb::ChildCacheState LibstdcppMapIteratorSyntheticFrontEnd::Update() { ValueObjectSP valobj_sp = m_backend.GetSP(); if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; TargetSP target_sp(valobj_sp->GetTargetSP()); if (!target_sp) - return false; + return lldb::ChildCacheState::eRefetch; bool is_64bit = (target_sp->GetArchitecture().GetAddressByteSize() == 8); if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_exe_ctx_ref = valobj_sp->GetExecutionContextRef(); ValueObjectSP _M_node_sp(valobj_sp->GetChildMemberWithName("_M_node")); if (!_M_node_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_pair_address = _M_node_sp->GetValueAsUnsigned(0); if (m_pair_address == 0) - return false; + return lldb::ChildCacheState::eRefetch; m_pair_address += (is_64bit ? 32 : 16); @@ -124,12 +124,12 @@ bool LibstdcppMapIteratorSyntheticFrontEnd::Update() { if (my_type.GetNumTemplateArguments() >= 1) { CompilerType pair_type = my_type.GetTypeTemplateArgument(0); if (!pair_type) - return false; + return lldb::ChildCacheState::eRefetch; m_pair_type = pair_type; } else - return false; + return lldb::ChildCacheState::eRefetch; - return true; + return lldb::ChildCacheState::eReuse; } size_t LibstdcppMapIteratorSyntheticFrontEnd::CalculateNumChildren() { @@ -193,22 +193,22 @@ lldb_private::formatters::VectorIteratorSyntheticFrontEnd:: Update(); } -bool VectorIteratorSyntheticFrontEnd::Update() { +lldb::ChildCacheState VectorIteratorSyntheticFrontEnd::Update() { m_item_sp.reset(); ValueObjectSP valobj_sp = m_backend.GetSP(); if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; ValueObjectSP item_ptr = formatters::GetChildMemberWithName(*valobj_sp, m_item_names); if (!item_ptr) - return false; + return lldb::ChildCacheState::eRefetch; if (item_ptr->GetValueAsUnsigned(0) == 0) - return false; + return lldb::ChildCacheState::eRefetch; Status err; m_exe_ctx_ref = valobj_sp->GetExecutionContextRef(); m_item_sp = CreateValueObjectFromAddress( @@ -216,7 +216,7 @@ bool VectorIteratorSyntheticFrontEnd::Update() { item_ptr->GetCompilerType().GetPointeeType()); if (err.Fail()) m_item_sp.reset(); - return false; + return lldb::ChildCacheState::eRefetch; } size_t VectorIteratorSyntheticFrontEnd::CalculateNumChildren() { return 1; } @@ -390,23 +390,23 @@ LibStdcppSharedPtrSyntheticFrontEnd::GetChildAtIndex(size_t idx) { return lldb::ValueObjectSP(); } -bool LibStdcppSharedPtrSyntheticFrontEnd::Update() { +lldb::ChildCacheState LibStdcppSharedPtrSyntheticFrontEnd::Update() { auto backend = m_backend.GetSP(); if (!backend) - return false; + return lldb::ChildCacheState::eRefetch; auto valobj_sp = backend->GetNonSyntheticValue(); if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; auto ptr_obj_sp = valobj_sp->GetChildMemberWithName("_M_ptr"); if (!ptr_obj_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_ptr_obj = ptr_obj_sp->Clone(ConstString("pointer")).get(); m_obj_obj = nullptr; - return false; + return lldb::ChildCacheState::eRefetch; } bool LibStdcppSharedPtrSyntheticFrontEnd::MightHaveChildren() { return true; } diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp index f1bfeae5099b7c..189f9561e52a1b 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp @@ -30,7 +30,7 @@ class LibStdcppTupleSyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -53,12 +53,12 @@ LibStdcppTupleSyntheticFrontEnd::LibStdcppTupleSyntheticFrontEnd( Update(); } -bool LibStdcppTupleSyntheticFrontEnd::Update() { +lldb::ChildCacheState LibStdcppTupleSyntheticFrontEnd::Update() { m_members.clear(); ValueObjectSP valobj_backend_sp = m_backend.GetSP(); if (!valobj_backend_sp) - return false; + return lldb::ChildCacheState::eRefetch; ValueObjectSP next_child_sp = valobj_backend_sp->GetNonSyntheticValue(); while (next_child_sp != nullptr) { @@ -83,7 +83,7 @@ bool LibStdcppTupleSyntheticFrontEnd::Update() { } } - return false; + return lldb::ChildCacheState::eRefetch; } bool LibStdcppTupleSyntheticFrontEnd::MightHaveChildren() { return true; } diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp index a84d641b57bc47..3b0f6329d0e3ff 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp @@ -30,7 +30,7 @@ class LibStdcppUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -84,11 +84,11 @@ ValueObjectSP LibStdcppUniquePtrSyntheticFrontEnd::GetTuple() { return obj_child_sp; } -bool LibStdcppUniquePtrSyntheticFrontEnd::Update() { +lldb::ChildCacheState LibStdcppUniquePtrSyntheticFrontEnd::Update() { ValueObjectSP tuple_sp = GetTuple(); if (!tuple_sp) - return false; + return lldb::ChildCacheState::eRefetch; std::unique_ptr<SyntheticChildrenFrontEnd> tuple_frontend( LibStdcppTupleSyntheticFrontEndCreator(nullptr, tuple_sp)); @@ -110,7 +110,7 @@ bool LibStdcppUniquePtrSyntheticFrontEnd::Update() { } m_obj_obj = nullptr; - return false; + return lldb::ChildCacheState::eRefetch; } bool LibStdcppUniquePtrSyntheticFrontEnd::MightHaveChildren() { return true; } diff --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp index f1a7e04bc9d1bf..64047dc53236bf 100644 --- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp +++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp @@ -1044,7 +1044,9 @@ class ObjCClassSyntheticChildrenFrontEnd : public SyntheticChildrenFrontEnd { return lldb::ValueObjectSP(); } - bool Update() override { return false; } + lldb::ChildCacheState Update() override { + return lldb::ChildCacheState::eRefetch; + } bool MightHaveChildren() override { return false; } diff --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp b/lldb/source/Plugins/Language/ObjC/NSArray.cpp index 7d0004c572ed6b..09bf7a23d6097e 100644 --- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp @@ -54,7 +54,7 @@ class NSArrayMSyntheticFrontEndBase : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override = 0; + lldb::ChildCacheState Update() override = 0; bool MightHaveChildren() override; @@ -81,7 +81,7 @@ class GenericNSArrayMSyntheticFrontEnd : public NSArrayMSyntheticFrontEndBase { ~GenericNSArrayMSyntheticFrontEnd() override; - bool Update() override; + lldb::ChildCacheState Update() override; protected: lldb::addr_t GetDataAddress() override; @@ -218,7 +218,7 @@ class GenericNSArrayISyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -306,7 +306,7 @@ class NSArray0SyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -323,7 +323,7 @@ class NSArray1SyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -500,9 +500,8 @@ lldb_private::formatters::NSArrayMSyntheticFrontEndBase::GetChildAtIndex( } template <typename D32, typename D64> -bool -lldb_private::formatters:: - GenericNSArrayMSyntheticFrontEnd<D32, D64>::Update() { +lldb::ChildCacheState +lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<D32, D64>::Update() { ValueObjectSP valobj_sp = m_backend.GetSP(); m_ptr_size = 0; delete m_data_32; @@ -510,13 +509,13 @@ lldb_private::formatters:: delete m_data_64; m_data_64 = nullptr; if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_exe_ctx_ref = valobj_sp->GetExecutionContextRef(); Status error; error.Clear(); lldb::ProcessSP process_sp(valobj_sp->GetProcessSP()); if (!process_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_ptr_size = process_sp->GetAddressByteSize(); uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size; if (m_ptr_size == 4) { @@ -529,7 +528,8 @@ lldb_private::formatters:: error); } - return error.Success(); + return error.Success() ? lldb::ChildCacheState::eReuse + : lldb::ChildCacheState::eRefetch; } bool @@ -641,9 +641,9 @@ lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>:: } template <typename D32, typename D64, bool Inline> -bool -lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>:: - Update() { +lldb::ChildCacheState +lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, + Inline>::Update() { ValueObjectSP valobj_sp = m_backend.GetSP(); m_ptr_size = 0; delete m_data_32; @@ -651,13 +651,13 @@ lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>:: delete m_data_64; m_data_64 = nullptr; if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_exe_ctx_ref = valobj_sp->GetExecutionContextRef(); Status error; error.Clear(); lldb::ProcessSP process_sp(valobj_sp->GetProcessSP()); if (!process_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_ptr_size = process_sp->GetAddressByteSize(); uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size; if (m_ptr_size == 4) { @@ -670,7 +670,8 @@ lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>:: error); } - return error.Success(); + return error.Success() ? lldb::ChildCacheState::eReuse + : lldb::ChildCacheState::eRefetch; } template <typename D32, typename D64, bool Inline> @@ -723,8 +724,9 @@ lldb_private::formatters::NSArray0SyntheticFrontEnd::CalculateNumChildren() { return 0; } -bool lldb_private::formatters::NSArray0SyntheticFrontEnd::Update() { - return false; +lldb::ChildCacheState +lldb_private::formatters::NSArray0SyntheticFrontEnd::Update() { + return lldb::ChildCacheState::eRefetch; } bool lldb_private::formatters::NSArray0SyntheticFrontEnd::MightHaveChildren() { @@ -757,8 +759,9 @@ lldb_private::formatters::NSArray1SyntheticFrontEnd::CalculateNumChildren() { return 1; } -bool lldb_private::formatters::NSArray1SyntheticFrontEnd::Update() { - return false; +lldb::ChildCacheState +lldb_private::formatters::NSArray1SyntheticFrontEnd::Update() { + return lldb::ChildCacheState::eRefetch; } bool lldb_private::formatters::NSArray1SyntheticFrontEnd::MightHaveChildren() { diff --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp index d377ee74ccc05d..9c252a98de8357 100644 --- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp @@ -107,7 +107,7 @@ class NSDictionaryISyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -148,7 +148,7 @@ class NSConstantDictionarySyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -180,7 +180,7 @@ class NSCFDictionarySyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -213,7 +213,7 @@ class NSDictionary1SyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -234,7 +234,7 @@ class GenericNSDictionaryMSyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -266,9 +266,9 @@ namespace Foundation1100 { size_t CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - - bool Update() override; - + + lldb::ChildCacheState Update() override; + bool MightHaveChildren() override; size_t GetIndexOfChildWithName(ConstString name) override; @@ -613,7 +613,8 @@ size_t lldb_private::formatters::NSDictionaryISyntheticFrontEnd:: return (m_data_32 ? m_data_32->_used : m_data_64->_used); } -bool lldb_private::formatters::NSDictionaryISyntheticFrontEnd::Update() { +lldb::ChildCacheState +lldb_private::formatters::NSDictionaryISyntheticFrontEnd::Update() { m_children.clear(); delete m_data_32; m_data_32 = nullptr; @@ -622,13 +623,13 @@ bool lldb_private::formatters::NSDictionaryISyntheticFrontEnd::Update() { m_ptr_size = 0; ValueObjectSP valobj_sp = m_backend.GetSP(); if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_exe_ctx_ref = valobj_sp->GetExecutionContextRef(); Status error; error.Clear(); lldb::ProcessSP process_sp(valobj_sp->GetProcessSP()); if (!process_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_ptr_size = process_sp->GetAddressByteSize(); m_order = process_sp->GetByteOrder(); uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size; @@ -642,9 +643,9 @@ bool lldb_private::formatters::NSDictionaryISyntheticFrontEnd::Update() { error); } if (error.Fail()) - return false; + return lldb::ChildCacheState::eRefetch; m_data_ptr = data_location + m_ptr_size; - return false; + return lldb::ChildCacheState::eRefetch; } bool lldb_private::formatters::NSDictionaryISyntheticFrontEnd:: @@ -750,20 +751,23 @@ size_t lldb_private::formatters::NSCFDictionarySyntheticFrontEnd:: return m_hashtable.GetCount(); } -bool lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::Update() { +lldb::ChildCacheState +lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::Update() { m_children.clear(); ValueObjectSP valobj_sp = m_backend.GetSP(); m_ptr_size = 0; if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_exe_ctx_ref = valobj_sp->GetExecutionContextRef(); lldb::ProcessSP process_sp(valobj_sp->GetProcessSP()); if (!process_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_ptr_size = process_sp->GetAddressByteSize(); m_order = process_sp->GetByteOrder(); - return m_hashtable.Update(valobj_sp->GetValueAsUnsigned(0), m_exe_ctx_ref); + return m_hashtable.Update(valobj_sp->GetValueAsUnsigned(0), m_exe_ctx_ref) + ? lldb::ChildCacheState::eReuse + : lldb::ChildCacheState::eRefetch; } bool lldb_private::formatters::NSCFDictionarySyntheticFrontEnd:: @@ -881,30 +885,33 @@ size_t lldb_private::formatters::NSConstantDictionarySyntheticFrontEnd:: return m_size; } -bool lldb_private::formatters::NSConstantDictionarySyntheticFrontEnd::Update() { +lldb::ChildCacheState +lldb_private::formatters::NSConstantDictionarySyntheticFrontEnd::Update() { ValueObjectSP valobj_sp = m_backend.GetSP(); if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_exe_ctx_ref = valobj_sp->GetExecutionContextRef(); Status error; error.Clear(); lldb::ProcessSP process_sp(valobj_sp->GetProcessSP()); if (!process_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_ptr_size = process_sp->GetAddressByteSize(); m_order = process_sp->GetByteOrder(); uint64_t valobj_addr = valobj_sp->GetValueAsUnsigned(0); m_size = process_sp->ReadUnsignedIntegerFromMemory( valobj_addr + 2 * m_ptr_size, m_ptr_size, 0, error); if (error.Fail()) - return false; + return lldb::ChildCacheState::eRefetch; m_keys_ptr = process_sp->ReadPointerFromMemory(valobj_addr + 3 * m_ptr_size, error); if (error.Fail()) - return false; + return lldb::ChildCacheState::eRefetch; m_objects_ptr = process_sp->ReadPointerFromMemory(valobj_addr + 4 * m_ptr_size, error); - return !error.Fail(); + + return error.Success() ? lldb::ChildCacheState::eReuse + : lldb::ChildCacheState::eRefetch; } bool lldb_private::formatters::NSConstantDictionarySyntheticFrontEnd:: @@ -992,9 +999,10 @@ size_t lldb_private::formatters::NSDictionary1SyntheticFrontEnd:: return 1; } -bool lldb_private::formatters::NSDictionary1SyntheticFrontEnd::Update() { +lldb::ChildCacheState +lldb_private::formatters::NSDictionary1SyntheticFrontEnd::Update() { m_pair.reset(); - return false; + return lldb::ChildCacheState::eRefetch; } bool lldb_private::formatters::NSDictionary1SyntheticFrontEnd:: @@ -1087,9 +1095,9 @@ lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>::Calcul } template <typename D32, typename D64> -bool -lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>:: - Update() { +lldb::ChildCacheState +lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32, + D64>::Update() { m_children.clear(); ValueObjectSP valobj_sp = m_backend.GetSP(); m_ptr_size = 0; @@ -1098,13 +1106,13 @@ lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>:: delete m_data_64; m_data_64 = nullptr; if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_exe_ctx_ref = valobj_sp->GetExecutionContextRef(); Status error; error.Clear(); lldb::ProcessSP process_sp(valobj_sp->GetProcessSP()); if (!process_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_ptr_size = process_sp->GetAddressByteSize(); m_order = process_sp->GetByteOrder(); uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size; @@ -1118,7 +1126,8 @@ lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>:: error); } - return error.Success(); + return error.Success() ? lldb::ChildCacheState::eReuse + : lldb::ChildCacheState::eRefetch; } template <typename D32, typename D64> @@ -1249,9 +1258,8 @@ lldb_private::formatters::Foundation1100:: return (m_data_32 ? m_data_32->_used : m_data_64->_used); } -bool -lldb_private::formatters::Foundation1100:: - NSDictionaryMSyntheticFrontEnd::Update() { +lldb::ChildCacheState lldb_private::formatters::Foundation1100:: + NSDictionaryMSyntheticFrontEnd::Update() { m_children.clear(); ValueObjectSP valobj_sp = m_backend.GetSP(); m_ptr_size = 0; @@ -1260,13 +1268,13 @@ lldb_private::formatters::Foundation1100:: delete m_data_64; m_data_64 = nullptr; if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_exe_ctx_ref = valobj_sp->GetExecutionContextRef(); Status error; error.Clear(); lldb::ProcessSP process_sp(valobj_sp->GetProcessSP()); if (!process_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_ptr_size = process_sp->GetAddressByteSize(); m_order = process_sp->GetByteOrder(); uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size; @@ -1280,7 +1288,8 @@ lldb_private::formatters::Foundation1100:: error); } - return error.Success(); + return error.Success() ? lldb::ChildCacheState::eReuse + : lldb::ChildCacheState::eRefetch; } bool diff --git a/lldb/source/Plugins/Language/ObjC/NSError.cpp b/lldb/source/Plugins/Language/ObjC/NSError.cpp index 99eeb2d5092f26..ce52ae542a50cb 100644 --- a/lldb/source/Plugins/Language/ObjC/NSError.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSError.cpp @@ -133,17 +133,17 @@ class NSErrorSyntheticFrontEnd : public SyntheticChildrenFrontEnd { return m_child_sp; } - bool Update() override { + lldb::ChildCacheState Update() override { m_child_ptr = nullptr; m_child_sp.reset(); ProcessSP process_sp(m_backend.GetProcessSP()); if (!process_sp) - return false; + return lldb::ChildCacheState::eRefetch; lldb::addr_t userinfo_location = DerefToNSErrorPointer(m_backend); if (userinfo_location == LLDB_INVALID_ADDRESS) - return false; + return lldb::ChildCacheState::eRefetch; size_t ptr_size = process_sp->GetAddressByteSize(); @@ -152,17 +152,17 @@ class NSErrorSyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::addr_t userinfo = process_sp->ReadPointerFromMemory(userinfo_location, error); if (userinfo == LLDB_INVALID_ADDRESS || error.Fail()) - return false; + return lldb::ChildCacheState::eRefetch; InferiorSizedWord isw(userinfo, *process_sp); TypeSystemClangSP scratch_ts_sp = ScratchTypeSystemClang::GetForTarget(process_sp->GetTarget()); if (!scratch_ts_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_child_sp = CreateValueObjectFromData( "_userInfo", isw.GetAsData(process_sp->GetByteOrder()), m_backend.GetExecutionContextRef(), scratch_ts_sp->GetBasicType(lldb::eBasicTypeObjCID)); - return false; + return lldb::ChildCacheState::eRefetch; } bool MightHaveChildren() override { return true; } diff --git a/lldb/source/Plugins/Language/ObjC/NSException.cpp b/lldb/source/Plugins/Language/ObjC/NSException.cpp index 29805bb2d5fe86..e8011e5d2ca0be 100644 --- a/lldb/source/Plugins/Language/ObjC/NSException.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSException.cpp @@ -137,14 +137,17 @@ class NSExceptionSyntheticFrontEnd : public SyntheticChildrenFrontEnd { return lldb::ValueObjectSP(); } - bool Update() override { + lldb::ChildCacheState Update() override { m_name_sp.reset(); m_reason_sp.reset(); m_userinfo_sp.reset(); m_reserved_sp.reset(); - return ExtractFields(m_backend, &m_name_sp, &m_reason_sp, &m_userinfo_sp, - &m_reserved_sp); + const auto ret = ExtractFields(m_backend, &m_name_sp, &m_reason_sp, + &m_userinfo_sp, &m_reserved_sp); + + return ret ? lldb::ChildCacheState::eReuse + : lldb::ChildCacheState::eRefetch; } bool MightHaveChildren() override { return true; } diff --git a/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp b/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp index 2a4ce80224e9e9..69e6ab1055d8c6 100644 --- a/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp @@ -46,17 +46,17 @@ class NSIndexPathSyntheticFrontEnd : public SyntheticChildrenFrontEnd { return m_impl.GetIndexAtIndex(idx, m_uint_star_type); } - bool Update() override { + lldb::ChildCacheState Update() override { m_impl.Clear(); auto type_system = m_backend.GetCompilerType().GetTypeSystem(); if (!type_system) - return false; + return lldb::ChildCacheState::eRefetch; auto ast = ScratchTypeSystemClang::GetForTarget( *m_backend.GetExecutionContextRef().GetTargetSP()); if (!ast) - return false; + return lldb::ChildCacheState::eRefetch; m_uint_star_type = ast->GetPointerSizedIntType(false); @@ -65,18 +65,18 @@ class NSIndexPathSyntheticFrontEnd : public SyntheticChildrenFrontEnd { ProcessSP process_sp = m_backend.GetProcessSP(); if (!process_sp) - return false; + return lldb::ChildCacheState::eRefetch; ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp); if (!runtime) - return false; + return lldb::ChildCacheState::eRefetch; ObjCLanguageRuntime::ClassDescriptorSP descriptor( runtime->GetClassDescriptor(m_backend)); if (!descriptor.get() || !descriptor->IsValid()) - return false; + return lldb::ChildCacheState::eRefetch; uint64_t info_bits(0), value_bits(0), payload(0); @@ -119,7 +119,7 @@ class NSIndexPathSyntheticFrontEnd : public SyntheticChildrenFrontEnd { } } } - return false; + return lldb::ChildCacheState::eRefetch; } bool MightHaveChildren() override { return m_impl.m_mode != Mode::Invalid; } diff --git a/lldb/source/Plugins/Language/ObjC/NSSet.cpp b/lldb/source/Plugins/Language/ObjC/NSSet.cpp index ed1751cc128ca2..ede64852d9a879 100644 --- a/lldb/source/Plugins/Language/ObjC/NSSet.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSSet.cpp @@ -50,7 +50,7 @@ class NSSetISyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -88,7 +88,7 @@ class NSCFSetSyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -121,7 +121,7 @@ class GenericNSSetMSyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -237,7 +237,7 @@ class NSSetCodeRunningSyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override; - bool Update() override; + lldb::ChildCacheState Update() override; bool MightHaveChildren() override; @@ -426,7 +426,8 @@ lldb_private::formatters::NSSetISyntheticFrontEnd::CalculateNumChildren() { return (m_data_32 ? m_data_32->_used : m_data_64->_used); } -bool lldb_private::formatters::NSSetISyntheticFrontEnd::Update() { +lldb::ChildCacheState +lldb_private::formatters::NSSetISyntheticFrontEnd::Update() { m_children.clear(); delete m_data_32; m_data_32 = nullptr; @@ -435,13 +436,13 @@ bool lldb_private::formatters::NSSetISyntheticFrontEnd::Update() { m_ptr_size = 0; ValueObjectSP valobj_sp = m_backend.GetSP(); if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_exe_ctx_ref = valobj_sp->GetExecutionContextRef(); lldb::ProcessSP process_sp(valobj_sp->GetProcessSP()); if (!process_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_ptr_size = process_sp->GetAddressByteSize(); uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size; Status error; @@ -455,9 +456,9 @@ bool lldb_private::formatters::NSSetISyntheticFrontEnd::Update() { error); } if (error.Fail()) - return false; + return lldb::ChildCacheState::eRefetch; m_data_ptr = data_location + m_ptr_size; - return true; + return lldb::ChildCacheState::eReuse; } bool lldb_private::formatters::NSSetISyntheticFrontEnd::MightHaveChildren() { @@ -561,20 +562,23 @@ lldb_private::formatters::NSCFSetSyntheticFrontEnd::CalculateNumChildren() { return m_hashtable.GetCount(); } -bool lldb_private::formatters::NSCFSetSyntheticFrontEnd::Update() { +lldb::ChildCacheState +lldb_private::formatters::NSCFSetSyntheticFrontEnd::Update() { m_children.clear(); ValueObjectSP valobj_sp = m_backend.GetSP(); m_ptr_size = 0; if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_exe_ctx_ref = valobj_sp->GetExecutionContextRef(); lldb::ProcessSP process_sp(valobj_sp->GetProcessSP()); if (!process_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_ptr_size = process_sp->GetAddressByteSize(); m_order = process_sp->GetByteOrder(); - return m_hashtable.Update(valobj_sp->GetValueAsUnsigned(0), m_exe_ctx_ref); + return m_hashtable.Update(valobj_sp->GetValueAsUnsigned(0), m_exe_ctx_ref) + ? lldb::ChildCacheState::eReuse + : lldb::ChildCacheState::eRefetch; } bool lldb_private::formatters::NSCFSetSyntheticFrontEnd::MightHaveChildren() { @@ -701,9 +705,8 @@ lldb_private::formatters:: } template <typename D32, typename D64> -bool -lldb_private::formatters:: - GenericNSSetMSyntheticFrontEnd<D32, D64>::Update() { +lldb::ChildCacheState +lldb_private::formatters::GenericNSSetMSyntheticFrontEnd<D32, D64>::Update() { m_children.clear(); ValueObjectSP valobj_sp = m_backend.GetSP(); m_ptr_size = 0; @@ -712,13 +715,13 @@ lldb_private::formatters:: delete m_data_64; m_data_64 = nullptr; if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; if (!valobj_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_exe_ctx_ref = valobj_sp->GetExecutionContextRef(); lldb::ProcessSP process_sp(valobj_sp->GetProcessSP()); if (!process_sp) - return false; + return lldb::ChildCacheState::eRefetch; m_ptr_size = process_sp->GetAddressByteSize(); uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size; Status error; @@ -731,7 +734,8 @@ lldb_private::formatters:: process_sp->ReadMemory(data_location, m_data_64, sizeof(D64), error); } - return error.Success(); + return error.Success() ? lldb::ChildCacheState::eReuse + : lldb::ChildCacheState::eRefetch; } template <typename D32, typename D64> _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits