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));
231 return (m_cntrl ? 1 : 0);
245 return valobj_sp->GetChildMemberWithName(
"__ptr_");
248 if (
auto ptr_sp = valobj_sp->GetChildMemberWithName(
"__ptr_")) {
251 valobj_sp->GetCompilerType()
252 .GetTypeTemplateArgument(0).GetPointerType();
272 TargetSP target_sp(valobj_sp->GetTargetSP());
278 m_cntrl = cntrl_sp.get();
290 if (name ==
"__ptr_")
292 if (name ==
"$$dereference$$")
327 return m_deleter_sp ? 2 : 1;
338 return m_value_ptr_sp;
345 auto value_sp = m_value_ptr_sp->Dereference(status);
360 ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName(
"__ptr_"));
367 if (value_pointer_sp)
368 m_value_ptr_sp = value_pointer_sp->Clone(
ConstString(
"pointer"));
372 m_deleter_sp = deleter_sp->Clone(
ConstString(
"deleter"));
384 if (name ==
"pointer")
386 if (name ==
"deleter")
388 if (name ==
"$$dereference$$")
399 stream.
Printf(
"0x%016" PRIx64
" ", value);
402 nullptr,
nullptr, &valobj,
false,
false);
407enum class StringLayout { CSD, DSC };
413static std::optional<std::pair<uint64_t, ValueObjectSP>>
416 if (!valobj_r_sp || !valobj_r_sp->GetError().Success())
421 ValueObjectSP valobj_r_base_sp = valobj_r_sp->GetChildAtIndex(0);
422 if (!valobj_r_base_sp)
426 valobj_r_base_sp->GetChildMemberWithName(
"__value_");
434 StringLayout layout =
l->GetIndexOfChildWithName(
"__data_") == 0
438 bool short_mode =
false;
440 bool using_bitmasks =
true;
443 uint64_t size_mode_value = 0;
445 ValueObjectSP short_sp = valobj_rep_sp->GetChildMemberWithName(
"__s");
449 ValueObjectSP is_long = short_sp->GetChildMemberWithName(
"__is_long_");
450 ValueObjectSP size_sp = short_sp->GetChildMemberWithName(
"__size_");
455 using_bitmasks =
false;
456 short_mode = !is_long->GetValueAsUnsigned(0);
457 size = size_sp->GetValueAsUnsigned(0);
460 size_mode_value = size_sp->GetValueAsUnsigned(0);
461 uint8_t mode_mask = layout == StringLayout::DSC ? 0x80 : 1;
462 short_mode = (size_mode_value & mode_mask) == 0;
466 ValueObjectSP location_sp = short_sp->GetChildMemberWithName(
"__data_");
468 size = (layout == StringLayout::DSC) ? size_mode_value
469 : ((size_mode_value >> 1) % 256);
478 const std::optional<uint64_t> max_bytes =
479 location_sp->GetCompilerType().GetByteSize(
481 if (!max_bytes || size > *max_bytes)
484 return std::make_pair(size, location_sp);
491 if (!size_vo || !location_sp || !capacity_vo)
495 if (!using_bitmasks && layout == StringLayout::CSD)
500 return std::make_pair(size, location_sp);
515 if (summary_options.
GetCapping() == TypeSummaryCapping::eTypeSummaryCapped) {
516 const auto max_size = valobj.
GetTargetSP()->GetMaximumSizeOfStringSummary();
517 if (size > max_size) {
524 const size_t bytes_read = location_sp->GetPointeeData(extractor, 0, size);
525 if (bytes_read < size)
539 options.
SetData(std::move(extractor));
546 switch (*wchar_t_size) {
549 lldb_private::formatters::StringPrinter::StringElementType::UTF8>(
555 lldb_private::formatters::StringPrinter::StringElementType::UTF16>(
561 lldb_private::formatters::StringPrinter::StringElementType::UTF32>(
575 std::tie(size, location_sp) = *string_info;
577 return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options,
581template <StringPr
inter::StringElementType element_type>
598 if (summary_options.
GetCapping() == TypeSummaryCapping::eTypeSummaryCapped) {
599 const auto max_size = valobj.
GetTargetSP()->GetMaximumSizeOfStringSummary();
600 if (size > max_size) {
608 const size_t bytes_read = location_sp->GetPointeeData(extractor, 0, size);
609 if (bytes_read < size)
612 options.
SetData(std::move(extractor));
615 if (prefix_token.empty())
622 return StringPrinter::ReadBufferAndDumpToStream<element_type>(options);
625template <StringPr
inter::StringElementType element_type>
629 std::string prefix_token) {
635 std::tie(size, location_sp) = *string_info;
637 return LibcxxStringSummaryProvider<element_type>(
638 valobj, stream, summary_options, prefix_token, location_sp, size);
640template <StringPr
inter::StringElementType element_type>
643 std::string prefix_token) {
645 const bool success = LibcxxStringSummaryProvider<element_type>(
646 valobj, scratch_stream, summary_options, prefix_token);
648 stream << scratch_stream.
GetData();
650 stream <<
"Summary Unavailable";
657 return formatStringImpl<StringPrinter::StringElementType::ASCII>(
658 valobj, stream, summary_options,
"");
664 return formatStringImpl<StringPrinter::StringElementType::UTF16>(
665 valobj, stream, summary_options,
"u");
671 return formatStringImpl<StringPrinter::StringElementType::UTF32>(
672 valobj, stream, summary_options,
"U");
675static std::tuple<bool, ValueObjectSP, size_t>
681 if (!dataobj || !sizeobj)
682 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
684 if (!dataobj->GetError().Success() || !sizeobj->GetError().Success())
685 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
688 uint64_t size = sizeobj->GetValueAsUnsigned(0, &success);
690 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
692 return std::make_tuple(
true,dataobj,size);
695template <StringPr
inter::StringElementType element_type>
698 std::string prefix_token) {
706 stream <<
"Summary Unavailable";
710 return LibcxxStringSummaryProvider<element_type>(
711 valobj, stream, summary_options, prefix_token, dataobj, size);
717 return formatStringViewImpl<StringPrinter::StringElementType::ASCII>(
718 valobj, stream, summary_options,
"");
724 return formatStringViewImpl<StringPrinter::StringElementType::UTF16>(
725 valobj, stream, summary_options,
"u");
731 return formatStringViewImpl<StringPrinter::StringElementType::UTF32>(
732 valobj, stream, summary_options,
"U");
745 stream <<
"Summary Unavailable";
749 return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options,
760 ptr_sp = ptr_sp->GetChildMemberWithName(
"__rep_");
770 const std::time_t chrono_timestamp_min =
772 const std::time_t chrono_timestamp_max =
775 const std::time_t chrono_timestamp_min = -43'200;
776 const std::time_t chrono_timestamp_max =
780 const std::time_t seconds = ptr_sp->GetValueAsSigned(0);
781 if (seconds < chrono_timestamp_min || seconds > chrono_timestamp_max)
782 stream.
Printf(
"timestamp=%" PRId64
" s",
static_cast<int64_t
>(seconds));
784 std::array<char, 128> str;
786 std::strftime(str.data(), str.size(), fmt, gmtime(&seconds));
790 stream.
Printf(
"date/time=%s timestamp=%" PRId64
" s", str.data(),
791 static_cast<int64_t
>(seconds));
816 ptr_sp = ptr_sp->GetChildMemberWithName(
"__rep_");
825 const int chrono_timestamp_min = -12'687'428;
826 const int chrono_timestamp_max = 11'248'737;
828 const int chrono_timestamp_min = 0;
829 const int chrono_timestamp_max = 376'583;
832 const int days = ptr_sp->GetValueAsSigned(0);
833 if (days < chrono_timestamp_min || days > chrono_timestamp_max)
834 stream.
Printf(
"timestamp=%d days", days);
837 const std::time_t seconds = std::time_t(86400) * days;
839 std::array<char, 128> str;
841 std::strftime(str.data(), str.size(), fmt, gmtime(&seconds));
845 stream.
Printf(
"date=%s timestamp=%d days", str.data(), days);
867 static const std::array<std::string_view, 12> months = {
868 "January",
"February",
"March",
"April",
"May",
"June",
869 "July",
"August",
"September",
"October",
"November",
"December"};
875 const unsigned month = ptr_sp->GetValueAsUnsigned(0);
876 if (month >= 1 && month <= 12)
877 stream <<
"month=" << months[month - 1];
879 stream.
Printf(
"month=%u", month);
888 static const std::array<std::string_view, 7> weekdays = {
889 "Sunday",
"Monday",
"Tuesday",
"Wednesday",
890 "Thursday",
"Friday",
"Saturday"};
896 const unsigned weekday = ptr_sp->GetValueAsUnsigned(0);
898 stream <<
"weekday=" << weekdays[weekday];
900 stream.
Printf(
"weekday=%u", weekday);
910 ptr_sp = ptr_sp->GetChildMemberWithName(
"__y_");
913 int year = ptr_sp->GetValueAsSigned(0);
918 ptr_sp = ptr_sp->GetChildMemberWithName(
"__m_");
921 const unsigned month = ptr_sp->GetValueAsUnsigned(0);
926 ptr_sp = ptr_sp->GetChildMemberWithName(
"__d_");
929 const unsigned day = ptr_sp->GetValueAsUnsigned(0);
936 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)
A uniqued constant string class.
const char * GetCString() const
Get the string value as a C string.
"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
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_OFFSET
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.
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP
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.