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));
237 m_pair_ptr =
nullptr;
243 TargetSP target_sp(valobj_sp->GetTargetSP());
256 m_pair_ptr = valobj_sp
257 ->GetValueForExpressionPath(
258 ".__i_.__ptr_->__value_",
nullptr,
nullptr,
260 .DontCheckDotVsArrowSyntax()
261 .SetSyntheticChildrenTraversal(
263 SyntheticChildrenTraversal::None),
268 m_pair_ptr = valobj_sp
269 ->GetValueForExpressionPath(
270 ".__i_.__ptr_",
nullptr,
nullptr,
272 .DontCheckDotVsArrowSyntax()
273 .SetSyntheticChildrenTraversal(
275 SyntheticChildrenTraversal::None),
279 auto __i_(valobj_sp->GetChildMemberWithName(
"__i_"));
281 m_pair_ptr =
nullptr;
285 __i_->GetCompilerType().GetTypeTemplateArgument(0));
287 uint64_t bit_offset_ptr;
288 uint32_t bitfield_bit_size_ptr;
289 bool is_bitfield_ptr;
291 0, name, &bit_offset_ptr, &bitfield_bit_size_ptr, &is_bitfield_ptr);
293 m_pair_ptr =
nullptr;
298 m_pair_ptr =
nullptr;
320 CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier(
329 {
"payload", pair_type}});
330 std::optional<uint64_t> size = tree_node_type.
GetByteSize(
nullptr);
334 ProcessSP process_sp(target_sp->GetProcessSP());
336 process_sp->ReadMemory(addr, buffer_sp->GetBytes(),
337 buffer_sp->GetByteSize(),
error);
340 DataExtractor extractor(buffer_sp, process_sp->GetByteOrder(),
341 process_sp->GetAddressByteSize());
342 auto pair_sp = CreateValueObjectFromData(
343 "pair", extractor, valobj_sp->GetExecutionContextRef(),
346 m_pair_sp = pair_sp->GetChildAtIndex(4);
363 return m_pair_ptr->GetChildAtIndex(idx);
365 return m_pair_sp->GetChildAtIndex(idx);
378 if (name ==
"second")
406 m_iter_ptr =
nullptr;
412 TargetSP target_sp(valobj_sp->GetTargetSP());
424 SyntheticChildrenTraversal::None);
433 ->GetValueForExpressionPath(
".__i_.__node_",
nullptr,
nullptr,
434 exprPathOptions,
nullptr)
438 auto iter_child(valobj_sp->GetChildMemberWithName(
"__i_"));
440 m_iter_ptr =
nullptr;
445 .GetTypeTemplateArgument(0)
451 uint64_t bit_offset_ptr;
452 uint32_t bitfield_bit_size_ptr;
453 bool is_bitfield_ptr;
456 0, name, &bit_offset_ptr, &bitfield_bit_size_ptr, &is_bitfield_ptr);
458 m_iter_ptr =
nullptr;
463 m_iter_ptr =
nullptr;
485 CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier(
490 {
"__value_", pair_type}});
491 std::optional<uint64_t> size = tree_node_type.
GetByteSize(
nullptr);
495 ProcessSP process_sp(target_sp->GetProcessSP());
497 process_sp->ReadMemory(addr, buffer_sp->GetBytes(),
498 buffer_sp->GetByteSize(),
error);
501 DataExtractor extractor(buffer_sp, process_sp->GetByteOrder(),
502 process_sp->GetAddressByteSize());
503 auto pair_sp = CreateValueObjectFromData(
504 "pair", extractor, valobj_sp->GetExecutionContextRef(), tree_node_type);
506 m_pair_sp = pair_sp->GetChildAtIndex(2);
520 return m_pair_sp->GetChildAtIndex(idx);
533 if (name ==
"second")
571 return (m_cntrl ? 1 : 0);
585 return valobj_sp->GetChildMemberWithName(
"__ptr_");
588 if (
auto ptr_sp = valobj_sp->GetChildMemberWithName(
"__ptr_")) {
591 valobj_sp->GetCompilerType()
592 .GetTypeTemplateArgument(0).GetPointerType();
612 TargetSP target_sp(valobj_sp->GetTargetSP());
618 m_cntrl = cntrl_sp.get();
630 if (name ==
"__ptr_")
632 if (name ==
"$$dereference$$")
667 return m_deleter_sp ? 2 : 1;
678 return m_value_ptr_sp;
685 auto value_sp = m_value_ptr_sp->Dereference(status);
700 ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName(
"__ptr_"));
707 if (value_pointer_sp)
708 m_value_ptr_sp = value_pointer_sp->Clone(
ConstString(
"pointer"));
712 m_deleter_sp = deleter_sp->Clone(
ConstString(
"deleter"));
724 if (name ==
"pointer")
726 if (name ==
"deleter")
728 if (name ==
"$$dereference$$")
739 stream.
Printf(
"0x%016" PRIx64
" ", value);
742 nullptr,
nullptr, &valobj,
false,
false);
747enum class StringLayout { CSD, DSC };
753static std::optional<std::pair<uint64_t, ValueObjectSP>>
756 if (!valobj_r_sp || !valobj_r_sp->GetError().Success())
761 ValueObjectSP valobj_r_base_sp = valobj_r_sp->GetChildAtIndex(0);
762 if (!valobj_r_base_sp)
766 valobj_r_base_sp->GetChildMemberWithName(
"__value_");
774 StringLayout layout =
l->GetIndexOfChildWithName(
"__data_") == 0
778 bool short_mode =
false;
780 bool using_bitmasks =
true;
783 uint64_t size_mode_value = 0;
785 ValueObjectSP short_sp = valobj_rep_sp->GetChildMemberWithName(
"__s");
789 ValueObjectSP is_long = short_sp->GetChildMemberWithName(
"__is_long_");
790 ValueObjectSP size_sp = short_sp->GetChildMemberWithName(
"__size_");
795 using_bitmasks =
false;
796 short_mode = !is_long->GetValueAsUnsigned(0);
797 size = size_sp->GetValueAsUnsigned(0);
800 size_mode_value = size_sp->GetValueAsUnsigned(0);
801 uint8_t mode_mask = layout == StringLayout::DSC ? 0x80 : 1;
802 short_mode = (size_mode_value & mode_mask) == 0;
806 ValueObjectSP location_sp = short_sp->GetChildMemberWithName(
"__data_");
808 size = (layout == StringLayout::DSC) ? size_mode_value
809 : ((size_mode_value >> 1) % 256);
815 const std::optional<uint64_t> max_bytes =
816 location_sp->GetCompilerType().GetByteSize(
818 if (!max_bytes || size > *max_bytes || !location_sp)
821 return std::make_pair(size, location_sp);
828 if (!size_vo || !location_sp || !capacity_vo)
832 if (!using_bitmasks && layout == StringLayout::CSD)
837 return std::make_pair(size, location_sp);
852 if (summary_options.
GetCapping() == TypeSummaryCapping::eTypeSummaryCapped) {
853 const auto max_size = valobj.
GetTargetSP()->GetMaximumSizeOfStringSummary();
854 if (size > max_size) {
861 const size_t bytes_read = location_sp->GetPointeeData(extractor, 0, size);
862 if (bytes_read < size)
876 options.
SetData(std::move(extractor));
883 switch (*wchar_t_size) {
886 lldb_private::formatters::StringPrinter::StringElementType::UTF8>(
892 lldb_private::formatters::StringPrinter::StringElementType::UTF16>(
898 lldb_private::formatters::StringPrinter::StringElementType::UTF32>(
912 std::tie(size, location_sp) = *string_info;
914 return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options,
918template <StringPr
inter::StringElementType element_type>
935 if (summary_options.
GetCapping() == TypeSummaryCapping::eTypeSummaryCapped) {
936 const auto max_size = valobj.
GetTargetSP()->GetMaximumSizeOfStringSummary();
937 if (size > max_size) {
945 const size_t bytes_read = location_sp->GetPointeeData(extractor, 0, size);
946 if (bytes_read < size)
949 options.
SetData(std::move(extractor));
952 if (prefix_token.empty())
959 return StringPrinter::ReadBufferAndDumpToStream<element_type>(options);
962template <StringPr
inter::StringElementType element_type>
966 std::string prefix_token) {
972 std::tie(size, location_sp) = *string_info;
974 return LibcxxStringSummaryProvider<element_type>(
975 valobj, stream, summary_options, prefix_token, location_sp, size);
977template <StringPr
inter::StringElementType element_type>
980 std::string prefix_token) {
982 const bool success = LibcxxStringSummaryProvider<element_type>(
983 valobj, scratch_stream, summary_options, prefix_token);
985 stream << scratch_stream.
GetData();
987 stream <<
"Summary Unavailable";
994 return formatStringImpl<StringPrinter::StringElementType::ASCII>(
995 valobj, stream, summary_options,
"");
1001 return formatStringImpl<StringPrinter::StringElementType::UTF16>(
1002 valobj, stream, summary_options,
"u");
1008 return formatStringImpl<StringPrinter::StringElementType::UTF32>(
1009 valobj, stream, summary_options,
"U");
1012static std::tuple<bool, ValueObjectSP, size_t>
1018 if (!dataobj || !sizeobj)
1019 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
1021 if (!dataobj->GetError().Success() || !sizeobj->GetError().Success())
1022 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
1024 bool success{
false};
1025 uint64_t size = sizeobj->GetValueAsUnsigned(0, &success);
1027 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
1029 return std::make_tuple(
true,dataobj,size);
1032template <StringPr
inter::StringElementType element_type>
1035 std::string prefix_token) {
1043 stream <<
"Summary Unavailable";
1047 return LibcxxStringSummaryProvider<element_type>(
1048 valobj, stream, summary_options, prefix_token, dataobj, size);
1054 return formatStringViewImpl<StringPrinter::StringElementType::ASCII>(
1055 valobj, stream, summary_options,
"");
1061 return formatStringViewImpl<StringPrinter::StringElementType::UTF16>(
1062 valobj, stream, summary_options,
"u");
1068 return formatStringViewImpl<StringPrinter::StringElementType::UTF32>(
1069 valobj, stream, summary_options,
"U");
1082 stream <<
"Summary Unavailable";
1086 return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options,
1097 ptr_sp = ptr_sp->GetChildMemberWithName(
"__rep_");
1106 const std::time_t chrono_timestamp_min =
1108 const std::time_t chrono_timestamp_max =
1111 const std::time_t seconds = ptr_sp->GetValueAsSigned(0);
1112 if (seconds < chrono_timestamp_min || seconds > chrono_timestamp_max)
1113 stream.
Printf(
"timestamp=%" PRId64
" s",
static_cast<int64_t
>(seconds));
1115 std::array<char, 128> str;
1117 std::strftime(str.data(), str.size(), fmt, gmtime(&seconds));
1121 stream.
Printf(
"date/time=%s timestamp=%" PRId64
" s", str.data(),
1122 static_cast<int64_t
>(seconds));
1147 ptr_sp = ptr_sp->GetChildMemberWithName(
"__rep_");
1155 const int chrono_timestamp_min = -12'687'428;
1156 const int chrono_timestamp_max = 11'248'737;
1158 const int days = ptr_sp->GetValueAsSigned(0);
1159 if (days < chrono_timestamp_min || days > chrono_timestamp_max)
1160 stream.
Printf(
"timestamp=%d days", days);
1163 const std::time_t seconds = std::time_t(86400) * days;
1165 std::array<char, 128> str;
1167 std::strftime(str.data(), str.size(), fmt, gmtime(&seconds));
1171 stream.
Printf(
"date=%s timestamp=%d days", str.data(), days);
1193 static const std::array<std::string_view, 12> months = {
1194 "January",
"February",
"March",
"April",
"May",
"June",
1195 "July",
"August",
"September",
"October",
"November",
"December"};
1201 const unsigned month = ptr_sp->GetValueAsUnsigned(0);
1202 if (month >= 1 && month <= 12)
1203 stream <<
"month=" << months[month - 1];
1205 stream.
Printf(
"month=%u", month);
1214 static const std::array<std::string_view, 7> weekdays = {
1215 "Sunday",
"Monday",
"Tuesday",
"Wednesday",
1216 "Thursday",
"Friday",
"Saturday"};
1222 const unsigned weekday = ptr_sp->GetValueAsUnsigned(0);
1224 stream <<
"weekday=" << weekdays[weekday];
1226 stream.
Printf(
"weekday=%u", weekday);
1236 ptr_sp = ptr_sp->GetChildMemberWithName(
"__y_");
1239 int year = ptr_sp->GetValueAsSigned(0);
1244 ptr_sp = ptr_sp->GetChildMemberWithName(
"__m_");
1247 const unsigned month = ptr_sp->GetValueAsUnsigned(0);
1252 ptr_sp = ptr_sp->GetChildMemberWithName(
"__d_");
1255 const unsigned day = ptr_sp->GetValueAsUnsigned(0);
1262 stream.
Printf(
"%04d-%02u-%02u", year, month, day);
static llvm::raw_ostream & error(Stream &strm)
static bool LibcxxChronoTimepointDaysSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options, const char *fmt)
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)
static bool LibcxxChronoTimePointSecondsSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options, const char *fmt)
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.
virtual lldb::ValueObjectSP GetChildAtIndex(uint32_t idx, bool can_create=true)
virtual uint64_t GetValueAsUnsigned(uint64_t fail_value, bool *success=nullptr)
virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name, bool can_create=true)
lldb::TargetSP GetTargetSP() const
virtual lldb::ValueObjectSP GetNonSyntheticValue()
@ eValueObjectRepresentationStyleSummary
uint32_t GetNumChildrenIgnoringErrors(uint32_t max=UINT32_MAX)
Like GetNumChildren but returns 0 on error.
#define LLDB_INVALID_ADDRESS
#define LLDB_INVALID_OFFSET
A class that represents a running process on the host machine.
@ eBasicTypeUnsignedLongLong
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
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
uint32_t line
The source line number, or LLDB_INVALID_LINE_NUMBER if there is no line number information.
const FileSpec & GetFile() const
Helper to access the file.
GetValueForExpressionPathOptions & SetSyntheticChildrenTraversal(SyntheticChildrenTraversal traverse)
GetValueForExpressionPathOptions & DontCheckDotVsArrowSyntax()