32#include "llvm/Support/ErrorExtras.h"
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::createStringErrorV(
"type has no child named '{0}'", name);
485 auto [ptr_sp, is_compressed_pair] =
492 if (is_compressed_pair) {
504 valobj_sp->GetChildMemberWithName(
"__deleter_"))
505 if (deleter_sp->GetNumChildrenIgnoringErrors() > 0)
512llvm::Expected<size_t>
515 if (name ==
"pointer")
517 if (name ==
"deleter")
519 if (name ==
"obj" || name ==
"object" || name ==
"$$dereference$$")
521 return llvm::createStringErrorV(
"type has no child named '{0}'", name);
526enum class StringLayout { CSD, DSC };
530 auto [valobj_r_sp, is_compressed_pair] =
535 if (is_compressed_pair)
544static std::optional<std::pair<uint64_t, ValueObjectSP>>
547 if (!valobj_rep_sp || !valobj_rep_sp->GetError().Success())
554 auto index_or_err =
l->GetIndexOfChildWithName(
"__data_");
561 StringLayout layout =
562 *index_or_err == 0 ? StringLayout::DSC : StringLayout::CSD;
564 bool short_mode =
false;
566 bool using_bitmasks =
true;
569 uint64_t size_mode_value = 0;
571 ValueObjectSP short_sp = valobj_rep_sp->GetChildMemberWithName(
"__s");
575 ValueObjectSP is_long = short_sp->GetChildMemberWithName(
"__is_long_");
576 ValueObjectSP size_sp = short_sp->GetChildMemberWithName(
"__size_");
581 using_bitmasks =
false;
582 short_mode = !is_long->GetValueAsUnsigned(0);
583 size = size_sp->GetValueAsUnsigned(0);
586 size_mode_value = size_sp->GetValueAsUnsigned(0);
587 uint8_t mode_mask = layout == StringLayout::DSC ? 0x80 : 1;
588 short_mode = (size_mode_value & mode_mask) == 0;
592 ValueObjectSP location_sp = short_sp->GetChildMemberWithName(
"__data_");
594 size = (layout == StringLayout::DSC) ? size_mode_value
595 : ((size_mode_value >> 1) % 256);
604 const std::optional<uint64_t> max_bytes =
605 llvm::expectedToOptional(location_sp->GetCompilerType().GetByteSize(
607 if (!max_bytes || size > *max_bytes)
610 return std::make_pair(size, location_sp);
617 if (!size_vo || !location_sp || !capacity_vo)
621 if (!using_bitmasks && layout == StringLayout::CSD)
626 return std::make_pair(size, location_sp);
637 std::tie(size, location_sp) = *string_info;
643 switch (*wchar_t_size) {
646 stream, summary_options, location_sp, size,
"L");
649 stream, summary_options, location_sp, size,
"L");
652 stream, summary_options, location_sp, size,
"L");
657template <StringPr
inter::StringElementType element_type>
661 std::string prefix_token) {
667 std::tie(size, location_sp) = *string_info;
670 stream, summary_options, location_sp, size, prefix_token);
672template <StringPr
inter::StringElementType element_type>
675 std::string prefix_token) {
678 valobj, scratch_stream, summary_options, prefix_token);
680 stream << scratch_stream.
GetData();
682 stream <<
"Summary Unavailable";
690 valobj, stream, summary_options,
"");
697 valobj, stream, summary_options,
"u");
704 valobj, stream, summary_options,
"U");
707static std::tuple<bool, ValueObjectSP, size_t>
713 if (!dataobj || !sizeobj)
714 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
716 if (!dataobj->GetError().Success() || !sizeobj->GetError().Success())
717 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
720 uint64_t size = sizeobj->GetValueAsUnsigned(0, &success);
722 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
724 return std::make_tuple(
true,dataobj,size);
727template <StringPr
inter::StringElementType element_type>
730 std::string prefix_token) {
738 stream <<
"Summary Unavailable";
743 dataobj, size, prefix_token);
750 valobj, stream, summary_options,
"");
757 valobj, stream, summary_options,
"u");
764 valobj, stream, summary_options,
"U");
777 stream <<
"Summary Unavailable";
785 switch (*wchar_t_size) {
788 stream, summary_options, dataobj, size,
"L");
791 stream, summary_options, dataobj, size,
"L");
794 stream, summary_options, dataobj, size,
"L");
806 ptr_sp = ptr_sp->GetChildMemberWithName(
"__rep_");
816 const std::time_t chrono_timestamp_min =
818 const std::time_t chrono_timestamp_max =
821 const std::time_t chrono_timestamp_min = -43'200;
822 const std::time_t chrono_timestamp_max =
826 const std::time_t seconds = ptr_sp->GetValueAsSigned(0);
827 if (seconds < chrono_timestamp_min || seconds > chrono_timestamp_max)
828 stream.
Printf(
"timestamp=%" PRId64
" s",
static_cast<int64_t
>(seconds));
830 std::array<char, 128> str;
832 std::strftime(str.data(), str.size(), fmt, gmtime(&seconds));
836 stream.
Printf(
"date/time=%s timestamp=%" PRId64
" s", str.data(),
837 static_cast<int64_t
>(seconds));
862 ptr_sp = ptr_sp->GetChildMemberWithName(
"__rep_");
871 const int chrono_timestamp_min = -12'687'428;
872 const int chrono_timestamp_max = 11'248'737;
874 const int chrono_timestamp_min = 0;
875 const int chrono_timestamp_max = 376'583;
878 const int days = ptr_sp->GetValueAsSigned(0);
879 if (days < chrono_timestamp_min || days > chrono_timestamp_max)
880 stream.
Printf(
"timestamp=%d days", days);
883 const std::time_t seconds = std::time_t(86400) * days;
885 std::array<char, 128> str;
887 std::strftime(str.data(), str.size(), fmt, gmtime(&seconds));
891 stream.
Printf(
"date=%s timestamp=%d days", str.data(), days);
913 static const std::array<std::string_view, 12> months = {
914 "January",
"February",
"March",
"April",
"May",
"June",
915 "July",
"August",
"September",
"October",
"November",
"December"};
921 const unsigned month = ptr_sp->GetValueAsUnsigned(0);
922 if (month >= 1 && month <= 12)
923 stream <<
"month=" << months[month - 1];
925 stream.
Printf(
"month=%u", month);
934 static const std::array<std::string_view, 7> weekdays = {
935 "Sunday",
"Monday",
"Tuesday",
"Wednesday",
936 "Thursday",
"Friday",
"Saturday"};
942 const unsigned weekday = ptr_sp->GetValueAsUnsigned(0);
944 stream <<
"weekday=" << weekdays[weekday];
946 stream.
Printf(
"weekday=%u", weekday);
956 ptr_sp = ptr_sp->GetChildMemberWithName(
"__y_");
959 int year = ptr_sp->GetValueAsSigned(0);
964 ptr_sp = ptr_sp->GetChildMemberWithName(
"__m_");
967 const unsigned month = ptr_sp->GetValueAsUnsigned(0);
972 ptr_sp = ptr_sp->GetChildMemberWithName(
"__d_");
975 const unsigned day = ptr_sp->GetValueAsUnsigned(0);
982 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.
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.