26#include "llvm/Support/ErrorExtras.h"
59 llvm::Expected<size_t> GetIndexOfChildWithName(llvm::StringRef name)
override;
62 ExecutionContextRef m_exe_ctx_ref;
64 CompilerType m_pair_type;
78 llvm::Expected<size_t> GetIndexOfChildWithName(llvm::StringRef name)
override;
86 ValueObject *m_ptr_obj =
nullptr;
91LibstdcppMapIteratorSyntheticFrontEnd::LibstdcppMapIteratorSyntheticFrontEnd(
104 TargetSP target_sp(valobj_sp->GetTargetSP());
109 bool is_64bit = (target_sp->GetArchitecture().GetAddressByteSize() == 8);
113 m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
115 ValueObjectSP _M_node_sp(valobj_sp->GetChildMemberWithName(
"_M_node"));
119 m_pair_address = _M_node_sp->GetValueAsUnsigned(0);
120 if (m_pair_address == 0)
123 m_pair_address += (is_64bit ? 32 : 16);
125 CompilerType my_type(valobj_sp->GetCompilerType());
126 if (my_type.GetNumTemplateArguments() >= 1) {
127 CompilerType pair_type = my_type.GetTypeTemplateArgument(0);
130 m_pair_type = pair_type;
137llvm::Expected<uint32_t>
138LibstdcppMapIteratorSyntheticFrontEnd::CalculateNumChildren() {
143LibstdcppMapIteratorSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) {
144 if (m_pair_address != 0 && m_pair_type) {
146 m_pair_sp = CreateChildValueObjectFromAddress(
"pair", m_pair_address,
147 m_exe_ctx_ref, m_pair_type);
149 return m_pair_sp->GetChildAtIndex(idx);
154llvm::Expected<size_t>
155LibstdcppMapIteratorSyntheticFrontEnd::GetIndexOfChildWithName(
156 llvm::StringRef name) {
159 if (name ==
"second")
161 return llvm::createStringErrorV(
"type has no child named '{0}'", name);
164SyntheticChildrenFrontEnd *
167 return (valobj_sp ?
new LibstdcppMapIteratorSyntheticFrontEnd(valobj_sp)
181SyntheticChildrenFrontEnd *
184 return (valobj_sp ?
new VectorIteratorSyntheticFrontEnd(
185 valobj_sp, {ConstString(
"_M_current")})
192 if (!ptr || !ptr->GetError().Success())
193 stream <<
"Summary Unavailable";
195 stream << ptr->GetSummaryAsCString();
200template <StringPr
inter::StringElementType element_type>
203 std::string prefix_token) {
206 if (!data_sp || !size_sp)
209 bool success =
false;
210 uint64_t size = size_sp->GetValueAsUnsigned(0, &success);
212 stream <<
"Summary Unavailable";
218 scratch_stream, summary_options, data_sp, size, prefix_token);
221 stream << scratch_stream.
GetData();
223 stream <<
"Summary Unavailable";
233 switch (*wchar_t_size) {
247template <StringElementType element_type>
249 switch (element_type) {
250 case StringElementType::ASCII:
252 case StringElementType::UTF8:
254 case StringElementType::UTF16:
256 case StringElementType::UTF32:
259 llvm_unreachable(
"invalid element type");
262template <StringPr
inter::StringElementType element_type>
282LibStdcppSharedPtrSyntheticFrontEnd::LibStdcppSharedPtrSyntheticFrontEnd(
289llvm::Expected<uint32_t>
290LibStdcppSharedPtrSyntheticFrontEnd::CalculateNumChildren() {
295LibStdcppSharedPtrSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) {
300 return m_ptr_obj->
GetSP();
316 auto backend = m_backend.GetSP();
320 auto valobj_sp = backend->GetNonSyntheticValue();
324 auto ptr_obj_sp = valobj_sp->GetChildMemberWithName(
"_M_ptr");
332 m_ptr_obj = cast_ptr_sp->
Clone(
"pointer").get();
337llvm::Expected<size_t>
338LibStdcppSharedPtrSyntheticFrontEnd::GetIndexOfChildWithName(
339 llvm::StringRef name) {
340 if (name ==
"pointer")
343 if (name ==
"object" || name ==
"$$dereference$$")
346 return llvm::createStringErrorV(
"type has no child named '{0}'", name);
349SyntheticChildrenFrontEnd *
352 return (valobj_sp ?
new LibStdcppSharedPtrSyntheticFrontEnd(valobj_sp)
357 bool is_atomic_child) {
362 if (!is_atomic_child)
363 return refcount_sp->GetChildMemberWithName(
"_M_pi");
365 ValueObjectSP val_sp = refcount_sp->GetChildMemberWithName(
"_M_val");
366 if (!val_sp || !val_sp->GetCompilerType())
370 if (!val_sp->GetCompilerType().IsScalarType()) {
371 val_sp = val_sp->GetChildMemberWithName(
"_M_i");
377 bool is_success =
false;
378 uint64_t raw_val = val_sp->GetValueAsUnsigned(0, &is_success);
379 if (!is_success || raw_val == 0)
387 refcount_sp->GetCompilerType().GetDirectNestedTypeWithName(
"pointer");
388 if (!ref_count_ptr_type)
398 bool is_atomic_child) {
403 ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName(
"_M_ptr"));
414 uint64_t pi_addr = pi_sp->GetValueAsUnsigned(0, &success);
416 if (!success || pi_addr == 0)
419 int64_t shared_count = 0;
420 if (
auto count_sp = pi_sp->GetChildMemberWithName(
"_M_use_count")) {
422 shared_count = count_sp->GetValueAsSigned(0, &success);
426 stream.
Printf(
" strong=%" PRId64, shared_count);
430 if (
auto weak_count_sp = pi_sp->GetChildMemberWithName(
"_M_weak_count")) {
432 int64_t count = weak_count_sp->GetValueAsUnsigned(0, &success);
436 stream.
Printf(
" weak=%" PRId64, count - (shared_count != 0));
443 switch (index_byte_size) {
459 ValueObjectSP index_obj = valobj_sp->GetChildMemberWithName(
"_M_index");
460 ValueObjectSP data_obj = valobj_sp->GetChildMemberWithName(
"_M_u");
461 if (!index_obj || !data_obj)
464 auto index_bytes_or_err = index_obj->GetByteSize();
465 if (!index_bytes_or_err) {
467 index_bytes_or_err.takeError(),
468 "failed to get variant index byte size: {0}");
472 auto index = index_obj->GetValueAsUnsigned(0);
473 if (index == npos_value) {
474 stream.
Printf(
" No Value");
479 valobj_sp->GetCompilerType().GetCanonicalType().GetNonReferenceType();
482 if (index >= variant_type.GetNumTemplateArguments(
true)) {
483 stream.
Printf(
" <Invalid>");
487 auto active_type = variant_type.GetTypeTemplateArgument(index,
true);
488 stream <<
" Active Type = " << active_type.GetDisplayTypeName() <<
" ";
492static std::optional<int64_t>
498 int64_t value = value_sp->GetValueAsSigned(0, &success);
514 stream <<
"equivalent";
521 stream <<
"unordered";
539 stream <<
"equivalent";
577 ValueObjectSP file_sp = impl_sp->GetChildMemberWithName(
"_M_file_name");
579 impl_sp->GetChildMemberWithName(
"_M_function_name");
580 ValueObjectSP line_sp = impl_sp->GetChildMemberWithName(
"_M_line");
581 ValueObjectSP column_sp = impl_sp->GetChildMemberWithName(
"_M_column");
583 if (!file_sp || !function_sp || !line_sp || !column_sp)
586 bool success =
false;
587 uint64_t line = line_sp->GetValueAsUnsigned(0, &success);
591 uint64_t column = column_sp->GetValueAsUnsigned(0, &success);
595 const char *file = file_sp->GetSummaryAsCString();
596 stream.
Format(
"{0}:{1}:{2}", file ? file :
"<unknown>", line, column);
598 if (
const char *function = function_sp->GetSummaryAsCString())
599 stream.
Printf(
" (%s)", function);
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 ValueObjectSP GetReferenceCountPointer(ValueObject &parent, bool is_atomic_child)
static uint64_t LibStdcppVariantNposValue(size_t index_byte_size)
#define LLDB_LOG_ERROR(log, error,...)
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 ...
Generic representation of a type in a programming language.
bool Success() const
Test for success condition.
const char * GetData() const
A stream class that can stream formatted output to a file.
void Format(const char *format, Args &&... args)
Forwards the arguments to llvm::formatv and writes to the stream.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
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(llvm::StringRef 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()
const ExecutionContextRef & GetExecutionContextRef() const
static lldb::ValueObjectSP CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx, CompilerType type, bool do_deref=true, ValueObject *parent=nullptr)
Given an address either create a value object containing the value at that address,...
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
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