41 if (scratch.consume_front(
"__") && std::isalnum(scratch[0])) {
42 scratch = scratch.drop_while([](
char c) {
return std::isalnum(c); });
43 if (scratch.consume_front(
"::")) {
56 llvm::StringRef type) {
59 if (name.consume_front(
"std::"))
61 return name.consume_front(type) && name.starts_with(
"<");
65 ValueObject &obj, llvm::ArrayRef<ConstString> alternative_names) {
81 value = first_child->GetChildMemberWithName(
"__value_");
96 value = second_child->GetChildMemberWithName(
"__value_");
117 if (process ==
nullptr)
129 case CPPLanguageRuntime::LibCppStdFunctionCallableCase::Invalid:
133 case CPPLanguageRuntime::LibCppStdFunctionCallableCase::Lambda:
135 " Lambda in File %s at Line %u",
139 case CPPLanguageRuntime::LibCppStdFunctionCallableCase::CallableObject:
141 " Function in File %s at Line %u",
145 case CPPLanguageRuntime::LibCppStdFunctionCallableCase::FreeOrMemberFunction:
146 stream.
Printf(
" Function = %s ",
159 ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName(
"__ptr_"));
161 valobj_sp->GetChildAtNamePath({
"__cntrl_",
"__shared_owners_"}));
163 valobj_sp->GetChildAtNamePath({
"__cntrl_",
"__shared_weak_owners_"}));
168 if (ptr_sp->GetValueAsUnsigned(0) == 0) {
172 bool print_pointee =
false;
175 if (pointee_sp &&
error.Success()) {
176 if (pointee_sp->DumpPrintableRepresentation(
179 ValueObject::PrintableRepresentationSpecialCases::eDisable,
181 print_pointee =
true;
184 stream.
Printf(
"ptr = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0));
188 stream.
Printf(
" strong=%" PRIu64, 1 + count_sp->GetValueAsUnsigned(0));
191 stream.
Printf(
" weak=%" PRIu64, 1 + weakcount_sp->GetValueAsUnsigned(0));
202 ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName(
"__ptr_"));
212 if (ptr_sp->GetValueAsUnsigned(0) == 0) {
216 bool print_pointee =
false;
219 if (pointee_sp &&
error.Success()) {
220 if (pointee_sp->DumpPrintableRepresentation(
223 ValueObject::PrintableRepresentationSpecialCases::eDisable,
225 print_pointee =
true;
228 stream.
Printf(
"ptr = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0));
260 return (m_cntrl ? 1 : 0);
274 return valobj_sp->GetChildMemberWithName(
"__ptr_");
277 if (
auto ptr_sp = valobj_sp->GetChildMemberWithName(
"__ptr_")) {
280 valobj_sp->GetCompilerType()
281 .GetTypeTemplateArgument(0).GetPointerType();
301 TargetSP target_sp(valobj_sp->GetTargetSP());
307 m_cntrl = cntrl_sp.get();
319 if (name ==
"__ptr_")
321 if (name ==
"$$dereference$$")
356 return m_deleter_sp ? 2 : 1;
367 return m_value_ptr_sp;
374 auto value_sp = m_value_ptr_sp->Dereference(status);
389 ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName(
"__ptr_"));
398 m_value_ptr_sp = value_pointer_sp->Clone(
ConstString(
"pointer"));
402 m_deleter_sp = deleter_sp->Clone(
ConstString(
"deleter"));
404 m_value_ptr_sp = ptr_sp->Clone(
ConstString(
"pointer"));
407 valobj_sp->GetChildMemberWithName(
"__deleter_"))
408 if (deleter_sp->GetNumChildrenIgnoringErrors() > 0)
409 m_deleter_sp = deleter_sp->Clone(
ConstString(
"deleter"));
422 if (name ==
"pointer")
424 if (name ==
"deleter")
426 if (name ==
"$$dereference$$")
437 stream.
Printf(
"0x%016" PRIx64
" ", value);
440 nullptr,
nullptr, &valobj,
false,
false);
445enum class StringLayout { CSD, DSC };
453 if (!valobj_r_sp || !valobj_r_sp->GetError().Success())
465static std::optional<std::pair<uint64_t, ValueObjectSP>>
468 if (!valobj_rep_sp || !valobj_rep_sp->GetError().Success())
475 StringLayout layout =
l->GetIndexOfChildWithName(
"__data_") == 0
479 bool short_mode =
false;
481 bool using_bitmasks =
true;
484 uint64_t size_mode_value = 0;
486 ValueObjectSP short_sp = valobj_rep_sp->GetChildMemberWithName(
"__s");
490 ValueObjectSP is_long = short_sp->GetChildMemberWithName(
"__is_long_");
491 ValueObjectSP size_sp = short_sp->GetChildMemberWithName(
"__size_");
496 using_bitmasks =
false;
497 short_mode = !is_long->GetValueAsUnsigned(0);
498 size = size_sp->GetValueAsUnsigned(0);
501 size_mode_value = size_sp->GetValueAsUnsigned(0);
502 uint8_t mode_mask = layout == StringLayout::DSC ? 0x80 : 1;
503 short_mode = (size_mode_value & mode_mask) == 0;
507 ValueObjectSP location_sp = short_sp->GetChildMemberWithName(
"__data_");
509 size = (layout == StringLayout::DSC) ? size_mode_value
510 : ((size_mode_value >> 1) % 256);
519 const std::optional<uint64_t> max_bytes =
520 location_sp->GetCompilerType().GetByteSize(
522 if (!max_bytes || size > *max_bytes)
525 return std::make_pair(size, location_sp);
532 if (!size_vo || !location_sp || !capacity_vo)
536 if (!using_bitmasks && layout == StringLayout::CSD)
541 return std::make_pair(size, location_sp);
556 if (summary_options.
GetCapping() == TypeSummaryCapping::eTypeSummaryCapped) {
557 const auto max_size = valobj.
GetTargetSP()->GetMaximumSizeOfStringSummary();
558 if (size > max_size) {
565 const size_t bytes_read = location_sp->GetPointeeData(extractor, 0, size);
566 if (bytes_read < size)
580 options.
SetData(std::move(extractor));
587 switch (*wchar_t_size) {
590 lldb_private::formatters::StringPrinter::StringElementType::UTF8>(
596 lldb_private::formatters::StringPrinter::StringElementType::UTF16>(
602 lldb_private::formatters::StringPrinter::StringElementType::UTF32>(
616 std::tie(size, location_sp) = *string_info;
618 return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options,
622template <StringPr
inter::StringElementType element_type>
639 if (summary_options.
GetCapping() == TypeSummaryCapping::eTypeSummaryCapped) {
640 const auto max_size = valobj.
GetTargetSP()->GetMaximumSizeOfStringSummary();
641 if (size > max_size) {
649 const size_t bytes_read = location_sp->GetPointeeData(extractor, 0, size);
650 if (bytes_read < size)
653 options.
SetData(std::move(extractor));
656 if (prefix_token.empty())
663 return StringPrinter::ReadBufferAndDumpToStream<element_type>(options);
666template <StringPr
inter::StringElementType element_type>
670 std::string prefix_token) {
676 std::tie(size, location_sp) = *string_info;
678 return LibcxxStringSummaryProvider<element_type>(
679 valobj, stream, summary_options, prefix_token, location_sp, size);
681template <StringPr
inter::StringElementType element_type>
684 std::string prefix_token) {
686 const bool success = LibcxxStringSummaryProvider<element_type>(
687 valobj, scratch_stream, summary_options, prefix_token);
689 stream << scratch_stream.
GetData();
691 stream <<
"Summary Unavailable";
698 return formatStringImpl<StringPrinter::StringElementType::ASCII>(
699 valobj, stream, summary_options,
"");
705 return formatStringImpl<StringPrinter::StringElementType::UTF16>(
706 valobj, stream, summary_options,
"u");
712 return formatStringImpl<StringPrinter::StringElementType::UTF32>(
713 valobj, stream, summary_options,
"U");
716static std::tuple<bool, ValueObjectSP, size_t>
722 if (!dataobj || !sizeobj)
723 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
725 if (!dataobj->GetError().Success() || !sizeobj->GetError().Success())
726 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
729 uint64_t size = sizeobj->GetValueAsUnsigned(0, &success);
731 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
733 return std::make_tuple(
true,dataobj,size);
736template <StringPr
inter::StringElementType element_type>
739 std::string prefix_token) {
747 stream <<
"Summary Unavailable";
751 return LibcxxStringSummaryProvider<element_type>(
752 valobj, stream, summary_options, prefix_token, dataobj, size);
758 return formatStringViewImpl<StringPrinter::StringElementType::ASCII>(
759 valobj, stream, summary_options,
"");
765 return formatStringViewImpl<StringPrinter::StringElementType::UTF16>(
766 valobj, stream, summary_options,
"u");
772 return formatStringViewImpl<StringPrinter::StringElementType::UTF32>(
773 valobj, stream, summary_options,
"U");
786 stream <<
"Summary Unavailable";
790 return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options,
801 ptr_sp = ptr_sp->GetChildMemberWithName(
"__rep_");
811 const std::time_t chrono_timestamp_min =
813 const std::time_t chrono_timestamp_max =
816 const std::time_t chrono_timestamp_min = -43'200;
817 const std::time_t chrono_timestamp_max =
821 const std::time_t seconds = ptr_sp->GetValueAsSigned(0);
822 if (seconds < chrono_timestamp_min || seconds > chrono_timestamp_max)
823 stream.
Printf(
"timestamp=%" PRId64
" s",
static_cast<int64_t
>(seconds));
825 std::array<char, 128> str;
827 std::strftime(str.data(), str.size(), fmt, gmtime(&seconds));
831 stream.
Printf(
"date/time=%s timestamp=%" PRId64
" s", str.data(),
832 static_cast<int64_t
>(seconds));
857 ptr_sp = ptr_sp->GetChildMemberWithName(
"__rep_");
866 const int chrono_timestamp_min = -12'687'428;
867 const int chrono_timestamp_max = 11'248'737;
869 const int chrono_timestamp_min = 0;
870 const int chrono_timestamp_max = 376'583;
873 const int days = ptr_sp->GetValueAsSigned(0);
874 if (days < chrono_timestamp_min || days > chrono_timestamp_max)
875 stream.
Printf(
"timestamp=%d days", days);
878 const std::time_t seconds = std::time_t(86400) * days;
880 std::array<char, 128> str;
882 std::strftime(str.data(), str.size(), fmt, gmtime(&seconds));
886 stream.
Printf(
"date=%s timestamp=%d days", str.data(), days);
908 static const std::array<std::string_view, 12> months = {
909 "January",
"February",
"March",
"April",
"May",
"June",
910 "July",
"August",
"September",
"October",
"November",
"December"};
916 const unsigned month = ptr_sp->GetValueAsUnsigned(0);
917 if (month >= 1 && month <= 12)
918 stream <<
"month=" << months[month - 1];
920 stream.
Printf(
"month=%u", month);
929 static const std::array<std::string_view, 7> weekdays = {
930 "Sunday",
"Monday",
"Tuesday",
"Wednesday",
931 "Thursday",
"Friday",
"Saturday"};
937 const unsigned weekday = ptr_sp->GetValueAsUnsigned(0);
939 stream <<
"weekday=" << weekdays[weekday];
941 stream.
Printf(
"weekday=%u", weekday);
951 ptr_sp = ptr_sp->GetChildMemberWithName(
"__y_");
954 int year = ptr_sp->GetValueAsSigned(0);
959 ptr_sp = ptr_sp->GetChildMemberWithName(
"__m_");
962 const unsigned month = ptr_sp->GetValueAsUnsigned(0);
967 ptr_sp = ptr_sp->GetChildMemberWithName(
"__d_");
970 const unsigned day = ptr_sp->GetValueAsUnsigned(0);
977 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 ValueObjectSP ExtractLibCxxStringData(ValueObject &valobj)
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)
static void consumeInlineNamespace(llvm::StringRef &name)
LibCppStdFunctionCallableInfo FindLibCppStdFunctionCallableInfo(lldb::ValueObjectSP &valobj_sp)
static CPPLanguageRuntime * Get(Process &process)
A uniqued constant string class.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
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)
virtual ConstString GetTypeName()
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.