39 ValueObject &obj, llvm::ArrayRef<ConstString> alternative_names) {
57 ValueObjectSP engaged_sp(
58 valobj_sp->GetChildMemberWithName(
ConstString(
"__engaged_"),
true));
63 llvm::StringRef engaged_as_cstring(
64 engaged_sp->GetValueAsUnsigned(0) == 1 ?
"true" :
"false");
66 stream.
Printf(
" Has Value=%s ", engaged_as_cstring.data());
82 if (process ==
nullptr)
94 case CPPLanguageRuntime::LibCppStdFunctionCallableCase::Invalid:
98 case CPPLanguageRuntime::LibCppStdFunctionCallableCase::Lambda:
100 " Lambda in File %s at Line %u",
104 case CPPLanguageRuntime::LibCppStdFunctionCallableCase::CallableObject:
106 " Function in File %s at Line %u",
110 case CPPLanguageRuntime::LibCppStdFunctionCallableCase::FreeOrMemberFunction:
111 stream.
Printf(
" Function = %s ",
124 ValueObjectSP ptr_sp(
125 valobj_sp->GetChildMemberWithName(
ConstString(
"__ptr_"),
true));
126 ValueObjectSP count_sp(valobj_sp->GetChildAtNamePath(
127 {ConstString(
"__cntrl_"), ConstString(
"__shared_owners_")}));
128 ValueObjectSP weakcount_sp(valobj_sp->GetChildAtNamePath(
129 {ConstString(
"__cntrl_"), ConstString(
"__shared_weak_owners_")}));
134 if (ptr_sp->GetValueAsUnsigned(0) == 0) {
138 bool print_pointee =
false;
140 ValueObjectSP pointee_sp = ptr_sp->Dereference(
error);
141 if (pointee_sp &&
error.Success()) {
142 if (pointee_sp->DumpPrintableRepresentation(
145 ValueObject::PrintableRepresentationSpecialCases::eDisable,
147 print_pointee =
true;
150 stream.
Printf(
"ptr = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0));
154 stream.
Printf(
" strong=%" PRIu64, 1 + count_sp->GetValueAsUnsigned(0));
157 stream.
Printf(
" weak=%" PRIu64, 1 + weakcount_sp->GetValueAsUnsigned(0));
168 ValueObjectSP ptr_sp(
169 valobj_sp->GetChildMemberWithName(
ConstString(
"__ptr_"),
true));
177 if (ptr_sp->GetValueAsUnsigned(0) == 0) {
181 bool print_pointee =
false;
183 ValueObjectSP pointee_sp = ptr_sp->Dereference(
error);
184 if (pointee_sp &&
error.Success()) {
185 if (pointee_sp->DumpPrintableRepresentation(
188 ValueObject::PrintableRepresentationSpecialCases::eDisable,
190 print_pointee =
true;
193 stream.
Printf(
"ptr = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0));
230 m_pair_ptr =
nullptr;
232 ValueObjectSP valobj_sp = m_backend.GetSP();
236 TargetSP target_sp(valobj_sp->GetTargetSP());
251 m_pair_ptr = valobj_sp
252 ->GetValueForExpressionPath(
253 ".__i_.__ptr_->__value_",
nullptr,
nullptr,
255 .DontCheckDotVsArrowSyntax()
256 .SetSyntheticChildrenTraversal(
258 SyntheticChildrenTraversal::None),
263 m_pair_ptr = valobj_sp
264 ->GetValueForExpressionPath(
265 ".__i_.__ptr_",
nullptr,
nullptr,
267 .DontCheckDotVsArrowSyntax()
268 .SetSyntheticChildrenTraversal(
270 SyntheticChildrenTraversal::None),
274 auto __i_(valobj_sp->GetChildMemberWithName(g_i_,
true));
276 m_pair_ptr =
nullptr;
280 __i_->GetCompilerType().GetTypeTemplateArgument(0));
282 uint64_t bit_offset_ptr;
284 bool is_bitfield_ptr;
286 0, name, &bit_offset_ptr, &bitfield_bit_size_ptr, &is_bitfield_ptr);
288 m_pair_ptr =
nullptr;
293 m_pair_ptr =
nullptr;
315 CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier(
324 {
"payload", pair_type}});
325 std::optional<uint64_t> size = tree_node_type.
GetByteSize(
nullptr);
329 ProcessSP process_sp(target_sp->GetProcessSP());
331 process_sp->ReadMemory(addr, buffer_sp->GetBytes(),
332 buffer_sp->GetByteSize(),
error);
335 DataExtractor extractor(buffer_sp, process_sp->GetByteOrder(),
336 process_sp->GetAddressByteSize());
337 auto pair_sp = CreateValueObjectFromData(
338 "pair", extractor, valobj_sp->GetExecutionContextRef(),
341 m_pair_sp = pair_sp->GetChildAtIndex(4,
true);
358 return m_pair_ptr->GetChildAtIndex(idx,
true);
360 return m_pair_sp->GetChildAtIndex(idx,
true);
361 return lldb::ValueObjectSP();
373 if (name ==
"second")
401 m_iter_ptr =
nullptr;
403 ValueObjectSP valobj_sp = m_backend.GetSP();
407 TargetSP target_sp(valobj_sp->GetTargetSP());
419 SyntheticChildrenTraversal::None);
428 ->GetValueForExpressionPath(
".__i_.__node_",
nullptr,
nullptr,
429 exprPathOptions,
nullptr)
434 valobj_sp->GetChildMemberWithName(
ConstString(
"__i_"),
true));
436 m_iter_ptr =
nullptr;
441 .GetTypeTemplateArgument(0)
447 uint64_t bit_offset_ptr;
449 bool is_bitfield_ptr;
452 0, name, &bit_offset_ptr, &bitfield_bit_size_ptr, &is_bitfield_ptr);
454 m_iter_ptr =
nullptr;
459 m_iter_ptr =
nullptr;
481 CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier(
486 {
"__value_", pair_type}});
487 std::optional<uint64_t> size = tree_node_type.
GetByteSize(
nullptr);
491 ProcessSP process_sp(target_sp->GetProcessSP());
493 process_sp->ReadMemory(addr, buffer_sp->GetBytes(),
494 buffer_sp->GetByteSize(),
error);
497 DataExtractor extractor(buffer_sp, process_sp->GetByteOrder(),
498 process_sp->GetAddressByteSize());
499 auto pair_sp = CreateValueObjectFromData(
500 "pair", extractor, valobj_sp->GetExecutionContextRef(), tree_node_type);
502 m_pair_sp = pair_sp->GetChildAtIndex(2,
true);
516 return m_pair_sp->GetChildAtIndex(idx,
true);
517 return lldb::ValueObjectSP();
529 if (name ==
"second")
567 return (m_cntrl ? 1 : 0);
574 return lldb::ValueObjectSP();
576 ValueObjectSP valobj_sp = m_backend.GetSP();
578 return lldb::ValueObjectSP();
581 return valobj_sp->GetChildMemberWithName(
ConstString(
"__ptr_"),
true);
585 valobj_sp->GetChildMemberWithName(
ConstString(
"__ptr_"),
true)) {
587 auto value_sp = ptr_sp->Dereference(status);
590 valobj_sp->GetCompilerType().GetTypeTemplateArgument(0);
591 return value_sp->Cast(value_type_sp);
596 return lldb::ValueObjectSP();
602 ValueObjectSP valobj_sp = m_backend.GetSP();
606 TargetSP target_sp(valobj_sp->GetTargetSP());
610 lldb::ValueObjectSP cntrl_sp(
611 valobj_sp->GetChildMemberWithName(
ConstString(
"__cntrl_"),
true));
613 m_cntrl = cntrl_sp.get();
625 if (name ==
"__ptr_")
627 if (name ==
"$$dereference$$")
661 return (m_value_ptr_sp ? 1 : 0);
668 return lldb::ValueObjectSP();
671 return m_value_ptr_sp;
675 auto value_sp = m_value_ptr_sp->Dereference(status);
681 return lldb::ValueObjectSP();
685 ValueObjectSP valobj_sp = m_backend.GetSP();
689 ValueObjectSP ptr_sp(
690 valobj_sp->GetChildMemberWithName(
ConstString(
"__ptr_"),
true));
706 if (name ==
"__value_")
708 if (name ==
"$$dereference$$")
719 stream.
Printf(
"0x%016" PRIx64
" ", value);
722 nullptr,
nullptr, &valobj,
false,
false);
727enum class StringLayout { CSD, DSC };
733static std::optional<std::pair<uint64_t, ValueObjectSP>>
735 ValueObjectSP valobj_r_sp =
737 if (!valobj_r_sp || !valobj_r_sp->GetError().Success())
742 ValueObjectSP valobj_r_base_sp =
743 valobj_r_sp->GetChildAtIndex(0,
true);
744 if (!valobj_r_base_sp)
747 ValueObjectSP valobj_rep_sp = valobj_r_base_sp->GetChildMemberWithName(
752 ValueObjectSP l = valobj_rep_sp->GetChildMemberWithName(
ConstString(
"__l"),
757 StringLayout layout = l->GetIndexOfChildWithName(
ConstString(
"__data_")) == 0
761 bool short_mode =
false;
763 bool using_bitmasks =
true;
766 uint64_t size_mode_value = 0;
768 ValueObjectSP short_sp = valobj_rep_sp->GetChildMemberWithName(
773 ValueObjectSP is_long =
774 short_sp->GetChildMemberWithName(
ConstString(
"__is_long_"),
true);
775 ValueObjectSP size_sp =
776 short_sp->GetChildAtNamePath({
ConstString(
"__size_")});
781 using_bitmasks =
false;
782 short_mode = !is_long->GetValueAsUnsigned(0);
783 size = size_sp->GetValueAsUnsigned(0);
786 size_mode_value = size_sp->GetValueAsUnsigned(0);
787 uint8_t mode_mask = layout == StringLayout::DSC ? 0x80 : 1;
788 short_mode = (size_mode_value & mode_mask) == 0;
792 ValueObjectSP location_sp =
793 short_sp->GetChildMemberWithName(
ConstString(
"__data_"),
true);
795 size = (layout == StringLayout::DSC) ? size_mode_value
796 : ((size_mode_value >> 1) % 256);
802 const std::optional<uint64_t> max_bytes =
803 location_sp->GetCompilerType().GetByteSize(
805 if (!max_bytes || size > *max_bytes || !location_sp)
808 return std::make_pair(size, location_sp);
812 ValueObjectSP location_sp =
813 l->GetChildMemberWithName(
ConstString(
"__data_"),
true);
814 ValueObjectSP size_vo =
815 l->GetChildMemberWithName(
ConstString(
"__size_"),
true);
816 ValueObjectSP capacity_vo =
817 l->GetChildMemberWithName(
ConstString(
"__cap_"),
true);
818 if (!size_vo || !location_sp || !capacity_vo)
822 if (!using_bitmasks && layout == StringLayout::CSD)
827 return std::make_pair(size, location_sp);
833 ValueObjectSP location_sp,
size_t size) {
842 if (summary_options.
GetCapping() == TypeSummaryCapping::eTypeSummaryCapped) {
843 const auto max_size = valobj.
GetTargetSP()->GetMaximumSizeOfStringSummary();
844 if (size > max_size) {
851 const size_t bytes_read = location_sp->GetPointeeData(extractor, 0, size);
852 if (bytes_read < size)
856 TypeSystemClangSP scratch_ts_sp =
866 options.
SetData(std::move(extractor));
873 switch (*wchar_t_size) {
876 lldb_private::formatters::StringPrinter::StringElementType::UTF8>(
882 lldb_private::formatters::StringPrinter::StringElementType::UTF16>(
888 lldb_private::formatters::StringPrinter::StringElementType::UTF32>(
901 ValueObjectSP location_sp;
902 std::tie(size, location_sp) = *string_info;
904 return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options,
908template <StringPr
inter::StringElementType element_type>
912 std::string prefix_token, ValueObjectSP location_sp,
925 if (summary_options.
GetCapping() == TypeSummaryCapping::eTypeSummaryCapped) {
926 const auto max_size = valobj.
GetTargetSP()->GetMaximumSizeOfStringSummary();
927 if (size > max_size) {
935 const size_t bytes_read = location_sp->GetPointeeData(extractor, 0, size);
936 if (bytes_read < size)
939 options.
SetData(std::move(extractor));
942 if (prefix_token.empty())
949 return StringPrinter::ReadBufferAndDumpToStream<element_type>(options);
952template <StringPr
inter::StringElementType element_type>
956 std::string prefix_token) {
961 ValueObjectSP location_sp;
962 std::tie(size, location_sp) = *string_info;
964 return LibcxxStringSummaryProvider<element_type>(
965 valobj, stream, summary_options, prefix_token, location_sp, size);
967template <StringPr
inter::StringElementType element_type>
970 std::string prefix_token) {
972 const bool success = LibcxxStringSummaryProvider<element_type>(
973 valobj, scratch_stream, summary_options, prefix_token);
975 stream << scratch_stream.
GetData();
977 stream <<
"Summary Unavailable";
984 return formatStringImpl<StringPrinter::StringElementType::ASCII>(
985 valobj, stream, summary_options,
"");
991 return formatStringImpl<StringPrinter::StringElementType::UTF16>(
992 valobj, stream, summary_options,
"u");
998 return formatStringImpl<StringPrinter::StringElementType::UTF32>(
999 valobj, stream, summary_options,
"U");
1002static std::tuple<bool, ValueObjectSP, size_t>
1008 if (!dataobj || !sizeobj)
1009 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
1011 if (!dataobj->GetError().Success() || !sizeobj->GetError().Success())
1012 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
1014 bool success{
false};
1015 uint64_t size = sizeobj->GetValueAsUnsigned(0, &success);
1017 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
1019 return std::make_tuple(
true,dataobj,size);
1022template <StringPr
inter::StringElementType element_type>
1025 std::string prefix_token) {
1028 ValueObjectSP dataobj;
1033 stream <<
"Summary Unavailable";
1037 return LibcxxStringSummaryProvider<element_type>(
1038 valobj, stream, summary_options, prefix_token, dataobj, size);
1044 return formatStringViewImpl<StringPrinter::StringElementType::ASCII>(
1045 valobj, stream, summary_options,
"");
1051 return formatStringViewImpl<StringPrinter::StringElementType::UTF16>(
1052 valobj, stream, summary_options,
"u");
1058 return formatStringViewImpl<StringPrinter::StringElementType::UTF32>(
1059 valobj, stream, summary_options,
"U");
1067 ValueObjectSP dataobj;
1072 stream <<
"Summary Unavailable";
1077 return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options,
static llvm::raw_ostream & error(Stream &strm)
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)
LibCppStdFunctionCallableInfo FindLibCppStdFunctionCallableInfo(lldb::ValueObjectSP &valobj_sp)
static CPPLanguageRuntime * Get(Process &process)
std::shared_ptr< TypeSystemType > dyn_cast_or_null()
Return a shared_ptr<TypeSystemType> if dyn_cast succeeds.
Generic representation of a type in a programming language.
CompilerType GetTypeTemplateArgument(size_t idx, bool expand_pack=false) const
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
std::optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
CompilerType GetFieldAtIndex(size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) const
A uniqued constant string class.
const char * GetCString() const
Get the string value as a C string.
A subclass of DataBuffer that stores a data buffer on the heap.
"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
A TypeSystem implementation based on Clang.
virtual uint64_t GetValueAsUnsigned(uint64_t fail_value, bool *success=nullptr)
lldb::TargetSP GetTargetSP() const
virtual bool IsPointerType()
virtual lldb::ValueObjectSP GetChildMemberWithName(ConstString name, bool can_create)
virtual lldb::ValueObjectSP GetNonSyntheticValue()
@ eValueObjectRepresentationStyleSummary
#define LLDB_INVALID_ADDRESS
#define LLDB_INVALID_OFFSET
A class that represents a running process on the host machine.
@ eBasicTypeUnsignedLongLong
lldb::addr_t member_f_pointer_value
LineEntry callable_line_entry
LibCppStdFunctionCallableCase callable_case
FileSpec file
The source file, possibly mapped by the target.source-map setting.
uint32_t line
The source line number, or zero if there is no line number information.
GetValueForExpressionPathOptions & SetSyntheticChildrenTraversal(SyntheticChildrenTraversal traverse)
GetValueForExpressionPathOptions & DontCheckDotVsArrowSyntax()