57 llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name)
override;
60 ExecutionContextRef m_exe_ctx_ref;
62 CompilerType m_pair_type;
76 llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name)
override;
84 ValueObject *m_ptr_obj =
nullptr;
89LibstdcppMapIteratorSyntheticFrontEnd::LibstdcppMapIteratorSyntheticFrontEnd(
102 TargetSP target_sp(valobj_sp->GetTargetSP());
107 bool is_64bit = (target_sp->GetArchitecture().GetAddressByteSize() == 8);
111 m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
113 ValueObjectSP _M_node_sp(valobj_sp->GetChildMemberWithName(
"_M_node"));
117 m_pair_address = _M_node_sp->GetValueAsUnsigned(0);
118 if (m_pair_address == 0)
121 m_pair_address += (is_64bit ? 32 : 16);
123 CompilerType my_type(valobj_sp->GetCompilerType());
124 if (my_type.GetNumTemplateArguments() >= 1) {
125 CompilerType pair_type = my_type.GetTypeTemplateArgument(0);
128 m_pair_type = pair_type;
135llvm::Expected<uint32_t>
136LibstdcppMapIteratorSyntheticFrontEnd::CalculateNumChildren() {
141LibstdcppMapIteratorSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) {
142 if (m_pair_address != 0 && m_pair_type) {
144 m_pair_sp = CreateValueObjectFromAddress(
"pair", m_pair_address,
145 m_exe_ctx_ref, m_pair_type);
147 return m_pair_sp->GetChildAtIndex(idx);
152llvm::Expected<size_t>
153LibstdcppMapIteratorSyntheticFrontEnd::GetIndexOfChildWithName(
157 if (name ==
"second")
159 return llvm::createStringError(
"Type has no child named '%s'",
163SyntheticChildrenFrontEnd *
166 return (valobj_sp ?
new LibstdcppMapIteratorSyntheticFrontEnd(valobj_sp)
180SyntheticChildrenFrontEnd *
183 return (valobj_sp ?
new VectorIteratorSyntheticFrontEnd(
184 valobj_sp, {ConstString(
"_M_current")})
190 llvm::ArrayRef<ConstString> item_names)
208 if (item_ptr->GetValueAsUnsigned(0) == 0)
214 item_ptr->GetCompilerType().GetPointeeType());
220llvm::Expected<uint32_t>
232llvm::Expected<size_t>
236 return llvm::createStringError(
"Type has no child named '%s'",
243 if (!ptr || !ptr->GetError().Success())
244 stream <<
"Summary Unavailable";
246 stream << ptr->GetSummaryAsCString();
251template <StringPr
inter::StringElementType element_type>
254 std::string prefix_token) {
257 if (!data_sp || !size_sp)
260 bool success =
false;
261 uint64_t size = size_sp->GetValueAsUnsigned(0, &success);
263 stream <<
"Summary Unavailable";
269 scratch_stream, summary_options, data_sp, size, prefix_token);
272 stream << scratch_stream.
GetData();
274 stream <<
"Summary Unavailable";
284 switch (*wchar_t_size) {
298template <StringElementType element_type>
300 switch (element_type) {
301 case StringElementType::ASCII:
303 case StringElementType::UTF8:
305 case StringElementType::UTF16:
307 case StringElementType::UTF32:
310 llvm_unreachable(
"invalid element type");
313template <StringPr
inter::StringElementType element_type>
333LibStdcppSharedPtrSyntheticFrontEnd::LibStdcppSharedPtrSyntheticFrontEnd(
340llvm::Expected<uint32_t>
341LibStdcppSharedPtrSyntheticFrontEnd::CalculateNumChildren() {
346LibStdcppSharedPtrSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) {
351 return m_ptr_obj->
GetSP();
367 auto backend = m_backend.GetSP();
371 auto valobj_sp = backend->GetNonSyntheticValue();
375 auto ptr_obj_sp = valobj_sp->GetChildMemberWithName(
"_M_ptr");
383 m_ptr_obj = cast_ptr_sp->
Clone(ConstString(
"pointer")).get();
388llvm::Expected<size_t>
389LibStdcppSharedPtrSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) {
390 if (name ==
"pointer")
393 if (name ==
"object" || name ==
"$$dereference$$")
396 return llvm::createStringError(
"Type has no child named '%s'",
400SyntheticChildrenFrontEnd *
403 return (valobj_sp ?
new LibStdcppSharedPtrSyntheticFrontEnd(valobj_sp)
413 ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName(
"_M_ptr"));
419 ValueObjectSP pi_sp = valobj_sp->GetChildAtNamePath({
"_M_refcount",
"_M_pi"});
424 uint64_t pi_addr = pi_sp->GetValueAsUnsigned(0, &success);
426 if (!success || pi_addr == 0)
429 int64_t shared_count = 0;
430 if (
auto count_sp = pi_sp->GetChildMemberWithName(
"_M_use_count")) {
432 shared_count = count_sp->GetValueAsSigned(0, &success);
436 stream.
Printf(
" strong=%" PRId64, shared_count);
440 if (
auto weak_count_sp = pi_sp->GetChildMemberWithName(
"_M_weak_count")) {
442 int64_t count = weak_count_sp->GetValueAsUnsigned(0, &success);
446 stream.
Printf(
" weak=%" PRId64, count - (shared_count != 0));
453 switch (index_byte_size) {
469 ValueObjectSP index_obj = valobj_sp->GetChildMemberWithName(
"_M_index");
470 ValueObjectSP data_obj = valobj_sp->GetChildMemberWithName(
"_M_u");
471 if (!index_obj || !data_obj)
474 auto index_bytes = index_obj->GetByteSize();
478 auto index = index_obj->GetValueAsUnsigned(0);
479 if (index == npos_value) {
480 stream.
Printf(
" No Value");
485 valobj_sp->GetCompilerType().GetCanonicalType().GetNonReferenceType();
488 if (index >= variant_type.GetNumTemplateArguments(
true)) {
489 stream.
Printf(
" <Invalid>");
493 auto active_type = variant_type.GetTypeTemplateArgument(index,
true);
494 stream <<
" Active Type = " << active_type.GetDisplayTypeName() <<
" ";
498static std::optional<int64_t>
504 int64_t value = value_sp->GetValueAsSigned(0, &success);
520 stream <<
"equivalent";
527 stream <<
"unordered";
545 stream <<
"equivalent";
static bool formatStringViewImpl(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options, std::string prefix_token)
static constexpr const char * getPrefixToken()
static std::optional< int64_t > LibStdcppExtractOrderingValue(ValueObject &valobj)
static uint64_t LibStdcppVariantNposValue(size_t index_byte_size)
StringPrinter::StringElementType StringElementType
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.
const char * GetData() const
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 GetSP()
virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name, bool can_create=true)
lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef< llvm::StringRef > names)
virtual lldb::ValueObjectSP Clone(ConstString new_name)
Creates a copy of the ValueObject with a new name and setting the current ValueObject as its parent.
virtual lldb::ValueObjectSP Dereference(Status &error)
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