43 if (scratch.consume_front(
"__") &&
44 std::isalnum(
static_cast<unsigned char>(scratch[0]))) {
45 scratch = scratch.drop_while(
46 [](
char c) {
return std::isalnum(
static_cast<unsigned char>(c)); });
47 if (scratch.consume_front(
"::")) {
55 llvm::StringRef type) {
58 if (name.consume_front(
"std::"))
60 return name.consume_front(type) && name.starts_with(
"<");
64 ValueObject &obj, llvm::ArrayRef<ConstString> alternative_names) {
80 value = first_child->GetChildMemberWithName(
"__value_");
95 value = second_child->GetChildMemberWithName(
"__value_");
105std::pair<lldb::ValueObjectSP, bool>
108 llvm::StringRef compressed_pair_name) {
109 auto is_old_compressed_pair = [](
ValueObject &pair_obj) ->
bool {
110 return isStdTemplate(pair_obj.GetTypeName(),
"__compressed_pair");
115 return {node_sp, is_old_compressed_pair(*node_sp)};
119 assert(!compressed_pair_name.empty());
125 return {
nullptr,
false};
128 if (!is_old_compressed_pair(*node_sp))
129 return {
nullptr,
false};
131 return {node_sp,
true};
145 if (process ==
nullptr)
163 " Lambda in File %s at Line %u",
169 " Function in File %s at Line %u",
174 stream.
Printf(
" Function = %s ",
188 ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName(
"__ptr_"));
189 ValueObjectSP ctrl_sp(valobj_sp->GetChildMemberWithName(
"__cntrl_"));
190 if (!ctrl_sp || !ptr_sp)
196 uint64_t ctrl_addr = ctrl_sp->GetValueAsUnsigned(0, &success);
198 if (!success || ctrl_addr == 0)
201 if (
auto count_sp = ctrl_sp->GetChildMemberWithName(
"__shared_owners_")) {
203 uint64_t count = count_sp->GetValueAsUnsigned(0, &success);
210 stream.
Printf(
" strong=%" PRIu64, count + 1);
213 if (
auto weak_count_sp =
214 ctrl_sp->GetChildMemberWithName(
"__shared_weak_owners_")) {
216 uint64_t count = weak_count_sp->GetValueAsUnsigned(0, &success);
222 stream.
Printf(
" weak=%" PRIu64, count);
234 auto [ptr_sp, is_compressed_pair] =
239 if (is_compressed_pair)
255 int64_t value = value_sp->GetValueAsSigned(0, &success);
271 stream <<
"equivalent";
277 stream <<
"unordered";
295 stream <<
"equivalent";
389 TargetSP target_sp(valobj_sp->GetTargetSP());
393 auto ptr_obj_sp = valobj_sp->GetChildMemberWithName(
"__ptr_");
410llvm::Expected<size_t>
413 if (name ==
"pointer")
416 if (name ==
"object" || name ==
"$$dereference$$")
419 return llvm::createStringError(
"Type has no child named '%s'",
486 auto [ptr_sp, is_compressed_pair] =
493 if (is_compressed_pair) {
505 valobj_sp->GetChildMemberWithName(
"__deleter_"))
506 if (deleter_sp->GetNumChildrenIgnoringErrors() > 0)
513llvm::Expected<size_t>
516 if (name ==
"pointer")
518 if (name ==
"deleter")
520 if (name ==
"obj" || name ==
"object" || name ==
"$$dereference$$")
522 return llvm::createStringError(
"Type has no child named '%s'",
528enum class StringLayout { CSD, DSC };
532 auto [valobj_r_sp, is_compressed_pair] =
537 if (is_compressed_pair)
546static std::optional<std::pair<uint64_t, ValueObjectSP>>
549 if (!valobj_rep_sp || !valobj_rep_sp->GetError().Success())
556 auto index_or_err =
l->GetIndexOfChildWithName(
"__data_");
563 StringLayout layout =
564 *index_or_err == 0 ? StringLayout::DSC : StringLayout::CSD;
566 bool short_mode =
false;
568 bool using_bitmasks =
true;
571 uint64_t size_mode_value = 0;
573 ValueObjectSP short_sp = valobj_rep_sp->GetChildMemberWithName(
"__s");
577 ValueObjectSP is_long = short_sp->GetChildMemberWithName(
"__is_long_");
578 ValueObjectSP size_sp = short_sp->GetChildMemberWithName(
"__size_");
583 using_bitmasks =
false;
584 short_mode = !is_long->GetValueAsUnsigned(0);
585 size = size_sp->GetValueAsUnsigned(0);
588 size_mode_value = size_sp->GetValueAsUnsigned(0);
589 uint8_t mode_mask = layout == StringLayout::DSC ? 0x80 : 1;
590 short_mode = (size_mode_value & mode_mask) == 0;
594 ValueObjectSP location_sp = short_sp->GetChildMemberWithName(
"__data_");
596 size = (layout == StringLayout::DSC) ? size_mode_value
597 : ((size_mode_value >> 1) % 256);
606 const std::optional<uint64_t> max_bytes =
607 llvm::expectedToOptional(location_sp->GetCompilerType().GetByteSize(
609 if (!max_bytes || size > *max_bytes)
612 return std::make_pair(size, location_sp);
619 if (!size_vo || !location_sp || !capacity_vo)
623 if (!using_bitmasks && layout == StringLayout::CSD)
628 return std::make_pair(size, location_sp);
639 std::tie(size, location_sp) = *string_info;
645 switch (*wchar_t_size) {
648 stream, summary_options, location_sp, size,
"L");
651 stream, summary_options, location_sp, size,
"L");
654 stream, summary_options, location_sp, size,
"L");
659template <StringPr
inter::StringElementType element_type>
663 std::string prefix_token) {
669 std::tie(size, location_sp) = *string_info;
672 stream, summary_options, location_sp, size, prefix_token);
674template <StringPr
inter::StringElementType element_type>
677 std::string prefix_token) {
680 valobj, scratch_stream, summary_options, prefix_token);
682 stream << scratch_stream.
GetData();
684 stream <<
"Summary Unavailable";
692 valobj, stream, summary_options,
"");
699 valobj, stream, summary_options,
"u");
706 valobj, stream, summary_options,
"U");
709static std::tuple<bool, ValueObjectSP, size_t>
715 if (!dataobj || !sizeobj)
716 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
718 if (!dataobj->GetError().Success() || !sizeobj->GetError().Success())
719 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
722 uint64_t size = sizeobj->GetValueAsUnsigned(0, &success);
724 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
726 return std::make_tuple(
true,dataobj,size);
729template <StringPr
inter::StringElementType element_type>
732 std::string prefix_token) {
740 stream <<
"Summary Unavailable";
745 dataobj, size, prefix_token);
752 valobj, stream, summary_options,
"");
759 valobj, stream, summary_options,
"u");
766 valobj, stream, summary_options,
"U");
779 stream <<
"Summary Unavailable";
787 switch (*wchar_t_size) {
790 stream, summary_options, dataobj, size,
"L");
793 stream, summary_options, dataobj, size,
"L");
796 stream, summary_options, dataobj, size,
"L");
808 ptr_sp = ptr_sp->GetChildMemberWithName(
"__rep_");
818 const std::time_t chrono_timestamp_min =
820 const std::time_t chrono_timestamp_max =
823 const std::time_t chrono_timestamp_min = -43'200;
824 const std::time_t chrono_timestamp_max =
828 const std::time_t seconds = ptr_sp->GetValueAsSigned(0);
829 if (seconds < chrono_timestamp_min || seconds > chrono_timestamp_max)
830 stream.
Printf(
"timestamp=%" PRId64
" s",
static_cast<int64_t
>(seconds));
832 std::array<char, 128> str;
834 std::strftime(str.data(), str.size(), fmt, gmtime(&seconds));
838 stream.
Printf(
"date/time=%s timestamp=%" PRId64
" s", str.data(),
839 static_cast<int64_t
>(seconds));
864 ptr_sp = ptr_sp->GetChildMemberWithName(
"__rep_");
873 const int chrono_timestamp_min = -12'687'428;
874 const int chrono_timestamp_max = 11'248'737;
876 const int chrono_timestamp_min = 0;
877 const int chrono_timestamp_max = 376'583;
880 const int days = ptr_sp->GetValueAsSigned(0);
881 if (days < chrono_timestamp_min || days > chrono_timestamp_max)
882 stream.
Printf(
"timestamp=%d days", days);
885 const std::time_t seconds = std::time_t(86400) * days;
887 std::array<char, 128> str;
889 std::strftime(str.data(), str.size(), fmt, gmtime(&seconds));
893 stream.
Printf(
"date=%s timestamp=%d days", str.data(), days);
915 static const std::array<std::string_view, 12> months = {
916 "January",
"February",
"March",
"April",
"May",
"June",
917 "July",
"August",
"September",
"October",
"November",
"December"};
923 const unsigned month = ptr_sp->GetValueAsUnsigned(0);
924 if (month >= 1 && month <= 12)
925 stream <<
"month=" << months[month - 1];
927 stream.
Printf(
"month=%u", month);
936 static const std::array<std::string_view, 7> weekdays = {
937 "Sunday",
"Monday",
"Tuesday",
"Wednesday",
938 "Thursday",
"Friday",
"Saturday"};
944 const unsigned weekday = ptr_sp->GetValueAsUnsigned(0);
946 stream <<
"weekday=" << weekdays[weekday];
948 stream.
Printf(
"weekday=%u", weekday);
958 ptr_sp = ptr_sp->GetChildMemberWithName(
"__y_");
961 int year = ptr_sp->GetValueAsSigned(0);
966 ptr_sp = ptr_sp->GetChildMemberWithName(
"__m_");
969 const unsigned month = ptr_sp->GetValueAsUnsigned(0);
974 ptr_sp = ptr_sp->GetChildMemberWithName(
"__d_");
977 const unsigned day = ptr_sp->GetValueAsUnsigned(0);
984 stream.
Printf(
"%04d-%02u-%02u", year, month, day);
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 std::optional< int64_t > LibcxxExtractOrderingValue(ValueObject &valobj)
static std::tuple< bool, ValueObjectSP, size_t > LibcxxExtractStringViewData(ValueObject &valobj)
static bool LibcxxChronoTimePointSecondsSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options, const char *fmt)
static bool LibcxxStringSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options, std::string prefix_token)
static void consumeInlineNamespace(llvm::StringRef &name)
#define LLDB_LOG_ERROR(log, error,...)
LibCppStdFunctionCallableInfo FindLibCppStdFunctionCallableInfo(lldb::ValueObjectSP &valobj_sp)
static CPPLanguageRuntime * Get(Process &process)
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
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.
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
SyntheticChildrenFrontEnd(ValueObject &backend)
virtual lldb::ValueObjectSP GetChildAtIndex(uint32_t idx, bool can_create=true)
virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name, bool can_create=true)
virtual lldb::ValueObjectSP GetNonSyntheticValue()
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.
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.
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
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.