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>
107 ValueObject &obj,
size_t anon_struct_idx, llvm::StringRef child_name,
108 llvm::StringRef compressed_pair_name) {
109 auto is_old_compressed_pair = [](
ValueObject &pair_obj) ->
bool {
110 return isStdTemplate(pair_obj.GetTypeName(),
"__compressed_pair");
117 return {node_sp, is_old_compressed_pair(*node_sp)};
124 return {node_sp, is_old_compressed_pair(*node_sp)};
128 assert(!compressed_pair_name.empty());
134 return {
nullptr,
false};
137 if (!is_old_compressed_pair(*node_sp))
138 return {
nullptr,
false};
140 return {node_sp,
true};
154 if (process ==
nullptr)
172 " Lambda in File %s at Line %u",
178 " Function in File %s at Line %u",
183 stream.
Printf(
" Function = %s ",
197 ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName(
"__ptr_"));
198 ValueObjectSP ctrl_sp(valobj_sp->GetChildMemberWithName(
"__cntrl_"));
199 if (!ctrl_sp || !ptr_sp)
205 uint64_t ctrl_addr = ctrl_sp->GetValueAsUnsigned(0, &success);
207 if (!success || ctrl_addr == 0)
210 if (
auto count_sp = ctrl_sp->GetChildMemberWithName(
"__shared_owners_")) {
212 uint64_t count = count_sp->GetValueAsUnsigned(0, &success);
219 stream.
Printf(
" strong=%" PRIu64, count + 1);
222 if (
auto weak_count_sp =
223 ctrl_sp->GetChildMemberWithName(
"__shared_weak_owners_")) {
225 uint64_t count = weak_count_sp->GetValueAsUnsigned(0, &success);
231 stream.
Printf(
" weak=%" PRIu64, count);
244 *valobj_sp, 0,
"__ptr_",
"__ptr_");
248 if (is_compressed_pair)
321 TargetSP target_sp(valobj_sp->GetTargetSP());
325 auto ptr_obj_sp = valobj_sp->GetChildMemberWithName(
"__ptr_");
342llvm::Expected<size_t>
345 if (name ==
"pointer")
348 if (name ==
"object" || name ==
"$$dereference$$")
351 return llvm::createStringError(
"Type has no child named '%s'",
419 *valobj_sp, 0,
"__ptr_",
"__ptr_");
425 if (is_compressed_pair) {
437 valobj_sp->GetChildMemberWithName(
"__deleter_"))
438 if (deleter_sp->GetNumChildrenIgnoringErrors() > 0)
445llvm::Expected<size_t>
448 if (name ==
"pointer")
450 if (name ==
"deleter")
452 if (name ==
"obj" || name ==
"object" || name ==
"$$dereference$$")
454 return llvm::createStringError(
"Type has no child named '%s'",
460enum class StringLayout { CSD, DSC };
465 valobj, 0,
"__rep_",
"__r_");
469 if (is_compressed_pair)
478static std::optional<std::pair<uint64_t, ValueObjectSP>>
481 if (!valobj_rep_sp || !valobj_rep_sp->GetError().Success())
488 auto index_or_err =
l->GetIndexOfChildWithName(
"__data_");
495 StringLayout layout =
496 *index_or_err == 0 ? StringLayout::DSC : StringLayout::CSD;
498 bool short_mode =
false;
500 bool using_bitmasks =
true;
503 uint64_t size_mode_value = 0;
505 ValueObjectSP short_sp = valobj_rep_sp->GetChildMemberWithName(
"__s");
509 ValueObjectSP is_long = short_sp->GetChildMemberWithName(
"__is_long_");
510 ValueObjectSP size_sp = short_sp->GetChildMemberWithName(
"__size_");
515 using_bitmasks =
false;
516 short_mode = !is_long->GetValueAsUnsigned(0);
517 size = size_sp->GetValueAsUnsigned(0);
520 size_mode_value = size_sp->GetValueAsUnsigned(0);
521 uint8_t mode_mask = layout == StringLayout::DSC ? 0x80 : 1;
522 short_mode = (size_mode_value & mode_mask) == 0;
526 ValueObjectSP location_sp = short_sp->GetChildMemberWithName(
"__data_");
528 size = (layout == StringLayout::DSC) ? size_mode_value
529 : ((size_mode_value >> 1) % 256);
538 const std::optional<uint64_t> max_bytes =
539 llvm::expectedToOptional(location_sp->GetCompilerType().GetByteSize(
541 if (!max_bytes || size > *max_bytes)
544 return std::make_pair(size, location_sp);
551 if (!size_vo || !location_sp || !capacity_vo)
555 if (!using_bitmasks && layout == StringLayout::CSD)
560 return std::make_pair(size, location_sp);
571 std::tie(size, location_sp) = *string_info;
577 switch (*wchar_t_size) {
580 stream, summary_options, location_sp, size,
"L");
583 stream, summary_options, location_sp, size,
"L");
586 stream, summary_options, location_sp, size,
"L");
591template <StringPr
inter::StringElementType element_type>
595 std::string prefix_token) {
601 std::tie(size, location_sp) = *string_info;
604 stream, summary_options, location_sp, size, prefix_token);
606template <StringPr
inter::StringElementType element_type>
609 std::string prefix_token) {
612 valobj, scratch_stream, summary_options, prefix_token);
614 stream << scratch_stream.
GetData();
616 stream <<
"Summary Unavailable";
624 valobj, stream, summary_options,
"");
631 valobj, stream, summary_options,
"u");
638 valobj, stream, summary_options,
"U");
641static std::tuple<bool, ValueObjectSP, size_t>
647 if (!dataobj || !sizeobj)
648 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
650 if (!dataobj->GetError().Success() || !sizeobj->GetError().Success())
651 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
654 uint64_t size = sizeobj->GetValueAsUnsigned(0, &success);
656 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
658 return std::make_tuple(
true,dataobj,size);
661template <StringPr
inter::StringElementType element_type>
664 std::string prefix_token) {
672 stream <<
"Summary Unavailable";
677 dataobj, size, prefix_token);
684 valobj, stream, summary_options,
"");
691 valobj, stream, summary_options,
"u");
698 valobj, stream, summary_options,
"U");
711 stream <<
"Summary Unavailable";
719 switch (*wchar_t_size) {
722 stream, summary_options, dataobj, size,
"L");
725 stream, summary_options, dataobj, size,
"L");
728 stream, summary_options, dataobj, size,
"L");
740 ptr_sp = ptr_sp->GetChildMemberWithName(
"__rep_");
750 const std::time_t chrono_timestamp_min =
752 const std::time_t chrono_timestamp_max =
755 const std::time_t chrono_timestamp_min = -43'200;
756 const std::time_t chrono_timestamp_max =
760 const std::time_t seconds = ptr_sp->GetValueAsSigned(0);
761 if (seconds < chrono_timestamp_min || seconds > chrono_timestamp_max)
762 stream.
Printf(
"timestamp=%" PRId64
" s",
static_cast<int64_t
>(seconds));
764 std::array<char, 128> str;
766 std::strftime(str.data(), str.size(), fmt, gmtime(&seconds));
770 stream.
Printf(
"date/time=%s timestamp=%" PRId64
" s", str.data(),
771 static_cast<int64_t
>(seconds));
796 ptr_sp = ptr_sp->GetChildMemberWithName(
"__rep_");
805 const int chrono_timestamp_min = -12'687'428;
806 const int chrono_timestamp_max = 11'248'737;
808 const int chrono_timestamp_min = 0;
809 const int chrono_timestamp_max = 376'583;
812 const int days = ptr_sp->GetValueAsSigned(0);
813 if (days < chrono_timestamp_min || days > chrono_timestamp_max)
814 stream.
Printf(
"timestamp=%d days", days);
817 const std::time_t seconds = std::time_t(86400) * days;
819 std::array<char, 128> str;
821 std::strftime(str.data(), str.size(), fmt, gmtime(&seconds));
825 stream.
Printf(
"date=%s timestamp=%d days", str.data(), days);
847 static const std::array<std::string_view, 12> months = {
848 "January",
"February",
"March",
"April",
"May",
"June",
849 "July",
"August",
"September",
"October",
"November",
"December"};
855 const unsigned month = ptr_sp->GetValueAsUnsigned(0);
856 if (month >= 1 && month <= 12)
857 stream <<
"month=" << months[month - 1];
859 stream.
Printf(
"month=%u", month);
868 static const std::array<std::string_view, 7> weekdays = {
869 "Sunday",
"Monday",
"Tuesday",
"Wednesday",
870 "Thursday",
"Friday",
"Saturday"};
876 const unsigned weekday = ptr_sp->GetValueAsUnsigned(0);
878 stream <<
"weekday=" << weekdays[weekday];
880 stream.
Printf(
"weekday=%u", weekday);
890 ptr_sp = ptr_sp->GetChildMemberWithName(
"__y_");
893 int year = ptr_sp->GetValueAsSigned(0);
898 ptr_sp = ptr_sp->GetChildMemberWithName(
"__m_");
901 const unsigned month = ptr_sp->GetValueAsUnsigned(0);
906 ptr_sp = ptr_sp->GetChildMemberWithName(
"__d_");
909 const unsigned day = ptr_sp->GetValueAsUnsigned(0);
916 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::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.