[Lldb-commits] [lldb] [lldb][TypeSynthetic][NFC] Make SyntheticChildrenFrontend::Update() return an enum (PR #80167)
Michael Buch via lldb-commits
lldb-commits at lists.llvm.org
Wed Jan 31 09:21:18 PST 2024
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/80167
>From a899377f8d0e0b28f8d87c8ea1770bd233c6616f Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Wed, 31 Jan 2024 15:51:03 +0000
Subject: [PATCH] [lldb][TypeSynthetic] Make
SyntheticChildrenFrontend::Update() return an enum
---
.../lldb/DataFormatters/TypeSynthetic.h | 25 +++---
.../lldb/DataFormatters/VectorIterator.h | 2 +-
.../Core/ValueObjectSyntheticFilter.cpp | 5 +-
lldb/source/DataFormatters/TypeSynthetic.cpp | 9 ++-
lldb/source/DataFormatters/VectorType.cpp | 4 +-
.../Language/CPlusPlus/BlockPointer.cpp | 2 +-
.../Plugins/Language/CPlusPlus/Coroutines.cpp | 16 ++--
.../Plugins/Language/CPlusPlus/Coroutines.h | 2 +-
.../Language/CPlusPlus/GenericBitset.cpp | 8 +-
.../Language/CPlusPlus/GenericOptional.cpp | 8 +-
.../Plugins/Language/CPlusPlus/LibCxx.cpp | 63 ++++++++-------
.../Plugins/Language/CPlusPlus/LibCxx.h | 8 +-
.../Language/CPlusPlus/LibCxxAtomic.cpp | 7 +-
.../CPlusPlus/LibCxxInitializerList.cpp | 10 +--
.../Plugins/Language/CPlusPlus/LibCxxList.cpp | 32 ++++----
.../Plugins/Language/CPlusPlus/LibCxxMap.cpp | 9 ++-
.../Language/CPlusPlus/LibCxxQueue.cpp | 8 +-
.../CPlusPlus/LibCxxRangesRefView.cpp | 10 +--
.../Plugins/Language/CPlusPlus/LibCxxSpan.cpp | 9 ++-
.../Language/CPlusPlus/LibCxxTuple.cpp | 8 +-
.../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 20 ++---
.../Language/CPlusPlus/LibCxxVariant.cpp | 12 +--
.../Language/CPlusPlus/LibCxxVector.cpp | 28 ++++---
.../Plugins/Language/CPlusPlus/LibStdcpp.cpp | 47 ++++++-----
.../Language/CPlusPlus/LibStdcppTuple.cpp | 9 ++-
.../CPlusPlus/LibStdcppUniquePointer.cpp | 9 ++-
lldb/source/Plugins/Language/ObjC/Cocoa.cpp | 2 +-
lldb/source/Plugins/Language/ObjC/NSArray.cpp | 43 +++++-----
.../Plugins/Language/ObjC/NSDictionary.cpp | 80 ++++++++++---------
lldb/source/Plugins/Language/ObjC/NSError.cpp | 12 +--
.../Plugins/Language/ObjC/NSException.cpp | 8 +-
.../Plugins/Language/ObjC/NSIndexPath.cpp | 14 ++--
lldb/source/Plugins/Language/ObjC/NSSet.cpp | 45 ++++++-----
33 files changed, 303 insertions(+), 271 deletions(-)
diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
index 41be9b7efda8f..7379a7ff06b44 100644
--- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h
+++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
@@ -49,14 +49,17 @@ 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;
+ enum class CacheState { Invalid, Valid };
+
+ /// 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 CacheState::Valid, \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 CacheState 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 +119,7 @@ class SyntheticValueProviderFrontEnd : public SyntheticChildrenFrontEnd {
return UINT32_MAX;
}
- bool Update() override { return false; }
+ CacheState Update() override { return CacheState::Invalid; }
bool MightHaveChildren() override { return false; }
@@ -328,7 +331,7 @@ class TypeFilterImpl : public SyntheticChildren {
filter->GetExpressionPathAtIndex(idx), true);
}
- bool Update() override { return false; }
+ CacheState Update() override { return CacheState::Invalid; }
bool MightHaveChildren() override { return filter->GetCount() > 0; }
@@ -427,7 +430,7 @@ class ScriptedSyntheticChildren : public SyntheticChildren {
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
- bool Update() override;
+ CacheState Update() override;
bool MightHaveChildren() override;
diff --git a/lldb/include/lldb/DataFormatters/VectorIterator.h b/lldb/include/lldb/DataFormatters/VectorIterator.h
index 3414298f255b6..df11380907099 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;
+ CacheState Update() override;
bool MightHaveChildren() override;
diff --git a/lldb/source/Core/ValueObjectSyntheticFilter.cpp b/lldb/source/Core/ValueObjectSyntheticFilter.cpp
index 43bc532c4a041..33f68615059bf 100644
--- a/lldb/source/Core/ValueObjectSyntheticFilter.cpp
+++ b/lldb/source/Core/ValueObjectSyntheticFilter.cpp
@@ -43,7 +43,7 @@ class DummySyntheticFrontEnd : public SyntheticChildrenFrontEnd {
bool MightHaveChildren() override { return m_backend.MightHaveChildren(); }
- bool Update() override { return false; }
+ CacheState Update() override { return CacheState::Invalid; }
};
ValueObjectSynthetic::ValueObjectSynthetic(ValueObject &parent,
@@ -177,7 +177,8 @@ bool ValueObjectSynthetic::UpdateValue() {
}
// let our backend do its update
- if (!m_synth_filter_up->Update()) {
+ if (m_synth_filter_up->Update() ==
+ SyntheticChildrenFrontEnd::CacheState::Invalid) {
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 de042e474903e..10174c034a0ea 100644
--- a/lldb/source/DataFormatters/TypeSynthetic.cpp
+++ b/lldb/source/DataFormatters/TypeSynthetic.cpp
@@ -190,11 +190,14 @@ size_t ScriptedSyntheticChildren::FrontEnd::CalculateNumChildren(uint32_t max) {
return m_interpreter->CalculateNumChildren(m_wrapper_sp, max);
}
-bool ScriptedSyntheticChildren::FrontEnd::Update() {
+SyntheticChildrenFrontEnd::CacheState
+ScriptedSyntheticChildren::FrontEnd::Update() {
if (!m_wrapper_sp || m_interpreter == nullptr)
- return false;
+ return CacheState::Invalid;
- return m_interpreter->UpdateSynthProviderInstance(m_wrapper_sp);
+ return m_interpreter->UpdateSynthProviderInstance(m_wrapper_sp)
+ ? CacheState::Valid
+ : CacheState::Invalid;
}
bool ScriptedSyntheticChildren::FrontEnd::MightHaveChildren() {
diff --git a/lldb/source/DataFormatters/VectorType.cpp b/lldb/source/DataFormatters/VectorType.cpp
index 57dae0b2c71f0..fc3900dc6ebce 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 {
+ CacheState 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 CacheState::Invalid;
}
bool MightHaveChildren() override { return true; }
diff --git a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
index 314a4aca8d266..3e9eb55e090c7 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -136,7 +136,7 @@ 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; }
+ CacheState Update() override { return CacheState::Invalid; }
// 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 6aeae97667c16..3a40b62bce3fb 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() {
+SyntheticChildrenFrontEnd::CacheState
+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 CacheState::Invalid;
lldb::addr_t frame_ptr_addr = GetCoroFramePtrFromHandle(valobj_sp);
if (frame_ptr_addr == 0 || frame_ptr_addr == LLDB_INVALID_ADDRESS)
- return false;
+ return CacheState::Invalid;
auto ts = valobj_sp->GetCompilerType().GetTypeSystem();
auto ast_ctx = ts.dyn_cast_or_null<TypeSystemClang>();
if (!ast_ctx)
- return false;
+ return CacheState::Invalid;
// 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 CacheState::Invalid;
// 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 CacheState::Invalid;
}
// 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 CacheState::Invalid;
}
bool lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::
diff --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.h b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.h
index b26cc9ed6132d..23f16d2a35110 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;
+ CacheState Update() override;
bool MightHaveChildren() override;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp b/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp
index 2876efc5c41a5..4d4e4fd85f7ff 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;
+ CacheState 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() {
+SyntheticChildrenFrontEnd::CacheState GenericBitsetFrontEnd::Update() {
m_elements.clear();
m_first = nullptr;
TargetSP target_sp = m_backend.GetTargetSP();
if (!target_sp)
- return false;
+ return CacheState::Invalid;
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 CacheState::Invalid;
}
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 7415e915844fc..55b70113b6c7d 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;
+ CacheState Update() override;
private:
bool m_has_value = false;
@@ -61,7 +61,7 @@ GenericOptionalFrontend::GenericOptionalFrontend(ValueObject &valobj,
}
}
-bool GenericOptionalFrontend::Update() {
+SyntheticChildrenFrontEnd::CacheState 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 CacheState::Invalid;
// _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 CacheState::Invalid;
}
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 d0bdbe1fd4d91..74941baeb67fa 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() {
+SyntheticChildrenFrontEnd::CacheState
+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 CacheState::Invalid;
TargetSP target_sp(valobj_sp->GetTargetSP());
if (!target_sp)
- return false;
+ return CacheState::Invalid;
if (!valobj_sp)
- return false;
+ return CacheState::Invalid;
// 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 CacheState::Invalid;
}
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 CacheState::Invalid;
}
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 CacheState::Invalid;
// 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 CacheState::Invalid;
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 CacheState::Invalid;
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 CacheState::Invalid;
}
size_t lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::
@@ -399,22 +400,22 @@ lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::
Update();
}
-bool lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::
- Update() {
+SyntheticChildrenFrontEnd::CacheState 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 CacheState::Invalid;
TargetSP target_sp(valobj_sp->GetTargetSP());
if (!target_sp)
- return false;
+ return CacheState::Invalid;
if (!valobj_sp)
- return false;
+ return CacheState::Invalid;
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 CacheState::Invalid;
}
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 CacheState::Invalid;
}
uint64_t addr = m_iter_ptr->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
m_iter_ptr = nullptr;
if (addr == 0 || addr == LLDB_INVALID_ADDRESS)
- return false;
+ return CacheState::Invalid;
auto ts = pair_type.GetTypeSystem();
auto ast_ctx = ts.dyn_cast_or_null<TypeSystemClang>();
if (!ast_ctx)
- return false;
+ return CacheState::Invalid;
// 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 CacheState::Invalid;
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 CacheState::Invalid;
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 CacheState::Invalid;
}
size_t lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::
@@ -600,22 +601,23 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex(
return lldb::ValueObjectSP();
}
-bool lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() {
+SyntheticChildrenFrontEnd::CacheState
+lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() {
m_cntrl = nullptr;
ValueObjectSP valobj_sp = m_backend.GetSP();
if (!valobj_sp)
- return false;
+ return CacheState::Invalid;
TargetSP target_sp(valobj_sp->GetTargetSP());
if (!target_sp)
- return false;
+ return CacheState::Invalid;
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 CacheState::Invalid;
}
bool lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
@@ -689,14 +691,15 @@ lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::GetChildAtIndex(
return lldb::ValueObjectSP();
}
-bool lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::Update() {
+SyntheticChildrenFrontEnd::CacheState
+lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::Update() {
ValueObjectSP valobj_sp = m_backend.GetSP();
if (!valobj_sp)
- return false;
+ return CacheState::Invalid;
ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName("__ptr_"));
if (!ptr_sp)
- return false;
+ return CacheState::Invalid;
// 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 CacheState::Invalid;
}
bool lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
index 72da6b2426efe..8919307618293 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;
+ CacheState Update() override;
bool MightHaveChildren() override;
@@ -139,7 +139,7 @@ class LibCxxUnorderedMapIteratorSyntheticFrontEnd
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
- bool Update() override;
+ CacheState Update() override;
bool MightHaveChildren() override;
@@ -170,7 +170,7 @@ class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
- bool Update() override;
+ CacheState Update() override;
bool MightHaveChildren() override;
@@ -190,7 +190,7 @@ class LibcxxUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
- bool Update() override;
+ CacheState Update() override;
bool MightHaveChildren() override;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
index eacc60886c6eb..e8a156995ce8e 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;
+ CacheState 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() {
+SyntheticChildrenFrontEnd::CacheState
+lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::Update() {
ValueObjectSP atomic_value = GetLibCxxAtomicValue(m_backend);
if (atomic_value)
m_real_child = GetLibCxxAtomicValue(m_backend).get();
- return false;
+ return CacheState::Invalid;
}
bool lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
index bfd7b881a7288..be5db30be6436 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;
+ CacheState Update() override;
bool MightHaveChildren() override;
@@ -82,13 +82,13 @@ lldb::ValueObjectSP lldb_private::formatters::
m_element_type);
}
-bool lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::
- Update() {
+SyntheticChildrenFrontEnd::CacheState
+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 CacheState::Invalid;
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 CacheState::Invalid;
}
bool lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
index 2e2e2a8b0515a..b759540d94379 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;
+ CacheState 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;
+ CacheState Update() override;
};
class ListFrontEnd : public AbstractListFrontEnd {
@@ -151,7 +151,7 @@ class ListFrontEnd : public AbstractListFrontEnd {
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
- bool Update() override;
+ CacheState Update() override;
private:
lldb::addr_t m_node_address = 0;
@@ -160,7 +160,7 @@ class ListFrontEnd : public AbstractListFrontEnd {
} // end anonymous namespace
-bool AbstractListFrontEnd::Update() {
+SyntheticChildrenFrontEnd::CacheState 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 CacheState::Invalid;
m_element_type = list_type.GetTypeTemplateArgument(0);
- return false;
+ return CacheState::Invalid;
}
bool AbstractListFrontEnd::HasLoop(size_t count) {
@@ -284,22 +284,22 @@ ValueObjectSP ForwardListFrontEnd::GetChildAtIndex(size_t idx) {
m_element_type);
}
-bool ForwardListFrontEnd::Update() {
+SyntheticChildrenFrontEnd::CacheState ForwardListFrontEnd::Update() {
AbstractListFrontEnd::Update();
Status err;
ValueObjectSP backend_addr(m_backend.AddressOf(err));
if (err.Fail() || !backend_addr)
- return false;
+ return CacheState::Invalid;
ValueObjectSP impl_sp(m_backend.GetChildMemberWithName("__before_begin_"));
if (!impl_sp)
- return false;
+ return CacheState::Invalid;
impl_sp = GetFirstValueOfLibCXXCompressedPair(*impl_sp);
if (!impl_sp)
- return false;
+ return CacheState::Invalid;
m_head = impl_sp->GetChildMemberWithName("__next_").get();
- return false;
+ return CacheState::Invalid;
}
ListFrontEnd::ListFrontEnd(lldb::ValueObjectSP valobj_sp)
@@ -394,7 +394,7 @@ lldb::ValueObjectSP ListFrontEnd::GetChildAtIndex(size_t idx) {
m_element_type);
}
-bool ListFrontEnd::Update() {
+SyntheticChildrenFrontEnd::CacheState 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 CacheState::Invalid;
m_node_address = backend_addr->GetValueAsUnsigned(0);
if (!m_node_address || m_node_address == LLDB_INVALID_ADDRESS)
- return false;
+ return CacheState::Invalid;
ValueObjectSP impl_sp(m_backend.GetChildMemberWithName("__end_"));
if (!impl_sp)
- return false;
+ return CacheState::Invalid;
m_head = impl_sp->GetChildMemberWithName("__next_").get();
m_tail = impl_sp->GetChildMemberWithName("__prev_").get();
- return false;
+ return CacheState::Invalid;
}
SyntheticChildrenFrontEnd *formatters::LibcxxStdListSyntheticFrontEndCreator(
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
index d3ee63a35e107..b62aacae911aa 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;
+ CacheState Update() override;
bool MightHaveChildren() override;
@@ -405,15 +405,16 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex(
return potential_child_sp;
}
-bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::Update() {
+SyntheticChildrenFrontEnd::CacheState
+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 CacheState::Invalid;
m_root_node = m_tree->GetChildMemberWithName("__begin_node_").get();
- return false;
+ return CacheState::Invalid;
}
bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
index c31940af08813..f8fcfe6f5e90c 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;
+ CacheState 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() {
+SyntheticChildrenFrontEnd::CacheState QueueFrontEnd::Update() {
m_container_sp = nullptr;
ValueObjectSP c_sp = m_backend.GetChildMemberWithName("c");
if (!c_sp)
- return false;
+ return CacheState::Invalid;
m_container_sp = c_sp->GetSyntheticValue().get();
- return false;
+ return CacheState::Invalid;
}
SyntheticChildrenFrontEnd *
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxRangesRefView.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxRangesRefView.cpp
index 6aeb557a95ff3..6d0eb4827d6fb 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;
+ CacheState Update() override;
bool MightHaveChildren() override { return true; }
@@ -59,17 +59,17 @@ lldb_private::formatters::LibcxxStdRangesRefViewSyntheticFrontEnd::
Update();
}
-bool lldb_private::formatters::LibcxxStdRangesRefViewSyntheticFrontEnd::
- Update() {
+SyntheticChildrenFrontEnd::CacheState
+lldb_private::formatters::LibcxxStdRangesRefViewSyntheticFrontEnd::Update() {
ValueObjectSP range_ptr =
GetChildMemberWithName(m_backend, {ConstString("__range_")});
if (!range_ptr)
- return false;
+ return CacheState::Invalid;
lldb_private::Status error;
m_range_sp = range_ptr->Dereference(error);
- return error.Success();
+ return error.Success() ? CacheState::Valid : CacheState::Invalid;
}
lldb_private::SyntheticChildrenFrontEnd *
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxSpan.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxSpan.cpp
index ec062ed21ee40..d70e9d17b2cdb 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;
+ CacheState Update() override;
bool MightHaveChildren() override;
@@ -93,12 +93,13 @@ lldb_private::formatters::LibcxxStdSpanSyntheticFrontEnd::GetChildAtIndex(
m_element_type);
}
-bool lldb_private::formatters::LibcxxStdSpanSyntheticFrontEnd::Update() {
+SyntheticChildrenFrontEnd::CacheState
+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 CacheState::Invalid;
m_element_type = data_type_finder_sp->GetCompilerType().GetPointeeType();
@@ -122,7 +123,7 @@ bool lldb_private::formatters::LibcxxStdSpanSyntheticFrontEnd::Update() {
}
}
- return true;
+ return CacheState::Valid;
}
bool lldb_private::formatters::LibcxxStdSpanSyntheticFrontEnd::
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
index 9024ed4dba45f..377ef01a2dece 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;
+ CacheState 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() {
+SyntheticChildrenFrontEnd::CacheState 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 CacheState::Invalid;
m_base = base_sp.get();
m_elements.assign(base_sp->GetCompilerType().GetNumDirectBaseClasses(),
nullptr);
- return false;
+ return CacheState::Invalid;
}
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 1a85d37ebf0cc..72f893d4051ba 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;
+ CacheState Update() override;
bool MightHaveChildren() override;
@@ -193,41 +193,41 @@ lldb::ValueObjectSP lldb_private::formatters::
m_element_type);
}
-bool lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
- Update() {
+SyntheticChildrenFrontEnd::CacheState
+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 CacheState::Invalid;
ValueObjectSP p2_sp = table_sp->GetChildMemberWithName("__p2_");
if (!p2_sp)
- return false;
+ return CacheState::Invalid;
ValueObjectSP num_elements_sp = GetFirstValueOfLibCXXCompressedPair(*p2_sp);
if (!num_elements_sp)
- return false;
+ return CacheState::Invalid;
ValueObjectSP p1_sp = table_sp->GetChildMemberWithName("__p1_");
if (!p1_sp)
- return false;
+ return CacheState::Invalid;
ValueObjectSP value_sp = GetFirstValueOfLibCXXCompressedPair(*p1_sp);
if (!value_sp)
- return false;
+ return CacheState::Invalid;
m_tree = value_sp->GetChildMemberWithName("__next_").get();
if (m_tree == nullptr)
- return false;
+ return CacheState::Invalid;
m_num_elements = num_elements_sp->GetValueAsUnsigned(0);
if (m_num_elements > 0)
m_next_element = m_tree;
- return false;
+ return CacheState::Invalid;
}
bool lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
index e863ccca2be83..54ae1a6b59546 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;
+ CacheState 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() {
+SyntheticChildrenFrontEnd::CacheState VariantFrontEnd::Update() {
m_size = 0;
ValueObjectSP impl_sp = formatters::GetChildMemberWithName(
m_backend, {ConstString("__impl_"), ConstString("__impl")});
if (!impl_sp)
- return false;
+ return CacheState::Invalid;
LibcxxVariantIndexValidity validity = LibcxxVariantGetIndexValidity(impl_sp);
if (validity == LibcxxVariantIndexValidity::Invalid)
- return false;
+ return CacheState::Invalid;
if (validity == LibcxxVariantIndexValidity::NPos)
- return true;
+ return CacheState::Valid;
m_size = 1;
- return false;
+ return CacheState::Invalid;
}
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 9d88fcf995309..bb09534384f08 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;
+ CacheState Update() override;
bool MightHaveChildren() override;
@@ -50,7 +50,7 @@ class LibcxxVectorBoolSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
- bool Update() override;
+ CacheState 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() {
+SyntheticChildrenFrontEnd::CacheState
+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 CacheState::Invalid;
data_type_finder_sp =
GetFirstValueOfLibCXXCompressedPair(*data_type_finder_sp);
if (!data_type_finder_sp)
- return false;
+ return CacheState::Invalid;
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 CacheState::Invalid;
}
bool lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::
@@ -226,29 +227,30 @@ lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::GetChildAtIndex(
}
}*/
-bool lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::Update() {
+SyntheticChildrenFrontEnd::CacheState
+lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::Update() {
m_children.clear();
ValueObjectSP valobj_sp = m_backend.GetSP();
if (!valobj_sp)
- return false;
+ return CacheState::Invalid;
m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
ValueObjectSP size_sp(valobj_sp->GetChildMemberWithName("__size_"));
if (!size_sp)
- return false;
+ return CacheState::Invalid;
m_count = size_sp->GetValueAsUnsigned(0);
if (!m_count)
- return true;
+ return CacheState::Valid;
ValueObjectSP begin_sp(valobj_sp->GetChildMemberWithName("__begin_"));
if (!begin_sp) {
m_count = 0;
- return false;
+ return CacheState::Invalid;
}
m_base_data_address = begin_sp->GetValueAsUnsigned(0);
if (!m_base_data_address) {
m_count = 0;
- return false;
+ return CacheState::Invalid;
}
- return false;
+ return CacheState::Invalid;
}
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 23af50fdb7124..762a2bd7c0e36 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;
+ CacheState Update() override;
bool MightHaveChildren() override;
@@ -68,7 +68,7 @@ class LibStdcppSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
- bool Update() override;
+ CacheState Update() override;
bool MightHaveChildren() override;
@@ -94,29 +94,30 @@ LibstdcppMapIteratorSyntheticFrontEnd::LibstdcppMapIteratorSyntheticFrontEnd(
Update();
}
-bool LibstdcppMapIteratorSyntheticFrontEnd::Update() {
+SyntheticChildrenFrontEnd::CacheState
+LibstdcppMapIteratorSyntheticFrontEnd::Update() {
ValueObjectSP valobj_sp = m_backend.GetSP();
if (!valobj_sp)
- return false;
+ return CacheState::Invalid;
TargetSP target_sp(valobj_sp->GetTargetSP());
if (!target_sp)
- return false;
+ return CacheState::Invalid;
bool is_64bit = (target_sp->GetArchitecture().GetAddressByteSize() == 8);
if (!valobj_sp)
- return false;
+ return CacheState::Invalid;
m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
ValueObjectSP _M_node_sp(valobj_sp->GetChildMemberWithName("_M_node"));
if (!_M_node_sp)
- return false;
+ return CacheState::Invalid;
m_pair_address = _M_node_sp->GetValueAsUnsigned(0);
if (m_pair_address == 0)
- return false;
+ return CacheState::Invalid;
m_pair_address += (is_64bit ? 32 : 16);
@@ -124,12 +125,12 @@ bool LibstdcppMapIteratorSyntheticFrontEnd::Update() {
if (my_type.GetNumTemplateArguments() >= 1) {
CompilerType pair_type = my_type.GetTypeTemplateArgument(0);
if (!pair_type)
- return false;
+ return CacheState::Invalid;
m_pair_type = pair_type;
} else
- return false;
+ return CacheState::Invalid;
- return true;
+ return CacheState::Valid;
}
size_t LibstdcppMapIteratorSyntheticFrontEnd::CalculateNumChildren() {
@@ -193,22 +194,23 @@ lldb_private::formatters::VectorIteratorSyntheticFrontEnd::
Update();
}
-bool VectorIteratorSyntheticFrontEnd::Update() {
+SyntheticChildrenFrontEnd::CacheState
+VectorIteratorSyntheticFrontEnd::Update() {
m_item_sp.reset();
ValueObjectSP valobj_sp = m_backend.GetSP();
if (!valobj_sp)
- return false;
+ return CacheState::Invalid;
if (!valobj_sp)
- return false;
+ return CacheState::Invalid;
ValueObjectSP item_ptr =
formatters::GetChildMemberWithName(*valobj_sp, m_item_names);
if (!item_ptr)
- return false;
+ return CacheState::Invalid;
if (item_ptr->GetValueAsUnsigned(0) == 0)
- return false;
+ return CacheState::Invalid;
Status err;
m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
m_item_sp = CreateValueObjectFromAddress(
@@ -216,7 +218,7 @@ bool VectorIteratorSyntheticFrontEnd::Update() {
item_ptr->GetCompilerType().GetPointeeType());
if (err.Fail())
m_item_sp.reset();
- return false;
+ return CacheState::Invalid;
}
size_t VectorIteratorSyntheticFrontEnd::CalculateNumChildren() { return 1; }
@@ -390,23 +392,24 @@ LibStdcppSharedPtrSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
return lldb::ValueObjectSP();
}
-bool LibStdcppSharedPtrSyntheticFrontEnd::Update() {
+SyntheticChildrenFrontEnd::CacheState
+LibStdcppSharedPtrSyntheticFrontEnd::Update() {
auto backend = m_backend.GetSP();
if (!backend)
- return false;
+ return CacheState::Invalid;
auto valobj_sp = backend->GetNonSyntheticValue();
if (!valobj_sp)
- return false;
+ return CacheState::Invalid;
auto ptr_obj_sp = valobj_sp->GetChildMemberWithName("_M_ptr");
if (!ptr_obj_sp)
- return false;
+ return CacheState::Invalid;
m_ptr_obj = ptr_obj_sp->Clone(ConstString("pointer")).get();
m_obj_obj = nullptr;
- return false;
+ return CacheState::Invalid;
}
bool LibStdcppSharedPtrSyntheticFrontEnd::MightHaveChildren() { return true; }
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
index f1bfeae5099b7..5dc6c3c1b24d7 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;
+ CacheState Update() override;
bool MightHaveChildren() override;
@@ -53,12 +53,13 @@ LibStdcppTupleSyntheticFrontEnd::LibStdcppTupleSyntheticFrontEnd(
Update();
}
-bool LibStdcppTupleSyntheticFrontEnd::Update() {
+SyntheticChildrenFrontEnd::CacheState
+LibStdcppTupleSyntheticFrontEnd::Update() {
m_members.clear();
ValueObjectSP valobj_backend_sp = m_backend.GetSP();
if (!valobj_backend_sp)
- return false;
+ return CacheState::Invalid;
ValueObjectSP next_child_sp = valobj_backend_sp->GetNonSyntheticValue();
while (next_child_sp != nullptr) {
@@ -83,7 +84,7 @@ bool LibStdcppTupleSyntheticFrontEnd::Update() {
}
}
- return false;
+ return CacheState::Invalid;
}
bool LibStdcppTupleSyntheticFrontEnd::MightHaveChildren() { return true; }
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
index a84d641b57bc4..db9b2856bbfaa 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;
+ CacheState Update() override;
bool MightHaveChildren() override;
@@ -84,11 +84,12 @@ ValueObjectSP LibStdcppUniquePtrSyntheticFrontEnd::GetTuple() {
return obj_child_sp;
}
-bool LibStdcppUniquePtrSyntheticFrontEnd::Update() {
+SyntheticChildrenFrontEnd::CacheState
+LibStdcppUniquePtrSyntheticFrontEnd::Update() {
ValueObjectSP tuple_sp = GetTuple();
if (!tuple_sp)
- return false;
+ return CacheState::Invalid;
std::unique_ptr<SyntheticChildrenFrontEnd> tuple_frontend(
LibStdcppTupleSyntheticFrontEndCreator(nullptr, tuple_sp));
@@ -110,7 +111,7 @@ bool LibStdcppUniquePtrSyntheticFrontEnd::Update() {
}
m_obj_obj = nullptr;
- return false;
+ return CacheState::Invalid;
}
bool LibStdcppUniquePtrSyntheticFrontEnd::MightHaveChildren() { return true; }
diff --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
index f1a7e04bc9d1b..e3b8cd93bf879 100644
--- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
+++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -1044,7 +1044,7 @@ class ObjCClassSyntheticChildrenFrontEnd : public SyntheticChildrenFrontEnd {
return lldb::ValueObjectSP();
}
- bool Update() override { return false; }
+ CacheState Update() override { return CacheState::Invalid; }
bool MightHaveChildren() override { return false; }
diff --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
index 7d0004c572ed6..f587b640aaa82 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;
+ CacheState Update() override = 0;
bool MightHaveChildren() override;
@@ -81,7 +81,7 @@ class GenericNSArrayMSyntheticFrontEnd : public NSArrayMSyntheticFrontEndBase {
~GenericNSArrayMSyntheticFrontEnd() override;
- bool Update() override;
+ CacheState 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;
+ CacheState Update() override;
bool MightHaveChildren() override;
@@ -306,7 +306,7 @@ class NSArray0SyntheticFrontEnd : public SyntheticChildrenFrontEnd {
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
- bool Update() override;
+ CacheState Update() override;
bool MightHaveChildren() override;
@@ -323,7 +323,7 @@ class NSArray1SyntheticFrontEnd : public SyntheticChildrenFrontEnd {
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
- bool Update() override;
+ CacheState 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() {
+SyntheticChildrenFrontEnd::CacheState
+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 CacheState::Invalid;
m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
Status error;
error.Clear();
lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
if (!process_sp)
- return false;
+ return CacheState::Invalid;
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,7 @@ lldb_private::formatters::
error);
}
- return error.Success();
+ return error.Success() ? CacheState::Valid : CacheState::Invalid;
}
bool
@@ -641,9 +640,9 @@ lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
}
template <typename D32, typename D64, bool Inline>
-bool
-lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
- Update() {
+SyntheticChildrenFrontEnd::CacheState
+lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64,
+ Inline>::Update() {
ValueObjectSP valobj_sp = m_backend.GetSP();
m_ptr_size = 0;
delete m_data_32;
@@ -651,13 +650,13 @@ lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
delete m_data_64;
m_data_64 = nullptr;
if (!valobj_sp)
- return false;
+ return CacheState::Invalid;
m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
Status error;
error.Clear();
lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
if (!process_sp)
- return false;
+ return CacheState::Invalid;
m_ptr_size = process_sp->GetAddressByteSize();
uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size;
if (m_ptr_size == 4) {
@@ -670,7 +669,7 @@ lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
error);
}
- return error.Success();
+ return error.Success() ? CacheState::Valid : CacheState::Invalid;
}
template <typename D32, typename D64, bool Inline>
@@ -723,8 +722,9 @@ lldb_private::formatters::NSArray0SyntheticFrontEnd::CalculateNumChildren() {
return 0;
}
-bool lldb_private::formatters::NSArray0SyntheticFrontEnd::Update() {
- return false;
+SyntheticChildrenFrontEnd::CacheState
+lldb_private::formatters::NSArray0SyntheticFrontEnd::Update() {
+ return CacheState::Invalid;
}
bool lldb_private::formatters::NSArray0SyntheticFrontEnd::MightHaveChildren() {
@@ -757,8 +757,9 @@ lldb_private::formatters::NSArray1SyntheticFrontEnd::CalculateNumChildren() {
return 1;
}
-bool lldb_private::formatters::NSArray1SyntheticFrontEnd::Update() {
- return false;
+SyntheticChildrenFrontEnd::CacheState
+lldb_private::formatters::NSArray1SyntheticFrontEnd::Update() {
+ return CacheState::Invalid;
}
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 d377ee74ccc05..97c2c32f5bc1b 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;
+ CacheState Update() override;
bool MightHaveChildren() override;
@@ -148,7 +148,7 @@ class NSConstantDictionarySyntheticFrontEnd : public SyntheticChildrenFrontEnd {
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
- bool Update() override;
+ CacheState Update() override;
bool MightHaveChildren() override;
@@ -180,7 +180,7 @@ class NSCFDictionarySyntheticFrontEnd : public SyntheticChildrenFrontEnd {
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
- bool Update() override;
+ CacheState Update() override;
bool MightHaveChildren() override;
@@ -213,7 +213,7 @@ class NSDictionary1SyntheticFrontEnd : public SyntheticChildrenFrontEnd {
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
- bool Update() override;
+ CacheState Update() override;
bool MightHaveChildren() override;
@@ -234,7 +234,7 @@ class GenericNSDictionaryMSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
- bool Update() override;
+ CacheState 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;
-
+
+ CacheState 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() {
+SyntheticChildrenFrontEnd::CacheState
+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 CacheState::Invalid;
m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
Status error;
error.Clear();
lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
if (!process_sp)
- return false;
+ return CacheState::Invalid;
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 CacheState::Invalid;
m_data_ptr = data_location + m_ptr_size;
- return false;
+ return CacheState::Invalid;
}
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() {
+SyntheticChildrenFrontEnd::CacheState
+lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::Update() {
m_children.clear();
ValueObjectSP valobj_sp = m_backend.GetSP();
m_ptr_size = 0;
if (!valobj_sp)
- return false;
+ return CacheState::Invalid;
m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
if (!process_sp)
- return false;
+ return CacheState::Invalid;
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)
+ ? CacheState::Valid
+ : CacheState::Invalid;
}
bool lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::
@@ -881,30 +885,32 @@ size_t lldb_private::formatters::NSConstantDictionarySyntheticFrontEnd::
return m_size;
}
-bool lldb_private::formatters::NSConstantDictionarySyntheticFrontEnd::Update() {
+SyntheticChildrenFrontEnd::CacheState
+lldb_private::formatters::NSConstantDictionarySyntheticFrontEnd::Update() {
ValueObjectSP valobj_sp = m_backend.GetSP();
if (!valobj_sp)
- return false;
+ return CacheState::Invalid;
m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
Status error;
error.Clear();
lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
if (!process_sp)
- return false;
+ return CacheState::Invalid;
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 CacheState::Invalid;
m_keys_ptr =
process_sp->ReadPointerFromMemory(valobj_addr + 3 * m_ptr_size, error);
if (error.Fail())
- return false;
+ return CacheState::Invalid;
m_objects_ptr =
process_sp->ReadPointerFromMemory(valobj_addr + 4 * m_ptr_size, error);
- return !error.Fail();
+
+ return error.Success() ? CacheState::Valid : CacheState::Invalid;
}
bool lldb_private::formatters::NSConstantDictionarySyntheticFrontEnd::
@@ -992,9 +998,10 @@ size_t lldb_private::formatters::NSDictionary1SyntheticFrontEnd::
return 1;
}
-bool lldb_private::formatters::NSDictionary1SyntheticFrontEnd::Update() {
+SyntheticChildrenFrontEnd::CacheState
+lldb_private::formatters::NSDictionary1SyntheticFrontEnd::Update() {
m_pair.reset();
- return false;
+ return CacheState::Invalid;
}
bool lldb_private::formatters::NSDictionary1SyntheticFrontEnd::
@@ -1087,9 +1094,9 @@ lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>::Calcul
}
template <typename D32, typename D64>
-bool
-lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>::
- Update() {
+SyntheticChildrenFrontEnd::CacheState
+lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,
+ D64>::Update() {
m_children.clear();
ValueObjectSP valobj_sp = m_backend.GetSP();
m_ptr_size = 0;
@@ -1098,13 +1105,13 @@ lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>::
delete m_data_64;
m_data_64 = nullptr;
if (!valobj_sp)
- return false;
+ return CacheState::Invalid;
m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
Status error;
error.Clear();
lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
if (!process_sp)
- return false;
+ return CacheState::Invalid;
m_ptr_size = process_sp->GetAddressByteSize();
m_order = process_sp->GetByteOrder();
uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size;
@@ -1118,7 +1125,7 @@ lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>::
error);
}
- return error.Success();
+ return error.Success() ? CacheState::Valid : CacheState::Invalid;
}
template <typename D32, typename D64>
@@ -1249,9 +1256,8 @@ lldb_private::formatters::Foundation1100::
return (m_data_32 ? m_data_32->_used : m_data_64->_used);
}
-bool
-lldb_private::formatters::Foundation1100::
- NSDictionaryMSyntheticFrontEnd::Update() {
+SyntheticChildrenFrontEnd::CacheState lldb_private::formatters::Foundation1100::
+ NSDictionaryMSyntheticFrontEnd::Update() {
m_children.clear();
ValueObjectSP valobj_sp = m_backend.GetSP();
m_ptr_size = 0;
@@ -1260,13 +1266,13 @@ lldb_private::formatters::Foundation1100::
delete m_data_64;
m_data_64 = nullptr;
if (!valobj_sp)
- return false;
+ return CacheState::Invalid;
m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
Status error;
error.Clear();
lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
if (!process_sp)
- return false;
+ return CacheState::Invalid;
m_ptr_size = process_sp->GetAddressByteSize();
m_order = process_sp->GetByteOrder();
uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size;
@@ -1280,7 +1286,7 @@ lldb_private::formatters::Foundation1100::
error);
}
- return error.Success();
+ return error.Success() ? CacheState::Valid : CacheState::Invalid;
}
bool
diff --git a/lldb/source/Plugins/Language/ObjC/NSError.cpp b/lldb/source/Plugins/Language/ObjC/NSError.cpp
index 99eeb2d5092f2..648ef84d442f6 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 {
+ CacheState Update() override {
m_child_ptr = nullptr;
m_child_sp.reset();
ProcessSP process_sp(m_backend.GetProcessSP());
if (!process_sp)
- return false;
+ return CacheState::Invalid;
lldb::addr_t userinfo_location = DerefToNSErrorPointer(m_backend);
if (userinfo_location == LLDB_INVALID_ADDRESS)
- return false;
+ return CacheState::Invalid;
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 CacheState::Invalid;
InferiorSizedWord isw(userinfo, *process_sp);
TypeSystemClangSP scratch_ts_sp =
ScratchTypeSystemClang::GetForTarget(process_sp->GetTarget());
if (!scratch_ts_sp)
- return false;
+ return CacheState::Invalid;
m_child_sp = CreateValueObjectFromData(
"_userInfo", isw.GetAsData(process_sp->GetByteOrder()),
m_backend.GetExecutionContextRef(),
scratch_ts_sp->GetBasicType(lldb::eBasicTypeObjCID));
- return false;
+ return CacheState::Invalid;
}
bool MightHaveChildren() override { return true; }
diff --git a/lldb/source/Plugins/Language/ObjC/NSException.cpp b/lldb/source/Plugins/Language/ObjC/NSException.cpp
index 29805bb2d5fe8..4689bbf841878 100644
--- a/lldb/source/Plugins/Language/ObjC/NSException.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSException.cpp
@@ -137,14 +137,16 @@ class NSExceptionSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
return lldb::ValueObjectSP();
}
- bool Update() override {
+ CacheState 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 ? CacheState::Valid : CacheState::Invalid;
}
bool MightHaveChildren() override { return true; }
diff --git a/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp b/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp
index 2a4ce80224e9e..986910003baa4 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 {
+ CacheState Update() override {
m_impl.Clear();
auto type_system = m_backend.GetCompilerType().GetTypeSystem();
if (!type_system)
- return false;
+ return CacheState::Invalid;
auto ast = ScratchTypeSystemClang::GetForTarget(
*m_backend.GetExecutionContextRef().GetTargetSP());
if (!ast)
- return false;
+ return CacheState::Invalid;
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 CacheState::Invalid;
ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (!runtime)
- return false;
+ return CacheState::Invalid;
ObjCLanguageRuntime::ClassDescriptorSP descriptor(
runtime->GetClassDescriptor(m_backend));
if (!descriptor.get() || !descriptor->IsValid())
- return false;
+ return CacheState::Invalid;
uint64_t info_bits(0), value_bits(0), payload(0);
@@ -119,7 +119,7 @@ class NSIndexPathSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
}
}
}
- return false;
+ return CacheState::Invalid;
}
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 ed1751cc128ca..76651665f4aa4 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;
+ CacheState Update() override;
bool MightHaveChildren() override;
@@ -88,7 +88,7 @@ class NSCFSetSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
- bool Update() override;
+ CacheState Update() override;
bool MightHaveChildren() override;
@@ -121,7 +121,7 @@ class GenericNSSetMSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
- bool Update() override;
+ CacheState Update() override;
bool MightHaveChildren() override;
@@ -237,7 +237,7 @@ class NSSetCodeRunningSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
- bool Update() override;
+ CacheState 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() {
+SyntheticChildrenFrontEnd::CacheState
+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 CacheState::Invalid;
if (!valobj_sp)
- return false;
+ return CacheState::Invalid;
m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
if (!process_sp)
- return false;
+ return CacheState::Invalid;
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 CacheState::Invalid;
m_data_ptr = data_location + m_ptr_size;
- return true;
+ return CacheState::Valid;
}
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() {
+SyntheticChildrenFrontEnd::CacheState
+lldb_private::formatters::NSCFSetSyntheticFrontEnd::Update() {
m_children.clear();
ValueObjectSP valobj_sp = m_backend.GetSP();
m_ptr_size = 0;
if (!valobj_sp)
- return false;
+ return CacheState::Invalid;
m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
if (!process_sp)
- return false;
+ return CacheState::Invalid;
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)
+ ? CacheState::Valid
+ : CacheState::Invalid;
}
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() {
+SyntheticChildrenFrontEnd::CacheState
+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 CacheState::Invalid;
if (!valobj_sp)
- return false;
+ return CacheState::Invalid;
m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
if (!process_sp)
- return false;
+ return CacheState::Invalid;
m_ptr_size = process_sp->GetAddressByteSize();
uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size;
Status error;
@@ -731,7 +734,7 @@ lldb_private::formatters::
process_sp->ReadMemory(data_location, m_data_64, sizeof(D64),
error);
}
- return error.Success();
+ return error.Success() ? CacheState::Valid : CacheState::Invalid;
}
template <typename D32, typename D64>
More information about the lldb-commits
mailing list