31#include "llvm/Support/ErrorExtras.h"
42 if (scratch.consume_front(
"__") &&
43 std::isalnum(
static_cast<unsigned char>(scratch[0]))) {
44 scratch = scratch.drop_while(
45 [](
char c) {
return std::isalnum(
static_cast<unsigned char>(c)); });
46 if (scratch.consume_front(
"::")) {
54 llvm::StringRef type) {
57 if (name.consume_front(
"std::"))
59 return name.consume_front(type) && name.starts_with(
"<");
63 ValueObject &obj, llvm::ArrayRef<ConstString> alternative_names) {
79 value = first_child->GetChildMemberWithName(
"__value_");
94 value = second_child->GetChildMemberWithName(
"__value_");
104std::pair<lldb::ValueObjectSP, bool>
107 llvm::StringRef compressed_pair_name) {
108 auto is_old_compressed_pair = [](
ValueObject &pair_obj) ->
bool {
109 return isStdTemplate(pair_obj.GetTypeName(),
"__compressed_pair");
114 return {node_sp, is_old_compressed_pair(*node_sp)};
118 assert(!compressed_pair_name.empty());
124 return {
nullptr,
false};
127 if (!is_old_compressed_pair(*node_sp))
128 return {
nullptr,
false};
130 return {node_sp,
true};
144 if (process ==
nullptr)
162 " Lambda in File %s at Line %u",
168 " Function in File %s at Line %u",
173 stream.
Printf(
" Function = %s ",
187 ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName(
"__ptr_"));
188 ValueObjectSP ctrl_sp(valobj_sp->GetChildMemberWithName(
"__cntrl_"));
189 if (!ctrl_sp || !ptr_sp)
195 uint64_t ctrl_addr = ctrl_sp->GetValueAsUnsigned(0, &success);
197 if (!success || ctrl_addr == 0)
200 if (
auto count_sp = ctrl_sp->GetChildMemberWithName(
"__shared_owners_")) {
202 uint64_t count = count_sp->GetValueAsUnsigned(0, &success);
209 stream.
Printf(
" strong=%" PRIu64, count + 1);
212 if (
auto weak_count_sp =
213 ctrl_sp->GetChildMemberWithName(
"__shared_weak_owners_")) {
215 uint64_t count = weak_count_sp->GetValueAsUnsigned(0, &success);
221 stream.
Printf(
" weak=%" PRIu64, count);
233 auto [ptr_sp, is_compressed_pair] =
238 if (is_compressed_pair)
254 int64_t value = value_sp->GetValueAsSigned(0, &success);
270 stream <<
"equivalent";
276 stream <<
"unordered";
294 stream <<
"equivalent";
388 TargetSP target_sp(valobj_sp->GetTargetSP());
392 auto ptr_obj_sp = valobj_sp->GetChildMemberWithName(
"__ptr_");
400 m_ptr_obj = cast_ptr_sp->Clone(
"pointer").get();
409llvm::Expected<size_t>
412 if (name ==
"pointer")
415 if (name ==
"object" || name ==
"$$dereference$$")
418 return llvm::createStringErrorV(
"type has no child named '{0}'", name);
484 auto [ptr_sp, is_compressed_pair] =
491 if (is_compressed_pair) {
503 valobj_sp->GetChildMemberWithName(
"__deleter_"))
504 if (deleter_sp->GetNumChildrenIgnoringErrors() > 0)
511llvm::Expected<size_t>
514 if (name ==
"pointer")
516 if (name ==
"deleter")
518 if (name ==
"obj" || name ==
"object" || name ==
"$$dereference$$")
520 return llvm::createStringErrorV(
"type has no child named '{0}'", name);
525enum class StringLayout { CSD, DSC };
529 auto [valobj_r_sp, is_compressed_pair] =
534 if (is_compressed_pair)
543static std::optional<std::pair<uint64_t, ValueObjectSP>>
546 if (!valobj_rep_sp || !valobj_rep_sp->GetError().Success())
553 auto index_or_err =
l->GetIndexOfChildWithName(
"__data_");
560 StringLayout layout =
561 *index_or_err == 0 ? StringLayout::DSC : StringLayout::CSD;
563 bool short_mode =
false;
565 bool using_bitmasks =
true;
568 uint64_t size_mode_value = 0;
570 ValueObjectSP short_sp = valobj_rep_sp->GetChildMemberWithName(
"__s");
574 ValueObjectSP is_long = short_sp->GetChildMemberWithName(
"__is_long_");
575 ValueObjectSP size_sp = short_sp->GetChildMemberWithName(
"__size_");
580 using_bitmasks =
false;
581 short_mode = !is_long->GetValueAsUnsigned(0);
582 size = size_sp->GetValueAsUnsigned(0);
585 size_mode_value = size_sp->GetValueAsUnsigned(0);
586 uint8_t mode_mask = layout == StringLayout::DSC ? 0x80 : 1;
587 short_mode = (size_mode_value & mode_mask) == 0;
591 ValueObjectSP location_sp = short_sp->GetChildMemberWithName(
"__data_");
593 size = (layout == StringLayout::DSC) ? size_mode_value
594 : ((size_mode_value >> 1) % 256);
603 const std::optional<uint64_t> max_bytes =
604 llvm::expectedToOptional(location_sp->GetCompilerType().GetByteSize(
606 if (!max_bytes || size > *max_bytes)
609 return std::make_pair(size, location_sp);
616 if (!size_vo || !location_sp || !capacity_vo)
620 if (!using_bitmasks && layout == StringLayout::CSD)
625 return std::make_pair(size, location_sp);
636 std::tie(size, location_sp) = *string_info;
642 switch (*wchar_t_size) {
645 stream, summary_options, location_sp, size,
"L");
648 stream, summary_options, location_sp, size,
"L");
651 stream, summary_options, location_sp, size,
"L");
656template <StringPr
inter::StringElementType element_type>
660 std::string prefix_token) {
666 std::tie(size, location_sp) = *string_info;
669 stream, summary_options, location_sp, size, prefix_token);
671template <StringPr
inter::StringElementType element_type>
674 std::string prefix_token) {
677 valobj, scratch_stream, summary_options, prefix_token);
679 stream << scratch_stream.
GetData();
681 stream <<
"Summary Unavailable";
689 valobj, stream, summary_options,
"");
696 valobj, stream, summary_options,
"u");
703 valobj, stream, summary_options,
"U");
706static std::tuple<bool, ValueObjectSP, size_t>
712 if (!dataobj || !sizeobj)
713 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
715 if (!dataobj->GetError().Success() || !sizeobj->GetError().Success())
716 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
719 uint64_t size = sizeobj->GetValueAsUnsigned(0, &success);
721 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
723 return std::make_tuple(
true,dataobj,size);
726template <StringPr
inter::StringElementType element_type>
729 std::string prefix_token) {
737 stream <<
"Summary Unavailable";
742 dataobj, size, prefix_token);
749 valobj, stream, summary_options,
"");
756 valobj, stream, summary_options,
"u");
763 valobj, stream, summary_options,
"U");
776 stream <<
"Summary Unavailable";
784 switch (*wchar_t_size) {
787 stream, summary_options, dataobj, size,
"L");
790 stream, summary_options, dataobj, size,
"L");
793 stream, summary_options, dataobj, size,
"L");
805 ptr_sp = ptr_sp->GetChildMemberWithName(
"__rep_");
815 const std::time_t chrono_timestamp_min =
817 const std::time_t chrono_timestamp_max =
820 const std::time_t chrono_timestamp_min = -43'200;
821 const std::time_t chrono_timestamp_max =
825 const std::time_t seconds = ptr_sp->GetValueAsSigned(0);
826 if (seconds < chrono_timestamp_min || seconds > chrono_timestamp_max)
827 stream.
Printf(
"timestamp=%" PRId64
" s",
static_cast<int64_t
>(seconds));
829 std::array<char, 128> str;
831 std::strftime(str.data(), str.size(), fmt, gmtime(&seconds));
835 stream.
Printf(
"date/time=%s timestamp=%" PRId64
" s", str.data(),
836 static_cast<int64_t
>(seconds));
861 ptr_sp = ptr_sp->GetChildMemberWithName(
"__rep_");
870 const int chrono_timestamp_min = -12'687'428;
871 const int chrono_timestamp_max = 11'248'737;
873 const int chrono_timestamp_min = 0;
874 const int chrono_timestamp_max = 376'583;
877 const int days = ptr_sp->GetValueAsSigned(0);
878 if (days < chrono_timestamp_min || days > chrono_timestamp_max)
879 stream.
Printf(
"timestamp=%d days", days);
882 const std::time_t seconds = std::time_t(86400) * days;
884 std::array<char, 128> str;
886 std::strftime(str.data(), str.size(), fmt, gmtime(&seconds));
890 stream.
Printf(
"date=%s timestamp=%d days", str.data(), days);
912 static const std::array<std::string_view, 12> months = {
913 "January",
"February",
"March",
"April",
"May",
"June",
914 "July",
"August",
"September",
"October",
"November",
"December"};
920 const unsigned month = ptr_sp->GetValueAsUnsigned(0);
921 if (month >= 1 && month <= 12)
922 stream <<
"month=" << months[month - 1];
924 stream.
Printf(
"month=%u", month);
933 static const std::array<std::string_view, 7> weekdays = {
934 "Sunday",
"Monday",
"Tuesday",
"Wednesday",
935 "Thursday",
"Friday",
"Saturday"};
941 const unsigned weekday = ptr_sp->GetValueAsUnsigned(0);
943 stream <<
"weekday=" << weekdays[weekday];
945 stream.
Printf(
"weekday=%u", weekday);
955 ptr_sp = ptr_sp->GetChildMemberWithName(
"__y_");
958 int year = ptr_sp->GetValueAsSigned(0);
963 ptr_sp = ptr_sp->GetChildMemberWithName(
"__m_");
966 const unsigned month = ptr_sp->GetValueAsUnsigned(0);
971 ptr_sp = ptr_sp->GetChildMemberWithName(
"__d_");
974 const unsigned day = ptr_sp->GetValueAsUnsigned(0);
981 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.