54 llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name)
override;
57 ExecutionContextRef m_exe_ctx_ref;
59 CompilerType m_pair_type;
73 llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name)
override;
82 ValueObject *m_ptr_obj =
nullptr;
87LibstdcppMapIteratorSyntheticFrontEnd::LibstdcppMapIteratorSyntheticFrontEnd(
100 TargetSP target_sp(valobj_sp->GetTargetSP());
105 bool is_64bit = (target_sp->GetArchitecture().GetAddressByteSize() == 8);
109 m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
111 ValueObjectSP _M_node_sp(valobj_sp->GetChildMemberWithName(
"_M_node"));
115 m_pair_address = _M_node_sp->GetValueAsUnsigned(0);
116 if (m_pair_address == 0)
119 m_pair_address += (is_64bit ? 32 : 16);
121 CompilerType my_type(valobj_sp->GetCompilerType());
122 if (my_type.GetNumTemplateArguments() >= 1) {
123 CompilerType pair_type = my_type.GetTypeTemplateArgument(0);
126 m_pair_type = pair_type;
133llvm::Expected<uint32_t>
134LibstdcppMapIteratorSyntheticFrontEnd::CalculateNumChildren() {
139LibstdcppMapIteratorSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) {
140 if (m_pair_address != 0 && m_pair_type) {
142 m_pair_sp = CreateValueObjectFromAddress(
"pair", m_pair_address,
143 m_exe_ctx_ref, m_pair_type);
145 return m_pair_sp->GetChildAtIndex(idx);
150llvm::Expected<size_t>
151LibstdcppMapIteratorSyntheticFrontEnd::GetIndexOfChildWithName(
155 if (name ==
"second")
157 return llvm::createStringError(
"Type has no child named '%s'",
161SyntheticChildrenFrontEnd *
164 return (valobj_sp ?
new LibstdcppMapIteratorSyntheticFrontEnd(valobj_sp)
188 llvm::ArrayRef<ConstString> item_names)
209 if (item_ptr->GetValueAsUnsigned(0) == 0)
215 item_ptr->GetCompilerType().GetPointeeType());
221llvm::Expected<uint32_t>
233llvm::Expected<size_t>
237 return llvm::createStringError(
"Type has no child named '%s'",
244 if (!ptr || !ptr->GetError().Success())
245 stream <<
"Summary Unavailable";
247 stream << ptr->GetSummaryAsCString();
252LibStdcppSharedPtrSyntheticFrontEnd::LibStdcppSharedPtrSyntheticFrontEnd(
259llvm::Expected<uint32_t>
260LibStdcppSharedPtrSyntheticFrontEnd::CalculateNumChildren() {
265LibStdcppSharedPtrSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) {
270 return m_ptr_obj->GetSP();
286 auto backend = m_backend.GetSP();
290 auto valobj_sp = backend->GetNonSyntheticValue();
294 auto ptr_obj_sp = valobj_sp->GetChildMemberWithName(
"_M_ptr");
302 m_ptr_obj = cast_ptr_sp->Clone(
ConstString(
"pointer")).get();
307llvm::Expected<size_t>
308LibStdcppSharedPtrSyntheticFrontEnd::GetIndexOfChildWithName(
ConstString name) {
309 if (name ==
"pointer")
312 if (name ==
"object" || name ==
"$$dereference$$")
315 return llvm::createStringError(
"Type has no child named '%s'",
322 return (valobj_sp ?
new LibStdcppSharedPtrSyntheticFrontEnd(valobj_sp)
332 ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName(
"_M_ptr"));
338 ValueObjectSP pi_sp = valobj_sp->GetChildAtNamePath({
"_M_refcount",
"_M_pi"});
343 uint64_t pi_addr = pi_sp->GetValueAsUnsigned(0, &success);
345 if (!success || pi_addr == 0)
348 int64_t shared_count = 0;
349 if (
auto count_sp = pi_sp->GetChildMemberWithName(
"_M_use_count")) {
351 shared_count = count_sp->GetValueAsSigned(0, &success);
355 stream.
Printf(
" strong=%" PRId64, shared_count);
359 if (
auto weak_count_sp = pi_sp->GetChildMemberWithName(
"_M_weak_count")) {
361 int64_t count = weak_count_sp->GetValueAsUnsigned(0, &success);
365 stream.
Printf(
" weak=%" PRId64, count - (shared_count != 0));
372 switch (index_byte_size) {
388 ValueObjectSP index_obj = valobj_sp->GetChildMemberWithName(
"_M_index");
389 ValueObjectSP data_obj = valobj_sp->GetChildMemberWithName(
"_M_u");
390 if (!index_obj || !data_obj)
393 auto index_bytes = index_obj->GetByteSize();
397 auto index = index_obj->GetValueAsUnsigned(0);
398 if (index == npos_value) {
399 stream.
Printf(
" No Value");
404 valobj_sp->GetCompilerType().GetCanonicalType().GetNonReferenceType();
407 if (index >= variant_type.GetNumTemplateArguments(
true)) {
408 stream.
Printf(
" <Invalid>");
412 auto active_type = variant_type.GetTypeTemplateArgument(index,
true);
413 stream <<
" Active Type = " << active_type.GetDisplayTypeName() <<
" ";
static uint64_t LibStdcppVariantNposValue(size_t index_byte_size)
static std::optional< size_t > CalculateNumChildren(CompilerType container_elem_type, uint64_t num_elements, CompilerType element_type)
Calculates the number of elements stored in a container (with element type 'container_elem_type') as ...
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
bool Fail() const
Test for error condition.
bool Success() const
Test for success condition.
A stream class that can stream formatted output to a file.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
SyntheticChildrenFrontEnd(ValueObject &backend)
lldb::ValueObjectSP CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx, CompilerType type, bool do_deref=true)
lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef< llvm::StringRef > names)
virtual lldb::ValueObjectSP GetNonSyntheticValue()
A class that represents a running process on the host machine.
ChildCacheState
Specifies if children need to be re-computed after a call to SyntheticChildrenFrontEnd::Update.
@ eRefetch
Children need to be recomputed dynamically.
@ eReuse
Children did not change and don't need to be recomputed; re-use what we computed the last time we cal...
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::Target > TargetSP