26#include "llvm/Support/ErrorExtras.h"
59 llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name)
override;
62 ExecutionContextRef m_exe_ctx_ref;
64 CompilerType m_pair_type;
78 llvm::Expected<size_t> GetIndexOfChildWithName(ConstString 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(
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(ConstString name) {
339 if (name ==
"pointer")
342 if (name ==
"object" || name ==
"$$dereference$$")
345 return llvm::createStringErrorV(
"type has no child named '{0}'", name);
348SyntheticChildrenFrontEnd *
351 return (valobj_sp ?
new LibStdcppSharedPtrSyntheticFrontEnd(valobj_sp)
361 ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName(
"_M_ptr"));
367 ValueObjectSP pi_sp = valobj_sp->GetChildAtNamePath({
"_M_refcount",
"_M_pi"});
372 uint64_t pi_addr = pi_sp->GetValueAsUnsigned(0, &success);
374 if (!success || pi_addr == 0)
377 int64_t shared_count = 0;
378 if (
auto count_sp = pi_sp->GetChildMemberWithName(
"_M_use_count")) {
380 shared_count = count_sp->GetValueAsSigned(0, &success);
384 stream.
Printf(
" strong=%" PRId64, shared_count);
388 if (
auto weak_count_sp = pi_sp->GetChildMemberWithName(
"_M_weak_count")) {
390 int64_t count = weak_count_sp->GetValueAsUnsigned(0, &success);
394 stream.
Printf(
" weak=%" PRId64, count - (shared_count != 0));
401 switch (index_byte_size) {
417 ValueObjectSP index_obj = valobj_sp->GetChildMemberWithName(
"_M_index");
418 ValueObjectSP data_obj = valobj_sp->GetChildMemberWithName(
"_M_u");
419 if (!index_obj || !data_obj)
422 auto index_bytes_or_err = index_obj->GetByteSize();
423 if (!index_bytes_or_err) {
425 index_bytes_or_err.takeError(),
426 "failed to get variant index byte size: {0}");
430 auto index = index_obj->GetValueAsUnsigned(0);
431 if (index == npos_value) {
432 stream.
Printf(
" No Value");
437 valobj_sp->GetCompilerType().GetCanonicalType().GetNonReferenceType();
440 if (index >= variant_type.GetNumTemplateArguments(
true)) {
441 stream.
Printf(
" <Invalid>");
445 auto active_type = variant_type.GetTypeTemplateArgument(index,
true);
446 stream <<
" Active Type = " << active_type.GetDisplayTypeName() <<
" ";
450static std::optional<int64_t>
456 int64_t value = value_sp->GetValueAsSigned(0, &success);
472 stream <<
"equivalent";
479 stream <<
"unordered";
497 stream <<
"equivalent";
535 ValueObjectSP file_sp = impl_sp->GetChildMemberWithName(
"_M_file_name");
537 impl_sp->GetChildMemberWithName(
"_M_function_name");
538 ValueObjectSP line_sp = impl_sp->GetChildMemberWithName(
"_M_line");
539 ValueObjectSP column_sp = impl_sp->GetChildMemberWithName(
"_M_column");
541 if (!file_sp || !function_sp || !line_sp || !column_sp)
544 bool success =
false;
545 uint64_t line = line_sp->GetValueAsUnsigned(0, &success);
549 uint64_t column = column_sp->GetValueAsUnsigned(0, &success);
553 const char *file = file_sp->GetSummaryAsCString();
554 stream.
Format(
"{0}:{1}:{2}", file ? file :
"<unknown>", line, column);
556 if (
const char *function = function_sp->GetSummaryAsCString())
557 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 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 ...
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()
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