19#include "llvm/ADT/StringRef.h"
20#include "llvm/Demangle/ItaniumDemangle.h"
74 if (demangled_name && mangled_name_cstr && mangled_name_cstr[0]) {
75 if (mangled_name_cstr[0] ==
'_' && mangled_name_cstr[1] ==
'Z' &&
76 (mangled_name_cstr[2] !=
'T' &&
79 mangled_name_cstr[2] !=
'G' &&
80 mangled_name_cstr[2] !=
'Z'))
86 std::string shortname;
88 shortname = cxx_method.
GetContext().str() +
"::";
95 return demangled_name;
121 const llvm::StringRef &left_right_chars,
122 size_t &left_pos,
size_t &right_pos,
123 size_t pos = llvm::StringRef::npos) {
124 assert(left_right_chars.size() == 2);
125 left_pos = llvm::StringRef::npos;
126 const char left_char = left_right_chars[0];
127 const char right_char = left_right_chars[1];
128 pos = s.find_last_of(left_right_chars, pos);
129 if (pos == llvm::StringRef::npos || s[pos] == left_char)
133 while (pos > 0 && depth > 0) {
134 pos = s.find_last_of(left_right_chars, pos);
135 if (pos == llvm::StringRef::npos)
137 if (s[pos] == left_char) {
140 return left_pos < right_pos;
142 }
else if (s[pos] == right_char) {
155 if (basename.starts_with(
'~'))
158 if (basename.size() <= idx)
161 if (!std::isalpha(basename[idx]) && basename[idx] !=
'_')
167 while (idx < basename.size()) {
168 if (!std::isalnum(basename[idx]) && basename[idx] !=
'_')
174 return idx == basename.size();
181 char const *full_name,
186 if (!cpp_method.IsValid())
189 llvm::StringRef return_type = cpp_method.GetReturnType();
190 if (!return_type.empty()) {
195 out_stream.
PutCString(cpp_method.GetScopeQualifiedName());
202 llvm::StringRef qualifiers = cpp_method.GetQualifiers();
203 if (!qualifiers.empty()) {
216 size_t arg_start, arg_end;
217 llvm::StringRef full(m_full.GetCString());
218 llvm::StringRef parens(
"()", 2);
220 m_arguments = full.substr(arg_start, arg_end - arg_start + 1);
221 if (arg_end + 1 < full.size())
222 m_qualifiers = full.substr(arg_end + 1).ltrim();
226 size_t basename_end = arg_start;
227 size_t context_start = 0;
228 size_t context_end = full.rfind(
':', basename_end);
229 if (context_end == llvm::StringRef::npos)
230 m_basename = full.substr(0, basename_end);
232 if (context_start < context_end)
233 m_context = full.substr(context_start, context_end - 1 - context_start);
234 const size_t basename_begin = context_end + 1;
235 m_basename = full.substr(basename_begin, basename_end - basename_begin);
243 m_context = llvm::StringRef();
244 m_basename = llvm::StringRef();
245 m_arguments = llvm::StringRef();
246 m_qualifiers = llvm::StringRef();
247 m_return_type = llvm::StringRef();
255 if (!m_parsed && m_full) {
256 if (TrySimplifiedParse()) {
257 m_parse_error =
false;
261 m_basename = function->name.basename;
262 m_context = function->name.context;
263 m_arguments = function->arguments;
264 m_qualifiers = function->qualifiers;
265 m_return_type = function->return_type;
266 m_parse_error =
false;
268 m_parse_error =
true;
302 return m_return_type;
308 if (m_context.empty())
309 return std::string(m_basename);
320 llvm::StringRef basename = GetBasename();
321 size_t arg_start, arg_end;
322 llvm::StringRef parens(
"<>", 2);
324 return basename.substr(0, arg_start);
335 return m_full.GetStringRef().contains(path);
337 llvm::StringRef identifier;
338 llvm::StringRef context;
339 std::string path_str = path.str();
341 path_str.c_str(), context, identifier);
343 return m_full.GetStringRef().contains(path);
358 if (GetBasename() != identifier &&
359 GetBasenameNoTemplateParameters() != identifier)
366 if (m_context.empty())
369 llvm::StringRef haystack = m_context;
370 if (!haystack.consume_back(context))
372 if (haystack.empty() || !isalnum(haystack.back()))
397 const char *name, llvm::StringRef &context, llvm::StringRef &identifier) {
404 identifier = full_name->basename;
405 context = full_name->context;
413 llvm::BumpPtrAllocator Alloc;
416 void reset() { Alloc.Reset(); }
418 template <
typename T,
typename...
Args> T *makeNode(
Args &&... args) {
419 return new (Alloc.Allocate(
sizeof(T),
alignof(T)))
420 T(std::forward<Args>(args)...);
423 void *allocateNodeArray(
size_t sz) {
424 return Alloc.Allocate(
sizeof(llvm::itanium_demangle::Node *) * sz,
425 alignof(llvm::itanium_demangle::Node *));
429template <
typename Derived>
430class ManglingSubstitutor
431 :
public llvm::itanium_demangle::AbstractManglingParser<Derived,
434 llvm::itanium_demangle::AbstractManglingParser<Derived, NodeAllocator>;
437 ManglingSubstitutor() :
Base(nullptr, nullptr) {}
439 template <
typename... Ts>
441 this->getDerived().reset(
Mangled, std::forward<Ts>(Vals)...);
442 return substituteImpl(
Mangled);
446 void reset(llvm::StringRef
Mangled) {
455 if (this->parse() ==
nullptr) {
463 appendUnchangedInput();
468 void trySubstitute(llvm::StringRef From, llvm::StringRef To) {
469 if (!llvm::StringRef(currentParserPos(), this->numLeft()).starts_with(From))
473 appendUnchangedInput();
477 Written += From.size();
484 const char *Written =
"";
486 llvm::SmallString<128> Result;
489 bool Substituted =
false;
491 const char *currentParserPos()
const {
return this->First; }
493 void appendUnchangedInput() {
495 llvm::StringRef(Written, std::distance(Written, currentParserPos()));
496 Written = currentParserPos();
502class TypeSubstitutor :
public ManglingSubstitutor<TypeSubstitutor> {
503 llvm::StringRef Search;
504 llvm::StringRef Replace;
507 void reset(llvm::StringRef
Mangled, llvm::StringRef Search,
508 llvm::StringRef Replace) {
509 ManglingSubstitutor::reset(
Mangled);
510 this->Search = Search;
511 this->Replace = Replace;
514 llvm::itanium_demangle::Node *parseType() {
515 trySubstitute(Search, Replace);
516 return ManglingSubstitutor::parseType();
520class CtorDtorSubstitutor :
public ManglingSubstitutor<CtorDtorSubstitutor> {
522 llvm::itanium_demangle::Node *
523 parseCtorDtorName(llvm::itanium_demangle::Node *&SoFar, NameState *State) {
524 trySubstitute(
"C1",
"C2");
525 trySubstitute(
"D1",
"D2");
526 return ManglingSubstitutor::parseCtorDtorName(SoFar, State);
533 std::vector<ConstString> alternates;
543 if (!strncmp(mangled_name.
GetCString(),
"_ZN", 3) &&
544 strncmp(mangled_name.
GetCString(),
"_ZNK", 4)) {
545 std::string fixed_scratch(
"_ZNK");
546 fixed_scratch.append(mangled_name.
GetCString() + 3);
551 if (!strncmp(mangled_name.
GetCString(),
"_Z", 2) &&
552 strncmp(mangled_name.
GetCString(),
"_ZL", 3)) {
553 std::string fixed_scratch(
"_ZL");
554 fixed_scratch.append(mangled_name.
GetCString() + 2);
565 alternates.push_back(char_fixup);
570 alternates.push_back(long_fixup);
576 alternates.push_back(ulong_fixup);
579 CtorDtorSubstitutor().substitute(mangled_name.
GetStringRef()))
580 alternates.push_back(ctor_fixup);
594 if (!scope_qualified_name.size())
604 std::vector<ConstString> alternates;
607 std::vector<ConstString> param_and_qual_matches;
608 std::vector<ConstString> param_matches;
609 for (
size_t i = 0; i < alternates.size(); i++) {
610 ConstString alternate_mangled_name = alternates[i];
611 Mangled mangled(alternate_mangled_name);
620 param_and_qual_matches.push_back(alternate_mangled_name);
622 param_matches.push_back(alternate_mangled_name);
626 if (param_and_qual_matches.size())
627 return param_and_qual_matches[0];
629 else if (param_matches.size())
630 return param_matches[0];
636 if (!cpp_category_sp)
650 "std::string summary provider",
"^std::__[[:alnum:]]+::string$",
651 stl_summary_flags,
true);
654 "std::string summary provider",
655 "^std::__[[:alnum:]]+::basic_string<char, "
656 "std::__[[:alnum:]]+::char_traits<char>, "
657 "std::__[[:alnum:]]+::allocator<char> >$",
658 stl_summary_flags,
true);
661 "std::string summary provider",
662 "^std::__[[:alnum:]]+::basic_string<unsigned char, "
663 "std::__[[:alnum:]]+::char_traits<unsigned char>, "
664 "std::__[[:alnum:]]+::allocator<unsigned char> >$",
665 stl_summary_flags,
true);
669 "std::u16string summary provider",
670 "^std::__[[:alnum:]]+::basic_string<char16_t, "
671 "std::__[[:alnum:]]+::char_traits<char16_t>, "
672 "std::__[[:alnum:]]+::allocator<char16_t> >$",
673 stl_summary_flags,
true);
677 "std::u32string summary provider",
678 "^std::__[[:alnum:]]+::basic_string<char32_t, "
679 "std::__[[:alnum:]]+::char_traits<char32_t>, "
680 "std::__[[:alnum:]]+::allocator<char32_t> >$",
681 stl_summary_flags,
true);
685 "std::wstring summary provider",
686 "^std::__[[:alnum:]]+::wstring$", stl_summary_flags,
true);
689 "std::wstring summary provider",
690 "^std::__[[:alnum:]]+::basic_string<wchar_t, "
691 "std::__[[:alnum:]]+::char_traits<wchar_t>, "
692 "std::__[[:alnum:]]+::allocator<wchar_t> >$",
693 stl_summary_flags,
true);
697 "std::string_view summary provider",
698 "^std::__[[:alnum:]]+::string_view$", stl_summary_flags,
true);
701 "std::string_view summary provider",
702 "^std::__[[:alnum:]]+::basic_string_view<char, "
703 "std::__[[:alnum:]]+::char_traits<char> >$",
704 stl_summary_flags,
true);
707 "std::string_view summary provider",
708 "^std::__[[:alnum:]]+::basic_string_view<unsigned char, "
709 "std::__[[:alnum:]]+::char_traits<unsigned char> >$",
710 stl_summary_flags,
true);
714 "std::u16string_view summary provider",
715 "^std::__[[:alnum:]]+::basic_string_view<char16_t, "
716 "std::__[[:alnum:]]+::char_traits<char16_t> >$",
717 stl_summary_flags,
true);
721 "std::u32string_view summary provider",
722 "^std::__[[:alnum:]]+::basic_string_view<char32_t, "
723 "std::__[[:alnum:]]+::char_traits<char32_t> >$",
724 stl_summary_flags,
true);
728 "std::wstring_view summary provider",
729 "^std::__[[:alnum:]]+::wstring_view$", stl_summary_flags,
true);
732 "std::wstring_view summary provider",
733 "^std::__[[:alnum:]]+::basic_string_view<wchar_t, "
734 "std::__[[:alnum:]]+::char_traits<wchar_t> >$",
735 stl_summary_flags,
true);
746 "libc++ std::bitset synthetic children",
747 "^std::__[[:alnum:]]+::bitset<.+>$", stl_deref_flags,
true);
751 "libc++ std::vector synthetic children",
752 "^std::__[[:alnum:]]+::vector<.+>$", stl_deref_flags,
true);
756 "libc++ std::valarray synthetic children",
757 "^std::__[[:alnum:]]+::valarray<.+>$", stl_deref_flags,
true);
761 "libc++ std::slice_array synthetic children",
762 "^std::__[[:alnum:]]+::slice_array<.+>$", stl_deref_flags,
true);
766 "libc++ synthetic children for the valarray proxy arrays",
767 "^std::__[[:alnum:]]+::(gslice|mask|indirect)_array<.+>$",
768 stl_deref_flags,
true);
772 "libc++ std::forward_list synthetic children",
773 "^std::__[[:alnum:]]+::forward_list<.+>$", stl_synth_flags,
true);
777 "libc++ std::list synthetic children",
780 "^std::__([A-Zabd-z0-9]|cx?[A-Za-wyz0-9]|cxx1?[A-Za-z02-9]|"
781 "cxx11[[:alnum:]])[[:alnum:]]*::list<.+>$",
782 stl_deref_flags,
true);
786 "libc++ std::map synthetic children",
"^std::__[[:alnum:]]+::map<.+> >$",
787 stl_synth_flags,
true);
791 "libc++ std::set synthetic children",
"^std::__[[:alnum:]]+::set<.+> >$",
792 stl_deref_flags,
true);
796 "libc++ std::multiset synthetic children",
797 "^std::__[[:alnum:]]+::multiset<.+> >$", stl_deref_flags,
true);
801 "libc++ std::multimap synthetic children",
802 "^std::__[[:alnum:]]+::multimap<.+> >$", stl_synth_flags,
true);
806 "libc++ std::unordered containers synthetic children",
807 "^std::__[[:alnum:]]+::unordered_(multi)?(map|set)<.+> >$",
808 stl_synth_flags,
true);
812 "libc++ std::initializer_list synthetic children",
813 "^std::initializer_list<.+>$", stl_synth_flags,
true);
815 "libc++ std::queue synthetic children",
816 "^std::__[[:alnum:]]+::queue<.+>$", stl_synth_flags,
true);
818 "libc++ std::tuple synthetic children",
819 "^std::__[[:alnum:]]+::tuple<.*>$", stl_synth_flags,
true);
821 "libc++ std::optional synthetic children",
822 "^std::__[[:alnum:]]+::optional<.+>$", stl_synth_flags,
true);
824 "libc++ std::variant synthetic children",
825 "^std::__[[:alnum:]]+::variant<.+>$", stl_synth_flags,
true);
829 "libc++ std::atomic synthetic children",
830 "^std::__[[:alnum:]]+::atomic<.+>$", stl_synth_flags,
true);
834 "libc++ std::span synthetic children",
"^std::__[[:alnum:]]+::span<.+>$",
835 stl_deref_flags,
true);
839 "libc++ std::ranges::ref_view synthetic children",
840 "^std::__[[:alnum:]]+::ranges::ref_view<.+>$", stl_deref_flags,
true);
842 cpp_category_sp->AddTypeSynthetic(
846 "lldb.formatters.cpp.libcxx.stddeque_SynthProvider")));
851 "shared_ptr synthetic children",
"^std::__[[:alnum:]]+::shared_ptr<.+>$",
852 stl_synth_flags,
true);
854 static constexpr const char *
const libcxx_std_unique_ptr_regex =
855 "^std::__[[:alnum:]]+::unique_ptr<.+>$";
859 "unique_ptr synthetic children", libcxx_std_unique_ptr_regex,
860 stl_synth_flags,
true);
865 "weak_ptr synthetic children",
"^std::__[[:alnum:]]+::weak_ptr<.+>$",
866 stl_synth_flags,
true);
869 "libc++ std::function summary provider",
870 "^std::__[[:alnum:]]+::function<.+>$", stl_summary_flags,
true);
872 static constexpr const char *
const libcxx_std_coroutine_handle_regex =
873 "^std::__[[:alnum:]]+::coroutine_handle<.+>$";
877 "coroutine_handle synthetic children", libcxx_std_coroutine_handle_regex,
878 stl_deref_flags,
true);
884 "libc++ std::bitset summary provider",
885 "^std::__[[:alnum:]]+::bitset<.+>$", stl_summary_flags,
true);
888 "libc++ std::vector summary provider",
889 "^std::__[[:alnum:]]+::vector<.+>$", stl_summary_flags,
true);
892 "libc++ std::valarray summary provider",
893 "^std::__[[:alnum:]]+::valarray<.+>$", stl_summary_flags,
true);
896 "libc++ std::slice_array summary provider",
897 "^std::__[[:alnum:]]+::slice_array<.+>$", stl_summary_flags,
901 "libc++ summary provider for the valarray proxy arrays",
902 "^std::__[[:alnum:]]+::(gslice|mask|indirect)_array<.+>$",
903 stl_summary_flags,
true);
906 "libc++ std::list summary provider",
907 "^std::__[[:alnum:]]+::forward_list<.+>$", stl_summary_flags,
true);
910 "libc++ std::list summary provider",
913 "^std::__([A-Zabd-z0-9]|cx?[A-Za-wyz0-9]|cxx1?[A-Za-z02-9]|"
914 "cxx11[[:alnum:]])[[:alnum:]]*::list<.+>$",
915 stl_summary_flags,
true);
918 "libc++ std::map summary provider",
919 "^std::__[[:alnum:]]+::map<.+>$", stl_summary_flags,
true);
922 "libc++ std::deque summary provider",
923 "^std::__[[:alnum:]]+::deque<.+>$", stl_summary_flags,
true);
926 "libc++ std::queue summary provider",
927 "^std::__[[:alnum:]]+::queue<.+>$", stl_summary_flags,
true);
930 "libc++ std::set summary provider",
931 "^std::__[[:alnum:]]+::set<.+>$", stl_summary_flags,
true);
934 "libc++ std::multiset summary provider",
935 "^std::__[[:alnum:]]+::multiset<.+>$", stl_summary_flags,
true);
938 "libc++ std::multimap summary provider",
939 "^std::__[[:alnum:]]+::multimap<.+>$", stl_summary_flags,
true);
942 "libc++ std::unordered containers summary provider",
943 "^std::__[[:alnum:]]+::unordered_(multi)?(map|set)<.+> >$",
944 stl_summary_flags,
true);
946 "libc++ std::tuple summary provider",
947 "^std::__[[:alnum:]]+::tuple<.*>$", stl_summary_flags,
true);
950 "libc++ std::atomic summary provider",
951 "^std::__[[:alnum:]]+::atomic<.+>$", stl_summary_flags,
true);
954 "libc++ std::optional summary provider",
955 "^std::__[[:alnum:]]+::optional<.+>$", stl_summary_flags,
true);
958 "libc++ std::variant summary provider",
959 "^std::__[[:alnum:]]+::variant<.+>$", stl_summary_flags,
true);
962 "libc++ std::span summary provider",
963 "^std::__[[:alnum:]]+::span<.+>$", stl_summary_flags,
true);
969 "libc++ std::shared_ptr summary provider",
970 "^std::__[[:alnum:]]+::shared_ptr<.+>$", stl_summary_flags,
974 "libc++ std::weak_ptr summary provider",
975 "^std::__[[:alnum:]]+::weak_ptr<.+>$", stl_summary_flags,
true);
978 "libc++ std::unique_ptr summary provider",
979 libcxx_std_unique_ptr_regex, stl_summary_flags,
true);
983 "libc++ std::coroutine_handle summary provider",
984 libcxx_std_coroutine_handle_regex, stl_summary_flags,
true);
989 "std::vector iterator synthetic children",
990 "^std::__[[:alnum:]]+::__wrap_iter<.+>$", stl_synth_flags,
true);
995 "std::map iterator synthetic children",
996 "^std::__[[:alnum:]]+::__map_(const_)?iterator<.+>$", stl_synth_flags,
1002 "std::unordered_map iterator synthetic children",
1003 "^std::__[[:alnum:]]+::__hash_map_(const_)?iterator<.+>$",
1004 stl_synth_flags,
true);
1006 cpp_category_sp->AddTypeSummary(
1009 eTypeOptionHideChildren | eTypeOptionHideValue,
"${var.__rep_} ns")));
1010 cpp_category_sp->AddTypeSummary(
1013 eTypeOptionHideChildren | eTypeOptionHideValue,
"${var.__rep_} µs")));
1014 cpp_category_sp->AddTypeSummary(
1017 eTypeOptionHideChildren | eTypeOptionHideValue,
"${var.__rep_} ms")));
1018 cpp_category_sp->AddTypeSummary(
1021 eTypeOptionHideChildren | eTypeOptionHideValue,
"${var.__rep_} s")));
1022 cpp_category_sp->AddTypeSummary(
1025 eTypeOptionHideValue,
1026 "${var.__rep_} min")));
1027 cpp_category_sp->AddTypeSummary(
1030 eTypeOptionHideChildren | eTypeOptionHideValue,
"${var.__rep_} h")));
1032 cpp_category_sp->AddTypeSummary(
1035 eTypeOptionHideValue,
1036 "${var.__rep_} days")));
1037 cpp_category_sp->AddTypeSummary(
1040 eTypeOptionHideValue,
1041 "${var.__rep_} weeks")));
1042 cpp_category_sp->AddTypeSummary(
1045 eTypeOptionHideValue,
1046 "${var.__rep_} months")));
1047 cpp_category_sp->AddTypeSummary(
1050 eTypeOptionHideValue,
1051 "${var.__rep_} years")));
1052 cpp_category_sp->AddTypeSummary(
1055 eTypeOptionHideChildren | eTypeOptionHideValue,
"${var.__rep_} s")));
1061 "libc++ std::chrono::sys_seconds summary provider",
1062 "^std::__[[:alnum:]]+::chrono::time_point<"
1063 "std::__[[:alnum:]]+::chrono::system_clock, "
1064 "std::__[[:alnum:]]+::chrono::duration<.*, "
1065 "std::__[[:alnum:]]+::ratio<1, 1> "
1067 eTypeOptionHideChildren | eTypeOptionHideValue |
1072 "libc++ std::chrono::sys_seconds summary provider",
1073 "^std::__[[:alnum:]]+::chrono::time_point<"
1074 "std::__[[:alnum:]]+::chrono::system_clock, "
1075 "std::__[[:alnum:]]+::chrono::duration<int, "
1076 "std::__[[:alnum:]]+::ratio<86400, 1> "
1078 eTypeOptionHideChildren | eTypeOptionHideValue |
1085 "libc++ std::chrono::local_seconds summary provider",
1086 "^std::__[[:alnum:]]+::chrono::time_point<"
1087 "std::__[[:alnum:]]+::chrono::local_t, "
1088 "std::__[[:alnum:]]+::chrono::duration<.*, "
1089 "std::__[[:alnum:]]+::ratio<1, 1> "
1091 eTypeOptionHideChildren | eTypeOptionHideValue | eTypeOptionCascade,
1095 "libc++ std::chrono::local_seconds summary provider",
1096 "^std::__[[:alnum:]]+::chrono::time_point<"
1097 "std::__[[:alnum:]]+::chrono::local_t, "
1098 "std::__[[:alnum:]]+::chrono::duration<int, "
1099 "std::__[[:alnum:]]+::ratio<86400, 1> "
1101 eTypeOptionHideChildren | eTypeOptionHideValue |
1107 cpp_category_sp->AddTypeSummary(
1110 eTypeOptionHideValue,
1111 "day=${var.__d_%u}")));
1115 "libc++ std::chrono::month summary provider",
1116 "^std::__[[:alnum:]]+::chrono::month$",
1117 eTypeOptionHideChildren | eTypeOptionHideValue,
true);
1119 cpp_category_sp->AddTypeSummary(
1122 eTypeOptionHideChildren | eTypeOptionHideValue,
"year=${var.__y_}")));
1126 "libc++ std::chrono::weekday summary provider",
1127 "^std::__[[:alnum:]]+::chrono::weekday$",
1128 eTypeOptionHideChildren | eTypeOptionHideValue,
true);
1130 cpp_category_sp->AddTypeSummary(
1133 eTypeOptionHideChildren | eTypeOptionHideValue,
1134 "${var.__wd_} index=${var.__idx_%u}")));
1136 cpp_category_sp->AddTypeSummary(
1139 eTypeOptionHideValue,
1140 "${var.__wd_} index=last")));
1141 cpp_category_sp->AddTypeSummary(
1144 eTypeOptionHideValue,
1145 "${var.__m_} ${var.__d_}")));
1146 cpp_category_sp->AddTypeSummary(
1149 eTypeOptionHideValue,
1150 "${var.__m_} day=last")));
1152 cpp_category_sp->AddTypeSummary(
1155 eTypeOptionHideValue,
1156 "${var.__m_} ${var.__wdi_}")));
1158 cpp_category_sp->AddTypeSummary(
1161 eTypeOptionHideValue,
1162 "${var.__m_} ${var.__wdl_}")));
1164 cpp_category_sp->AddTypeSummary(
1167 eTypeOptionHideValue,
1168 "${var.__y_} ${var.__m_}")));
1173 "libc++ std::chrono::year_month_day summary provider",
1174 "^std::__[[:alnum:]]+::chrono::year_month_day$",
1175 eTypeOptionHideChildren | eTypeOptionHideValue,
true);
1177 cpp_category_sp->AddTypeSummary(
1178 "^std::__[[:alnum:]]+::chrono::year_month_day_last$",
1181 eTypeOptionHideValue,
1182 "${var.__y_} ${var.__mdl_}")));
1184 cpp_category_sp->AddTypeSummary(
1187 eTypeOptionHideChildren | eTypeOptionHideValue,
1188 "${var.__y_} ${var.__m_} ${var.__wdi_}")));
1190 cpp_category_sp->AddTypeSummary(
1191 "^std::__[[:alnum:]]+::chrono::year_month_weekday_last$",
1194 eTypeOptionHideChildren | eTypeOptionHideValue,
1195 "${var.__y_} ${var.__m_} ${var.__wdl_}")));
1199 if (!cpp_category_sp)
1216 "libstdc++ c++11 std::string summary provider"));
1219 "libstdc++ c++11 std::wstring summary provider"));
1222 std_string_summary_sp);
1223 cpp_category_sp->AddTypeSummary(
"std::basic_string<char>",
1225 cpp_category_sp->AddTypeSummary(
1226 "std::basic_string<char,std::char_traits<char>,std::allocator<char> >",
1228 cpp_category_sp->AddTypeSummary(
1229 "std::basic_string<char, std::char_traits<char>, std::allocator<char> >",
1233 cxx11_string_summary_sp);
1234 cpp_category_sp->AddTypeSummary(
1235 "std::__cxx11::basic_string<char, std::char_traits<char>, "
1236 "std::allocator<char> >",
1238 cpp_category_sp->AddTypeSummary(
"std::__cxx11::basic_string<unsigned char, "
1239 "std::char_traits<unsigned char>, "
1240 "std::allocator<unsigned char> >",
1242 cxx11_string_summary_sp);
1250 std_wstring_summary_sp);
1251 cpp_category_sp->AddTypeSummary(
"std::basic_string<wchar_t>",
1253 cpp_category_sp->AddTypeSummary(
"std::basic_string<wchar_t,std::char_traits<"
1254 "wchar_t>,std::allocator<wchar_t> >",
1256 cpp_category_sp->AddTypeSummary(
1257 "std::basic_string<wchar_t, std::char_traits<wchar_t>, "
1258 "std::allocator<wchar_t> >",
1262 cxx11_wstring_summary_sp);
1263 cpp_category_sp->AddTypeSummary(
1264 "std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, "
1265 "std::allocator<wchar_t> >",
1274 cpp_category_sp->AddTypeSynthetic(
1278 "lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider")));
1279 cpp_category_sp->AddTypeSynthetic(
1283 "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
1284 cpp_category_sp->AddTypeSynthetic(
1288 "lldb.formatters.cpp.gnu_libstdcpp.StdDequeSynthProvider")));
1289 cpp_category_sp->AddTypeSynthetic(
1293 "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
1294 cpp_category_sp->AddTypeSynthetic(
1298 "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
1299 cpp_category_sp->AddTypeSynthetic(
1303 "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
1304 cpp_category_sp->AddTypeSynthetic(
1308 "lldb.formatters.cpp.gnu_libstdcpp.StdUnorderedMapSynthProvider")));
1309 cpp_category_sp->AddTypeSynthetic(
1313 "lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider")));
1314 cpp_category_sp->AddTypeSynthetic(
1318 "lldb.formatters.cpp.gnu_libstdcpp.StdForwardListSynthProvider")));
1319 cpp_category_sp->AddTypeSynthetic(
1323 "lldb.formatters.cpp.gnu_libstdcpp.VariantSynthProvider")));
1327 cpp_category_sp->AddTypeSummary(
"^std::bitset<.+>(( )?&)?$",
1330 stl_summary_flags,
"size=${svar%#}")));
1331 cpp_category_sp->AddTypeSummary(
"^std::vector<.+>(( )?&)?$",
1334 stl_summary_flags,
"size=${svar%#}")));
1335 cpp_category_sp->AddTypeSummary(
"^std::map<.+> >(( )?&)?$",
1338 stl_summary_flags,
"size=${svar%#}")));
1339 cpp_category_sp->AddTypeSummary(
"^std::set<.+> >(( )?&)?$",
1342 stl_summary_flags,
"size=${svar%#}")));
1343 cpp_category_sp->AddTypeSummary(
"^std::deque<.+>(( )?&)?$",
1346 stl_summary_flags,
"size=${svar%#}")));
1347 cpp_category_sp->AddTypeSummary(
"^std::multimap<.+> >(( )?&)?$",
1350 stl_summary_flags,
"size=${svar%#}")));
1351 cpp_category_sp->AddTypeSummary(
"^std::multiset<.+> >(( )?&)?$",
1354 stl_summary_flags,
"size=${svar%#}")));
1355 cpp_category_sp->AddTypeSummary(
"^std::unordered_(multi)?(map|set)<.+> >$",
1358 stl_summary_flags,
"size=${svar%#}")));
1359 cpp_category_sp->AddTypeSummary(
"^std::(__cxx11::)?list<.+>(( )?&)?$",
1362 stl_summary_flags,
"size=${svar%#}")));
1363 cpp_category_sp->AddTypeSummary(
1367 "lldb.formatters.cpp.gnu_libstdcpp.ForwardListSummaryProvider")));
1368 cpp_category_sp->AddTypeSummary(
1372 "lldb.formatters.cpp.gnu_libstdcpp.VariantSummaryProvider")));
1377 "std::vector iterator synthetic children",
1378 "^__gnu_cxx::__normal_iterator<.+>$", stl_synth_flags,
true);
1383 "std::map iterator synthetic children",
"^std::_Rb_tree_iterator<.+>$",
1384 stl_synth_flags,
true);
1389 "std::unique_ptr synthetic children",
"^std::unique_ptr<.+>(( )?&)?$",
1390 stl_synth_flags,
true);
1394 "std::shared_ptr synthetic children",
"^std::shared_ptr<.+>(( )?&)?$",
1395 stl_synth_flags,
true);
1399 "std::weak_ptr synthetic children",
"^std::weak_ptr<.+>(( )?&)?$",
1400 stl_synth_flags,
true);
1404 "std::tuple synthetic children",
"^std::tuple<.+>(( )?&)?$",
1405 stl_synth_flags,
true);
1407 static constexpr const char *
const libstdcpp_std_coroutine_handle_regex =
1408 "^std::coroutine_handle<.+>(( )?&)?$";
1412 "std::coroutine_handle synthetic children",
1413 libstdcpp_std_coroutine_handle_regex, stl_deref_flags,
true);
1418 "std::bitset synthetic child",
"^std::bitset<.+>(( )?&)?$",
1419 stl_deref_flags,
true);
1424 "std::optional synthetic child",
"^std::optional<.+>(( )?&)?$",
1425 stl_deref_flags,
true);
1429 "libstdc++ std::unique_ptr summary provider",
1430 "^std::unique_ptr<.+>(( )?&)?$", stl_summary_flags,
true);
1433 "libstdc++ std::shared_ptr summary provider",
1434 "^std::shared_ptr<.+>(( )?&)?$", stl_summary_flags,
true);
1437 "libstdc++ std::weak_ptr summary provider",
1438 "^std::weak_ptr<.+>(( )?&)?$", stl_summary_flags,
true);
1441 "libstdc++ std::coroutine_handle summary provider",
1442 libstdcpp_std_coroutine_handle_regex, stl_summary_flags,
true);
1445 "libstd++ std::optional summary provider",
1446 "^std::optional<.+>(( )?&)?$", stl_summary_flags,
true);
1450 if (!cpp_category_sp)
1473 "char8_t * summary provider",
"char8_t *", string_flags);
1476 "char8_t [] summary provider",
"char8_t ?\\[[0-9]+\\]",
1477 string_array_flags,
true);
1481 "char16_t * summary provider",
"char16_t *", string_flags);
1484 "char16_t [] summary provider",
"char16_t ?\\[[0-9]+\\]",
1485 string_array_flags,
true);
1489 "char32_t * summary provider",
"char32_t *", string_flags);
1492 "char32_t [] summary provider",
"char32_t ?\\[[0-9]+\\]",
1493 string_array_flags,
true);
1497 "wchar_t * summary provider",
"wchar_t *", string_flags);
1500 "wchar_t * summary provider",
"wchar_t ?\\[[0-9]+\\]",
1501 string_array_flags,
true);
1505 "unichar * summary provider",
"unichar *", string_flags);
1517 "char8_t summary provider",
"char8_t", widechar_flags);
1520 "char16_t summary provider",
"char16_t", widechar_flags);
1523 "char32_t summary provider",
"char32_t", widechar_flags);
1525 "wchar_t summary provider",
"wchar_t", widechar_flags);
1529 "unichar summary provider",
"unichar", widechar_flags);
1546 return std::unique_ptr<TypeScavenger>(
new CPlusPlusTypeScavenger());
1550 static llvm::once_flag g_initialize;
1553 llvm::call_once(g_initialize, [
this]() ->
void {
1567 static llvm::once_flag g_initialize;
1571 llvm::call_once(g_initialize, []() ->
void {
1572 g_formatters.push_back(
1579 "Function pointer summary provider"));
1583 return formatter_sp;
1587 g_formatters.push_back(
1594 .SetDontShowChildren(
true)
1595 .SetHideItemNames(
true)
1596 .SetShowMembersOneLiner(
true)
1597 .SetSkipPointers(
true)
1598 .SetSkipReferences(
false),
1600 "vector_type pointer summary provider"));
1602 if (fmt_mgr.
GetCategory(g_vectortypes)->IsEnabled())
1603 return formatter_sp;
1607 g_formatters.push_back(
1614 .SetDontShowChildren(
true)
1615 .SetHideItemNames(
true)
1616 .SetShowMembersOneLiner(
true)
1617 .SetSkipPointers(
true)
1618 .SetSkipReferences(
false),
1620 "block pointer summary provider"));
1622 return formatter_sp;
1628 return g_formatters;
1633 static llvm::once_flag g_initialize;
1637 llvm::call_once(g_initialize, []() ->
void {
1645 .SetSkipPointers(
true)
1646 .SetSkipReferences(
true)
1647 .SetNonCacheable(
true),
1648 "vector_type synthetic children",
1651 if (fmt_mgr.
GetCategory(g_vectortypes)->IsEnabled())
1652 return formatter_sp;
1663 .SetSkipPointers(
true)
1664 .SetSkipReferences(
true)
1665 .SetNonCacheable(
true),
1666 "block pointer synthetic children",
1669 return formatter_sp;
1675 return g_formatters;
1682 bool canReadValue =
true;
1684 return canReadValue && isZero;
1688 const auto suffixes = {
".cpp",
".cxx",
".c++",
".cc",
".c",
1689 ".h",
".hh",
".hpp",
".hxx",
".h++"};
1690 for (
auto suffix : suffixes) {
1691 if (file_path.ends_with_insensitive(suffix))
1697 return file_path.contains(
"/usr/include/c++/");
1703 switch (representation) {
1713 bool get_function_vars =
true;
1718 get_function_vars =
false;
1725 if (get_function_vars) {
1737 if (variable_list_sp)
static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp)
static bool IsTrivialBasename(const llvm::StringRef &basename)
static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp)
static bool ReverseFindMatchingChars(const llvm::StringRef &s, const llvm::StringRef &left_right_chars, size_t &left_pos, size_t &right_pos, size_t pos=llvm::StringRef::npos)
static void LoadSystemFormatters(lldb::TypeCategoryImplSP cpp_category_sp)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_PLUGIN_DEFINE(PluginName)
static bool IsMSVCUndecoratedName(llvm::StringRef name)
static bool ExtractContextAndIdentifier(llvm::StringRef name, llvm::StringRef &context, llvm::StringRef &identifier)
A command line argument class.
A class that describes a single lexical block.
lldb::VariableListSP GetBlockVariableList(bool can_create)
Get the variable list for this block only.
Block * GetContainingInlinedBlock()
Get the inlined block that contains this block.
const InlineFunctionInfo * GetInlinedFunctionInfo() const
Get const accessor for any inlined function information.
llvm::StringRef m_arguments
llvm::StringRef m_return_type
llvm::StringRef m_basename
llvm::StringRef GetArguments()
std::string GetScopeQualifiedName()
llvm::StringRef GetContext()
llvm::StringRef m_context
llvm::StringRef m_qualifiers
llvm::StringRef GetQualifiers()
bool ContainsPath(llvm::StringRef path)
llvm::StringRef GetBasename()
bool TrySimplifiedParse()
llvm::StringRef GetReturnType()
Returns the methods return-type.
llvm::StringRef GetBasenameNoTemplateParameters()
Returns the Basename of this method without a template parameter list, if any.
bool GetFunctionDisplayName(const SymbolContext *sc, const ExecutionContext *exe_ctx, FunctionNameRepresentation representation, Stream &s) override
bool IsNilReference(ValueObject &valobj) override
bool IsSourceFile(llvm::StringRef file_path) const override
ConstString GetDemangledFunctionNameWithoutArguments(Mangled mangled) const override
lldb::TypeCategoryImplSP GetFormatters() override
bool SymbolNameFitsToLanguage(Mangled mangled) const override
Returns true iff the given symbol name is compatible with the mangling scheme of this language.
HardcodedFormatters::HardcodedSyntheticFinder GetHardcodedSynthetics() override
static bool IsCPPMangledName(llvm::StringRef name)
llvm::StringRef GetPluginName() override
std::vector< ConstString > GenerateAlternateFunctionManglings(const ConstString mangled) const override
bool DemangledNameContainsPath(llvm::StringRef path, ConstString demangled) const override
ConstString FindBestAlternateFunctionMangledName(const Mangled mangled, const SymbolContext &sym_ctx) const override
static bool ExtractContextAndIdentifier(const char *name, llvm::StringRef &context, llvm::StringRef &identifier)
std::unique_ptr< TypeScavenger > GetTypeScavenger() override
HardcodedFormatters::HardcodedSummaryFinder GetHardcodedSummaries() override
static lldb_private::Language * CreateInstance(lldb::LanguageType language)
CPlusPlusLanguage()=default
std::optional< ParsedFunction > ParseAsFunctionDefinition()
std::optional< ParsedName > ParseAsFullName()
Generic representation of a type in a programming language.
lldb::LanguageType GetMinimumLanguage()
bool IsBlockPointerType(CompilerType *function_pointer_type_ptr=nullptr) const
CompilerType GetTypedefedType() const
If the current object represents a typedef type, get the underlying type.
bool IsFunctionPointerType() const
bool IsTypedefType() const
bool IsVectorType(CompilerType *element_type=nullptr, uint64_t *size=nullptr) const
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.
void Clear()
Clear this object's state.
const char * GetCString() const
Get the string value as a C string.
static bool GetCategory(ConstString category, lldb::TypeCategoryImplSP &entry, bool allow_create=true)
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
ExecutionContextScope * GetBestExecutionContextScope() const
ConstString GetName() const
Block & GetBlock(bool can_create)
Get accessor for the block list.
A class that describes information for an inlined function.
ConstString GetName() const
FunctionNameRepresentation
static bool LanguageIsC(lldb::LanguageType language)
static bool LanguageIsCPlusPlus(lldb::LanguageType language)
A class that handles mangled names.
static Mangled::ManglingScheme GetManglingScheme(llvm::StringRef const name)
Try to identify the mangling scheme used.
ConstString GetDemangledName() const
Demangled name get accessor.
ConstString & GetMangledName()
Mangled name get accessor.
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
A stream class that can stream formatted output to a file.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Defines a symbol context baton that can be handed other debug core functions.
Function * function
The Function for a given query.
Block * block
The Block for a given query.
lldb::ModuleSP module_sp
The Module for a given query.
Symbol * symbol
The Symbol for a given query.
Provides public interface for all SymbolFiles.
virtual void GetMangledNamesForFunction(const std::string &scope_qualified_name, std::vector< ConstString > &mangled_names)
ConstString GetName() const
Flags & SetSkipReferences(bool value=true)
Flags & SetFrontEndWantsDereference(bool value=true)
Flags & SetSkipPointers(bool value=true)
Flags & SetCascades(bool value=true)
std::shared_ptr< SyntheticChildren > SharedPointer
Flags & SetCascades(bool value=true)
Flags & SetSkipPointers(bool value=true)
Flags & SetHideItemNames(bool value=true)
Flags & SetDontShowChildren(bool value=true)
Flags & SetSkipReferences(bool value=true)
Flags & SetShowMembersOneLiner(bool value=true)
Flags & SetDontShowValue(bool value=true)
std::shared_ptr< TypeSummaryImpl > SharedPointer
CompilerType GetCompilerType()
virtual uint64_t GetValueAsUnsigned(uint64_t fail_value, bool *success=nullptr)
virtual lldb::ValueType GetValueType() const =0
lldb::LanguageType GetObjectRuntimeLanguage()
size_t AppendVariablesWithScope(lldb::ValueType type, VariableList &var_list, bool if_unique=true)
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.
std::shared_ptr< lldb_private::TypeSummaryImpl > TypeSummaryImplSP
LanguageType
Programming language type.
@ eLanguageTypeObjC_plus_plus
Objective-C++.
std::shared_ptr< lldb_private::VariableList > VariableListSP
std::shared_ptr< lldb_private::SyntheticChildren > SyntheticChildrenSP
std::shared_ptr< lldb_private::TypeCategoryImpl > TypeCategoryImplSP
@ eValueTypeVTableEntry
function pointer in virtual function table
@ eValueTypeVariableArgument
function argument variables