39 ValueObject &obj, llvm::ArrayRef<ConstString> alternative_names) {
55 value = first_child->GetChildMemberWithName(
"__value_",
true);
70 value = second_child->GetChildMemberWithName(
"__value_",
true);
88 ValueObjectSP engaged_sp(
89 valobj_sp->GetChildMemberWithName(
"__engaged_",
true));
94 llvm::StringRef engaged_as_cstring(
95 engaged_sp->GetValueAsUnsigned(0) == 1 ?
"true" :
"false");
97 stream.
Printf(
" Has Value=%s ", engaged_as_cstring.data());
113 if (process ==
nullptr)
125 case CPPLanguageRuntime::LibCppStdFunctionCallableCase::Invalid:
129 case CPPLanguageRuntime::LibCppStdFunctionCallableCase::Lambda:
131 " Lambda in File %s at Line %u",
135 case CPPLanguageRuntime::LibCppStdFunctionCallableCase::CallableObject:
137 " Function in File %s at Line %u",
141 case CPPLanguageRuntime::LibCppStdFunctionCallableCase::FreeOrMemberFunction:
142 stream.
Printf(
" Function = %s ",
155 ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName(
"__ptr_",
true));
156 ValueObjectSP count_sp(
157 valobj_sp->GetChildAtNamePath({
"__cntrl_",
"__shared_owners_"}));
158 ValueObjectSP weakcount_sp(
159 valobj_sp->GetChildAtNamePath({
"__cntrl_",
"__shared_weak_owners_"}));
164 if (ptr_sp->GetValueAsUnsigned(0) == 0) {
168 bool print_pointee =
false;
170 ValueObjectSP pointee_sp = ptr_sp->Dereference(
error);
171 if (pointee_sp &&
error.Success()) {
172 if (pointee_sp->DumpPrintableRepresentation(
175 ValueObject::PrintableRepresentationSpecialCases::eDisable,
177 print_pointee =
true;
180 stream.
Printf(
"ptr = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0));
184 stream.
Printf(
" strong=%" PRIu64, 1 + count_sp->GetValueAsUnsigned(0));
187 stream.
Printf(
" weak=%" PRIu64, 1 + weakcount_sp->GetValueAsUnsigned(0));
198 ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName(
"__ptr_",
true));
206 if (ptr_sp->GetValueAsUnsigned(0) == 0) {
210 bool print_pointee =
false;
212 ValueObjectSP pointee_sp = ptr_sp->Dereference(
error);
213 if (pointee_sp &&
error.Success()) {
214 if (pointee_sp->DumpPrintableRepresentation(
217 ValueObject::PrintableRepresentationSpecialCases::eDisable,
219 print_pointee =
true;
222 stream.
Printf(
"ptr = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0));
259 m_pair_ptr =
nullptr;
261 ValueObjectSP valobj_sp = m_backend.GetSP();
265 TargetSP target_sp(valobj_sp->GetTargetSP());
278 m_pair_ptr = valobj_sp
279 ->GetValueForExpressionPath(
280 ".__i_.__ptr_->__value_",
nullptr,
nullptr,
282 .DontCheckDotVsArrowSyntax()
283 .SetSyntheticChildrenTraversal(
285 SyntheticChildrenTraversal::None),
290 m_pair_ptr = valobj_sp
291 ->GetValueForExpressionPath(
292 ".__i_.__ptr_",
nullptr,
nullptr,
294 .DontCheckDotVsArrowSyntax()
295 .SetSyntheticChildrenTraversal(
297 SyntheticChildrenTraversal::None),
301 auto __i_(valobj_sp->GetChildMemberWithName(
"__i_",
true));
303 m_pair_ptr =
nullptr;
307 __i_->GetCompilerType().GetTypeTemplateArgument(0));
309 uint64_t bit_offset_ptr;
311 bool is_bitfield_ptr;
313 0, name, &bit_offset_ptr, &bitfield_bit_size_ptr, &is_bitfield_ptr);
315 m_pair_ptr =
nullptr;
320 m_pair_ptr =
nullptr;
342 CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier(
351 {
"payload", pair_type}});
352 std::optional<uint64_t> size = tree_node_type.
GetByteSize(
nullptr);
356 ProcessSP process_sp(target_sp->GetProcessSP());
358 process_sp->ReadMemory(addr, buffer_sp->GetBytes(),
359 buffer_sp->GetByteSize(),
error);
362 DataExtractor extractor(buffer_sp, process_sp->GetByteOrder(),
363 process_sp->GetAddressByteSize());
364 auto pair_sp = CreateValueObjectFromData(
365 "pair", extractor, valobj_sp->GetExecutionContextRef(),
368 m_pair_sp = pair_sp->GetChildAtIndex(4,
true);
385 return m_pair_ptr->GetChildAtIndex(idx,
true);
387 return m_pair_sp->GetChildAtIndex(idx,
true);
388 return lldb::ValueObjectSP();
400 if (name ==
"second")
428 m_iter_ptr =
nullptr;
430 ValueObjectSP valobj_sp = m_backend.GetSP();
434 TargetSP target_sp(valobj_sp->GetTargetSP());
446 SyntheticChildrenTraversal::None);
455 ->GetValueForExpressionPath(
".__i_.__node_",
nullptr,
nullptr,
456 exprPathOptions,
nullptr)
460 auto iter_child(valobj_sp->GetChildMemberWithName(
"__i_",
true));
462 m_iter_ptr =
nullptr;
467 .GetTypeTemplateArgument(0)
473 uint64_t bit_offset_ptr;
475 bool is_bitfield_ptr;
478 0, name, &bit_offset_ptr, &bitfield_bit_size_ptr, &is_bitfield_ptr);
480 m_iter_ptr =
nullptr;
485 m_iter_ptr =
nullptr;
507 CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier(
512 {
"__value_", pair_type}});
513 std::optional<uint64_t> size = tree_node_type.
GetByteSize(
nullptr);
517 ProcessSP process_sp(target_sp->GetProcessSP());
519 process_sp->ReadMemory(addr, buffer_sp->GetBytes(),
520 buffer_sp->GetByteSize(),
error);
523 DataExtractor extractor(buffer_sp, process_sp->GetByteOrder(),
524 process_sp->GetAddressByteSize());
525 auto pair_sp = CreateValueObjectFromData(
526 "pair", extractor, valobj_sp->GetExecutionContextRef(), tree_node_type);
528 m_pair_sp = pair_sp->GetChildAtIndex(2,
true);
542 return m_pair_sp->GetChildAtIndex(idx,
true);
543 return lldb::ValueObjectSP();
555 if (name ==
"second")
593 return (m_cntrl ? 1 : 0);
600 return lldb::ValueObjectSP();
602 ValueObjectSP valobj_sp = m_backend.GetSP();
604 return lldb::ValueObjectSP();
607 return valobj_sp->GetChildMemberWithName(
"__ptr_",
true);
610 if (
auto ptr_sp = valobj_sp->GetChildMemberWithName(
"__ptr_",
true)) {
612 auto value_sp = ptr_sp->Dereference(status);
615 valobj_sp->GetCompilerType().GetTypeTemplateArgument(0);
616 return value_sp->Cast(value_type_sp);
621 return lldb::ValueObjectSP();
627 ValueObjectSP valobj_sp = m_backend.GetSP();
631 TargetSP target_sp(valobj_sp->GetTargetSP());
635 lldb::ValueObjectSP cntrl_sp(
636 valobj_sp->GetChildMemberWithName(
"__cntrl_",
true));
638 m_cntrl = cntrl_sp.get();
650 if (name ==
"__ptr_")
652 if (name ==
"$$dereference$$")
687 return m_deleter_sp ? 2 : 1;
695 return lldb::ValueObjectSP();
698 return m_value_ptr_sp;
705 auto value_sp = m_value_ptr_sp->Dereference(status);
711 return lldb::ValueObjectSP();
715 ValueObjectSP valobj_sp = m_backend.GetSP();
719 ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName(
"__ptr_",
true));
726 if (value_pointer_sp)
727 m_value_ptr_sp = value_pointer_sp->Clone(
ConstString(
"pointer"));
731 m_deleter_sp = deleter_sp->Clone(
ConstString(
"deleter"));
743 if (name ==
"pointer")
745 if (name ==
"deleter")
747 if (name ==
"$$dereference$$")
758 stream.
Printf(
"0x%016" PRIx64
" ", value);
761 nullptr,
nullptr, &valobj,
false,
false);
766enum class StringLayout { CSD, DSC };
772static std::optional<std::pair<uint64_t, ValueObjectSP>>
774 ValueObjectSP valobj_r_sp =
776 if (!valobj_r_sp || !valobj_r_sp->GetError().Success())
781 ValueObjectSP valobj_r_base_sp =
782 valobj_r_sp->GetChildAtIndex(0,
true);
783 if (!valobj_r_base_sp)
786 ValueObjectSP valobj_rep_sp =
787 valobj_r_base_sp->GetChildMemberWithName(
"__value_",
true);
791 ValueObjectSP l = valobj_rep_sp->GetChildMemberWithName(
"__l",
796 StringLayout layout = l->GetIndexOfChildWithName(
"__data_") == 0
800 bool short_mode =
false;
802 bool using_bitmasks =
true;
805 uint64_t size_mode_value = 0;
807 ValueObjectSP short_sp =
808 valobj_rep_sp->GetChildMemberWithName(
"__s",
true);
812 ValueObjectSP is_long = short_sp->GetChildMemberWithName(
"__is_long_",
true);
813 ValueObjectSP size_sp = short_sp->GetChildMemberWithName(
"__size_",
true);
818 using_bitmasks =
false;
819 short_mode = !is_long->GetValueAsUnsigned(0);
820 size = size_sp->GetValueAsUnsigned(0);
823 size_mode_value = size_sp->GetValueAsUnsigned(0);
824 uint8_t mode_mask = layout == StringLayout::DSC ? 0x80 : 1;
825 short_mode = (size_mode_value & mode_mask) == 0;
829 ValueObjectSP location_sp =
830 short_sp->GetChildMemberWithName(
"__data_",
true);
832 size = (layout == StringLayout::DSC) ? size_mode_value
833 : ((size_mode_value >> 1) % 256);
839 const std::optional<uint64_t> max_bytes =
840 location_sp->GetCompilerType().GetByteSize(
842 if (!max_bytes || size > *max_bytes || !location_sp)
845 return std::make_pair(size, location_sp);
849 ValueObjectSP location_sp =
850 l->GetChildMemberWithName(
"__data_",
true);
851 ValueObjectSP size_vo =
852 l->GetChildMemberWithName(
"__size_",
true);
853 ValueObjectSP capacity_vo =
854 l->GetChildMemberWithName(
"__cap_",
true);
855 if (!size_vo || !location_sp || !capacity_vo)
859 if (!using_bitmasks && layout == StringLayout::CSD)
864 return std::make_pair(size, location_sp);
870 ValueObjectSP location_sp,
size_t size) {
879 if (summary_options.
GetCapping() == TypeSummaryCapping::eTypeSummaryCapped) {
880 const auto max_size = valobj.
GetTargetSP()->GetMaximumSizeOfStringSummary();
881 if (size > max_size) {
888 const size_t bytes_read = location_sp->GetPointeeData(extractor, 0, size);
889 if (bytes_read < size)
893 TypeSystemClangSP scratch_ts_sp =
903 options.
SetData(std::move(extractor));
910 switch (*wchar_t_size) {
913 lldb_private::formatters::StringPrinter::StringElementType::UTF8>(
919 lldb_private::formatters::StringPrinter::StringElementType::UTF16>(
925 lldb_private::formatters::StringPrinter::StringElementType::UTF32>(
938 ValueObjectSP location_sp;
939 std::tie(size, location_sp) = *string_info;
941 return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options,
945template <StringPr
inter::StringElementType element_type>
949 std::string prefix_token, ValueObjectSP location_sp,
962 if (summary_options.
GetCapping() == TypeSummaryCapping::eTypeSummaryCapped) {
963 const auto max_size = valobj.
GetTargetSP()->GetMaximumSizeOfStringSummary();
964 if (size > max_size) {
972 const size_t bytes_read = location_sp->GetPointeeData(extractor, 0, size);
973 if (bytes_read < size)
976 options.
SetData(std::move(extractor));
979 if (prefix_token.empty())
986 return StringPrinter::ReadBufferAndDumpToStream<element_type>(options);
989template <StringPr
inter::StringElementType element_type>
993 std::string prefix_token) {
998 ValueObjectSP location_sp;
999 std::tie(size, location_sp) = *string_info;
1001 return LibcxxStringSummaryProvider<element_type>(
1002 valobj, stream, summary_options, prefix_token, location_sp, size);
1004template <StringPr
inter::StringElementType element_type>
1007 std::string prefix_token) {
1009 const bool success = LibcxxStringSummaryProvider<element_type>(
1010 valobj, scratch_stream, summary_options, prefix_token);
1012 stream << scratch_stream.
GetData();
1014 stream <<
"Summary Unavailable";
1021 return formatStringImpl<StringPrinter::StringElementType::ASCII>(
1022 valobj, stream, summary_options,
"");
1028 return formatStringImpl<StringPrinter::StringElementType::UTF16>(
1029 valobj, stream, summary_options,
"u");
1035 return formatStringImpl<StringPrinter::StringElementType::UTF32>(
1036 valobj, stream, summary_options,
"U");
1039static std::tuple<bool, ValueObjectSP, size_t>
1045 if (!dataobj || !sizeobj)
1046 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
1048 if (!dataobj->GetError().Success() || !sizeobj->GetError().Success())
1049 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
1051 bool success{
false};
1052 uint64_t size = sizeobj->GetValueAsUnsigned(0, &success);
1054 return std::make_tuple<bool,ValueObjectSP,size_t>(
false, {}, {});
1056 return std::make_tuple(
true,dataobj,size);
1059template <StringPr
inter::StringElementType element_type>
1062 std::string prefix_token) {
1065 ValueObjectSP dataobj;
1070 stream <<
"Summary Unavailable";
1074 return LibcxxStringSummaryProvider<element_type>(
1075 valobj, stream, summary_options, prefix_token, dataobj, size);
1081 return formatStringViewImpl<StringPrinter::StringElementType::ASCII>(
1082 valobj, stream, summary_options,
"");
1088 return formatStringViewImpl<StringPrinter::StringElementType::UTF16>(
1089 valobj, stream, summary_options,
"u");
1095 return formatStringViewImpl<StringPrinter::StringElementType::UTF32>(
1096 valobj, stream, summary_options,
"U");
1104 ValueObjectSP dataobj;
1109 stream <<
"Summary Unavailable";
1114 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 lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create)
size_t GetNumChildren(uint32_t max=UINT32_MAX)
virtual uint64_t GetValueAsUnsigned(uint64_t fail_value, bool *success=nullptr)
lldb::TargetSP GetTargetSP() const
virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name, bool can_create)
virtual bool IsPointerType()
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()