30 GenericBitsetFrontEnd(ValueObject &valobj, StdLib stdlib);
34 return m_elements.size();
39 llvm::StringRef GetDataContainerMemberName();
48 std::vector<ValueObjectSP> m_elements;
49 ValueObject *m_first =
nullptr;
50 CompilerType m_bool_type;
52 uint8_t m_byte_size = 0;
57GenericBitsetFrontEnd::GenericBitsetFrontEnd(
ValueObject &valobj, StdLib stdlib)
60 if (
auto target_sp = m_backend.GetTargetSP()) {
61 m_byte_order = target_sp->GetArchitecture().GetByteOrder();
62 m_byte_size = target_sp->GetArchitecture().GetAddressByteSize();
67llvm::StringRef GenericBitsetFrontEnd::GetDataContainerMemberName() {
68 static constexpr llvm::StringLiteral s_libcxx_case(
"__first_");
69 static constexpr llvm::StringLiteral s_libstdcpp_case(
"_M_w");
70 static constexpr llvm::StringLiteral s_msvcstl_case(
"_Array");
74 case StdLib::LibStdcpp:
75 return s_libstdcpp_case;
77 return s_msvcstl_case;
79 llvm_unreachable(
"Unknown StdLib enum");
92 if (
auto arg = m_backend.GetCompilerType().GetIntegralTemplateArgument(0))
93 size = arg->value.GetAPSInt().getLimitedValue();
97 ConstString type_name =
98 m_backend.GetCompilerType().GetTypeName(
true);
100 assert(size_str.starts_with(
"bitset<") && size_str.ends_with(
">"));
102 size_str.consume_front(
"bitset<");
103 size_str.consume_back(
">");
104 if (size_str.getAsInteger(10, size))
114ValueObjectSP GenericBitsetFrontEnd::GetChildAtIndex(uint32_t idx) {
115 if (idx >= m_elements.size() || !m_first)
119 return m_elements[idx];
121 ExecutionContext ctx = m_backend.GetExecutionContextRef().Lock(
false);
126 std::optional<uint64_t> bit_size = llvm::expectedToOptional(
128 if (!bit_size || *bit_size == 0)
133 chunk = m_first->
GetSP();
138 std::optional<uint64_t> bit_size = llvm::expectedToOptional(
140 if (!bit_size || *bit_size == 0)
142 size_t chunk_idx = idx % *bit_size;
143 uint8_t value = !!(chunk->GetValueAsUnsigned(0) & (uint64_t(1) << chunk_idx));
144 DataExtractor data(&value,
sizeof(value), m_byte_order, m_byte_size);
146 m_elements[idx] = CreateChildValueObjectFromData(
147 llvm::formatv(
"[{0}]", idx).str(), data, ctx, m_bool_type);
149 return m_elements[idx];
155 return new GenericBitsetFrontEnd(*valobj_sp,
156 GenericBitsetFrontEnd::StdLib::LibStdcpp);
163 return new GenericBitsetFrontEnd(*valobj_sp,
164 GenericBitsetFrontEnd::StdLib::LibCxx);
170 return valobj_sp->GetChildMemberWithName(
"_Array") !=
nullptr;
177 return new GenericBitsetFrontEnd(*valobj_sp,
178 GenericBitsetFrontEnd::StdLib::MsvcStl);
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 ...
bool IsArrayType(CompilerType *element_type=nullptr, uint64_t *size=nullptr, bool *is_incomplete=nullptr) const
llvm::Expected< uint64_t > GetBitSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bits.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
ExecutionContextScope * GetBestExecutionContextScope() const
virtual lldb::ValueObjectSP GetChildAtIndex(uint32_t idx, bool can_create=true)
lldb::ValueObjectSP GetSP()
virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name, bool can_create=true)
lldb::TargetSP GetTargetSP() const
CompilerType GetCompilerType()
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.
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
ByteOrder
Byte ordering definitions.
std::shared_ptr< lldb_private::Target > TargetSP