38 ValueObject &obj, llvm::ArrayRef<ConstString> alternative_names) {
54 value = first_child->GetChildMemberWithName(
"__value_");
69 value = second_child->GetChildMemberWithName(
"__value_");
90 if (process ==
nullptr)
102 case CPPLanguageRuntime::LibCppStdFunctionCallableCase::Invalid:
106 case CPPLanguageRuntime::LibCppStdFunctionCallableCase::Lambda:
108 " Lambda in File %s at Line %u",
112 case CPPLanguageRuntime::LibCppStdFunctionCallableCase::CallableObject:
114 " Function in File %s at Line %u",
118 case CPPLanguageRuntime::LibCppStdFunctionCallableCase::FreeOrMemberFunction:
119 stream.
Printf(
" Function = %s ",
132 ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName(
"__ptr_"));
134 valobj_sp->GetChildAtNamePath({
"__cntrl_",
"__shared_owners_"}));
136 valobj_sp->GetChildAtNamePath({
"__cntrl_",
"__shared_weak_owners_"}));
141 if (ptr_sp->GetValueAsUnsigned(0) == 0) {
145 bool print_pointee =
false;
148 if (pointee_sp &&
error.Success()) {
149 if (pointee_sp->DumpPrintableRepresentation(
152 ValueObject::PrintableRepresentationSpecialCases::eDisable,
154 print_pointee =
true;
157 stream.
Printf(
"ptr = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0));
161 stream.
Printf(
" strong=%" PRIu64, 1 + count_sp->GetValueAsUnsigned(0));
164 stream.
Printf(
" weak=%" PRIu64, 1 + weakcount_sp->GetValueAsUnsigned(0));
175 ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName(
"__ptr_"));
183 if (ptr_sp->GetValueAsUnsigned(0) == 0) {
187 bool print_pointee =
false;
190 if (pointee_sp &&
error.Success()) {
191 if (pointee_sp->DumpPrintableRepresentation(
194 ValueObject::PrintableRepresentationSpecialCases::eDisable,
196 print_pointee =
true;
199 stream.
Printf(
"ptr = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0));
236 m_pair_ptr =
nullptr;
242 TargetSP target_sp(valobj_sp->GetTargetSP());
255 m_pair_ptr = valobj_sp
256 ->GetValueForExpressionPath(
257 ".__i_.__ptr_->__value_",
nullptr,
nullptr,
259 .DontCheckDotVsArrowSyntax()
260 .SetSyntheticChildrenTraversal(
262 SyntheticChildrenTraversal::None),
267 m_pair_ptr = valobj_sp
268 ->GetValueForExpressionPath(
269 ".__i_.__ptr_",
nullptr,
nullptr,
271 .DontCheckDotVsArrowSyntax()
272 .SetSyntheticChildrenTraversal(
274 SyntheticChildrenTraversal::None),
278 auto __i_(valobj_sp->GetChildMemberWithName(
"__i_"));
280 m_pair_ptr =
nullptr;
284 __i_->GetCompilerType().GetTypeTemplateArgument(0));
286 uint64_t bit_offset_ptr;
287 uint32_t bitfield_bit_size_ptr;
288 bool is_bitfield_ptr;
290 0, name, &bit_offset_ptr, &bitfield_bit_size_ptr, &is_bitfield_ptr);
292 m_pair_ptr =
nullptr;
297 m_pair_ptr =
nullptr;
319 CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier(
328 {
"payload", pair_type}});
329 std::optional<uint64_t> size = tree_node_type.
GetByteSize(
nullptr);
333 ProcessSP process_sp(target_sp->GetProcessSP());
335 process_sp->ReadMemory(addr, buffer_sp->GetBytes(),
336 buffer_sp->GetByteSize(),
error);
339 DataExtractor extractor(buffer_sp, process_sp->GetByteOrder(),
340 process_sp->GetAddressByteSize());
341 auto pair_sp = CreateValueObjectFromData(
342 "pair", extractor, valobj_sp->GetExecutionContextRef(),
345 m_pair_sp = pair_sp->GetChildAtIndex(4);
362 return m_pair_ptr->GetChildAtIndex(idx);
364 return m_pair_sp->GetChildAtIndex(idx);
377 if (name ==
"second")
405 m_iter_ptr =
nullptr;
411 TargetSP target_sp(valobj_sp->GetTargetSP());
423 SyntheticChildrenTraversal::None);
432 ->GetValueForExpressionPath(
".__i_.__node_",
nullptr,
nullptr,
433 exprPathOptions,
nullptr)
437 auto iter_child(valobj_sp->GetChildMemberWithName(
"__i_"));
439 m_iter_ptr =
nullptr;
444 .GetTypeTemplateArgument(0)
450 uint64_t bit_offset_ptr;
451 uint32_t bitfield_bit_size_ptr;
452 bool is_bitfield_ptr;
455 0, name, &bit_offset_ptr, &bitfield_bit_size_ptr, &is_bitfield_ptr);
457 m_iter_ptr =
nullptr;
462 m_iter_ptr =
nullptr;
484 CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier(
489 {
"__value_", pair_type}});
490 std::optional<uint64_t> size = tree_node_type.
GetByteSize(
nullptr);
494 ProcessSP process_sp(target_sp->GetProcessSP());
496 process_sp->ReadMemory(addr, buffer_sp->GetBytes(),
497 buffer_sp->GetByteSize(),
error);
500 DataExtractor extractor(buffer_sp, process_sp->GetByteOrder(),
501 process_sp->GetAddressByteSize());
502 auto pair_sp = CreateValueObjectFromData(
503 "pair", extractor, valobj_sp->GetExecutionContextRef(), tree_node_type);
505 m_pair_sp = pair_sp->GetChildAtIndex(2);
519 return m_pair_sp->GetChildAtIndex(idx);
532 if (name ==
"second")
570 return (m_cntrl ? 1 : 0);
584 return valobj_sp->GetChildMemberWithName(
"__ptr_");
587 if (
auto ptr_sp = valobj_sp->GetChildMemberWithName(
"__ptr_")) {
590 valobj_sp->GetCompilerType()
591 .GetTypeTemplateArgument(0).GetPointerType();
610 TargetSP target_sp(valobj_sp->GetTargetSP());
616 m_cntrl = cntrl_sp.get();
628 if (name ==
"__ptr_")
630 if (name ==
"$$dereference$$")
665 return m_deleter_sp ? 2 : 1;
676 return m_value_ptr_sp;
683 auto value_sp = m_value_ptr_sp->Dereference(status);
697 ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName(
"__ptr_"));
704 if (value_pointer_sp)
705 m_value_ptr_sp = value_pointer_sp->Clone(
ConstString(
"pointer"));
709 m_deleter_sp = deleter_sp->Clone(
ConstString(
"deleter"));
721 if (name ==
"pointer")
723 if (name ==
"deleter")
725 if (name ==
"$$dereference$$")
736 stream.
Printf(
"0x%016" PRIx64
" ", value);
739 nullptr,
nullptr, &valobj,
false,
false);
744enum class StringLayout { CSD, DSC };
750static std::optional<std::pair<uint64_t, ValueObjectSP>>
753 if (!valobj_r_sp || !valobj_r_sp->GetError().Success())
758 ValueObjectSP valobj_r_base_sp = valobj_r_sp->GetChildAtIndex(0);
759 if (!valobj_r_base_sp)
763 valobj_r_base_sp->GetChildMemberWithName(
"__value_");
771 StringLayout layout =
l->GetIndexOfChildWithName(
"__data_") == 0
775 bool short_mode =
false;
777 bool using_bitmasks =
true;
780 uint64_t size_mode_value = 0;
782 ValueObjectSP short_sp = valobj_rep_sp->GetChildMemberWithName(
"__s");
786 ValueObjectSP is_long = short_sp->GetChildMemberWithName(
"__is_long_");
787 ValueObjectSP size_sp = short_sp->GetChildMemberWithName(
"__size_");
792 using_bitmasks =
false;
793 short_mode = !is_long->GetValueAsUnsigned(0);
794 size = size_sp->GetValueAsUnsigned(0);
797 size_mode_value = size_sp->GetValueAsUnsigned(0);
798 uint8_t mode_mask = layout == StringLayout::DSC ? 0x80 : 1;
799 short_mode = (size_mode_value & mode_mask) == 0;
803 ValueObjectSP location_sp = short_sp->GetChildMemberWithName(
"__data_");
805 size = (layout == StringLayout::DSC) ? size_mode_value
806 : ((size_mode_value >> 1) % 256);
812 const std::optional<uint64_t> max_bytes =
813 location_sp->GetCompilerType().GetByteSize(
815 if (!max_bytes || size > *max_bytes || !location_sp)
818 return std::make_pair(size, location_sp);
825 if (!size_vo || !location_sp || !capacity_vo)
829 if (!using_bitmasks && layout == StringLayout::CSD)
834 return std::make_pair(size, location_sp);
849 if (summary_options.
GetCapping() == TypeSummaryCapping::eTypeSummaryCapped) {
850 const auto max_size = valobj.
GetTargetSP()->GetMaximumSizeOfStringSummary();
851 if (size > max_size) {
858 const size_t bytes_read = location_sp->GetPointeeData(extractor, 0, size);
859 if (bytes_read < size)
873 options.
SetData(std::move(extractor));
880 switch (*wchar_t_size) {
883 lldb_private::formatters::StringPrinter::StringElementType::UTF8>(
889 lldb_private::formatters::StringPrinter::StringElementType::UTF16>(
895 lldb_private::formatters::StringPrinter::StringElementType::UTF32>(
909 std::tie(size, location_sp) = *string_info;
911 return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options,
915template <StringPr
inter::StringElementType element_type>
932 if (summary_options.
GetCapping() == TypeSummaryCapping::eTypeSummaryCapped) {
933 const auto max_size = valobj.
GetTargetSP()->GetMaximumSizeOfStringSummary();
934 if (size > max_size) {
942 const size_t bytes_read = location_sp->GetPointeeData(extractor, 0, size);
943 if (bytes_read < size)
946 options.
SetData(std::move(extractor));
949 if (prefix_token.empty())
956 return StringPrinter::ReadBufferAndDumpToStream<element_type>(options);
959template <StringPr
inter::StringElementType element_type>
963 std::string prefix_token) {
969 std::tie(size, location_sp) = *string_info;
971 return LibcxxStringSummaryProvider<element_type>(
972 valobj, stream, summary_options, prefix_token, location_sp, size);
974template <StringPr
inter::StringElementType element_type>
977 std::string prefix_token) {
979 const bool success = LibcxxStringSummaryProvider<element_type>(
980 valobj, scratch_stream, summary_options, prefix_token);
982 stream << scratch_stream.
GetData();
984 stream <<
"Summary Unavailable";
991 return formatStringImpl<StringPrinter::StringElementType::ASCII>(
992 valobj, stream, summary_options,
"");
998 return formatStringImpl<StringPrinter::StringElementType::UTF16>(
999 valobj, stream, summary_options,
"u");
1005 return formatStringImpl<StringPrinter::StringElementType::UTF32>(
1006 valobj, stream, summary_options,
"U");
1009static std::tuple<bool, ValueObjectSP, size_t>
1015 if (!dataobj || !sizeobj)
1016 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
1018 if (!dataobj->GetError().Success() || !sizeobj->GetError().Success())
1019 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
1021 bool success{
false};
1022 uint64_t size = sizeobj->GetValueAsUnsigned(0, &success);
1024 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
1026 return std::make_tuple(
true,dataobj,size);
1029template <StringPr
inter::StringElementType element_type>
1032 std::string prefix_token) {
1040 stream <<
"Summary Unavailable";
1044 return LibcxxStringSummaryProvider<element_type>(
1045 valobj, stream, summary_options, prefix_token, dataobj, size);
1051 return formatStringViewImpl<StringPrinter::StringElementType::ASCII>(
1052 valobj, stream, summary_options,
"");
1058 return formatStringViewImpl<StringPrinter::StringElementType::UTF16>(
1059 valobj, stream, summary_options,
"u");
1065 return formatStringViewImpl<StringPrinter::StringElementType::UTF32>(
1066 valobj, stream, summary_options,
"U");
1079 stream <<
"Summary Unavailable";
1084 return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options,
static llvm::raw_ostream & error(Stream &strm)
static bool formatStringImpl(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options, std::string prefix_token)
static std::optional< std::pair< uint64_t, ValueObjectSP > > ExtractLibcxxStringInfo(ValueObject &valobj)
Determine the size in bytes of valobj (a libc++ std::string object) and extract its data payload.
static bool formatStringViewImpl(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options, std::string prefix_token)
static bool LibcxxStringSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options, std::string prefix_token, ValueObjectSP location_sp, uint64_t size)
static std::tuple< bool, ValueObjectSP, size_t > LibcxxExtractStringViewData(ValueObject &valobj)
LibCppStdFunctionCallableInfo FindLibCppStdFunctionCallableInfo(lldb::ValueObjectSP &valobj_sp)
static CPPLanguageRuntime * Get(Process &process)
std::shared_ptr< TypeSystemType > dyn_cast_or_null()
Return a shared_ptr<TypeSystemType> if dyn_cast succeeds.
Generic representation of a type in a programming language.
CompilerType GetTypeTemplateArgument(size_t idx, bool expand_pack=false) const
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
std::optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
CompilerType GetFieldAtIndex(size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) const
A uniqued constant string class.
const char * GetCString() const
Get the string value as a C string.
A subclass of DataBuffer that stores a data buffer on the heap.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
ExecutionContextScope * GetBestExecutionContextScope() const
Process * GetProcessPtr() const
Returns a pointer to the process object.
const ConstString & GetFilename() const
Filename string const get accessor.
A plug-in interface definition class for debugging a process.
static lldb::TypeSystemClangSP GetForTarget(Target &target, std::optional< IsolatedASTKind > ast_kind=DefaultAST, bool create_on_demand=true)
Returns the scratch TypeSystemClang for the given target.
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.
ConstString GetName() const
lldb::TypeSummaryCapping GetCapping() const
A TypeSystem implementation based on Clang.
size_t GetNumChildren(uint32_t max=UINT32_MAX)
virtual uint64_t GetValueAsUnsigned(uint64_t fail_value, bool *success=nullptr)
virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name, bool can_create=true)
virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create=true)
lldb::TargetSP GetTargetSP() const
virtual lldb::ValueObjectSP GetNonSyntheticValue()
@ eValueObjectRepresentationStyleSummary
#define LLDB_INVALID_ADDRESS
#define LLDB_INVALID_OFFSET
A class that represents a running process on the host machine.
@ eBasicTypeUnsignedLongLong
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
std::shared_ptr< lldb_private::Target > TargetSP
lldb::addr_t member_f_pointer_value
LineEntry callable_line_entry
LibCppStdFunctionCallableCase callable_case
FileSpec file
The source file, possibly mapped by the target.source-map setting.
uint32_t line
The source line number, or zero if there is no line number information.
GetValueForExpressionPathOptions & SetSyntheticChildrenTraversal(SyntheticChildrenTraversal traverse)
GetValueForExpressionPathOptions & DontCheckDotVsArrowSyntax()