1 //===-- LibCxx.h ---------------------------------------------------*- C++ 2 //-*-===// 3 // 4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5 // See https://llvm.org/LICENSE.txt for license information. 6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXX_H 11 #define LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXX_H 12 13 #include "lldb/DataFormatters/TypeSummary.h" 14 #include "lldb/DataFormatters/TypeSynthetic.h" 15 #include "lldb/Utility/Stream.h" 16 #include "lldb/ValueObject/ValueObject.h" 17 18 namespace lldb_private { 19 namespace formatters { 20 21 /// Find a child member of \c obj_sp, trying all alternative names in order. 22 lldb::ValueObjectSP 23 GetChildMemberWithName(ValueObject &obj, 24 llvm::ArrayRef<ConstString> alternative_names); 25 26 lldb::ValueObjectSP GetFirstValueOfLibCXXCompressedPair(ValueObject &pair); 27 lldb::ValueObjectSP GetSecondValueOfLibCXXCompressedPair(ValueObject &pair); 28 bool isOldCompressedPairLayout(ValueObject &pair_obj); 29 bool isStdTemplate(ConstString type_name, llvm::StringRef type); 30 31 bool LibcxxStringSummaryProviderASCII( 32 ValueObject &valobj, Stream &stream, 33 const TypeSummaryOptions &summary_options); // libc++ std::string 34 35 bool LibcxxStringSummaryProviderUTF16( 36 ValueObject &valobj, Stream &stream, 37 const TypeSummaryOptions &summary_options); // libc++ std::u16string 38 39 bool LibcxxStringSummaryProviderUTF32( 40 ValueObject &valobj, Stream &stream, 41 const TypeSummaryOptions &summary_options); // libc++ std::u32string 42 43 bool LibcxxWStringSummaryProvider( 44 ValueObject &valobj, Stream &stream, 45 const TypeSummaryOptions &options); // libc++ std::wstring 46 47 bool LibcxxStringViewSummaryProviderASCII( 48 ValueObject &valueObj, Stream &stream, 49 const TypeSummaryOptions &summary_options); // libc++ std::string_view 50 51 bool LibcxxStringViewSummaryProviderUTF16( 52 ValueObject &valobj, Stream &stream, 53 const TypeSummaryOptions &summary_options); // libc++ std::u16string_view 54 55 bool LibcxxStringViewSummaryProviderUTF32( 56 ValueObject &valobj, Stream &stream, 57 const TypeSummaryOptions &summary_options); // libc++ std::u32string_view 58 59 bool LibcxxWStringViewSummaryProvider( 60 ValueObject &valobj, Stream &stream, 61 const TypeSummaryOptions &options); // libc++ std::wstring_view 62 63 bool LibcxxStdSliceArraySummaryProvider( 64 ValueObject &valobj, Stream &stream, 65 const TypeSummaryOptions &options); // libc++ std::slice_array 66 67 bool LibcxxSmartPointerSummaryProvider( 68 ValueObject &valobj, Stream &stream, 69 const TypeSummaryOptions 70 &options); // libc++ std::shared_ptr<> and std::weak_ptr<> 71 72 // libc++ std::unique_ptr<> 73 bool LibcxxUniquePointerSummaryProvider(ValueObject &valobj, Stream &stream, 74 const TypeSummaryOptions &options); 75 76 bool LibcxxFunctionSummaryProvider( 77 ValueObject &valobj, Stream &stream, 78 const TypeSummaryOptions &options); // libc++ std::function<> 79 80 SyntheticChildrenFrontEnd * 81 LibcxxVectorBoolSyntheticFrontEndCreator(CXXSyntheticChildren *, 82 lldb::ValueObjectSP); 83 84 bool LibcxxContainerSummaryProvider(ValueObject &valobj, Stream &stream, 85 const TypeSummaryOptions &options); 86 87 /// Formatter for libc++ std::span<>. 88 bool LibcxxSpanSummaryProvider(ValueObject &valobj, Stream &stream, 89 const TypeSummaryOptions &options); 90 91 SyntheticChildrenFrontEnd * 92 LibCxxVectorIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *, 93 lldb::ValueObjectSP); 94 95 class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd { 96 public: 97 LibcxxSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); 98 99 llvm::Expected<uint32_t> CalculateNumChildren() override; 100 101 lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; 102 103 lldb::ChildCacheState Update() override; 104 105 bool MightHaveChildren() override; 106 107 size_t GetIndexOfChildWithName(ConstString name) override; 108 109 ~LibcxxSharedPtrSyntheticFrontEnd() override; 110 111 private: 112 ValueObject *m_cntrl; 113 }; 114 115 class LibcxxUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd { 116 public: 117 LibcxxUniquePtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); 118 119 llvm::Expected<uint32_t> CalculateNumChildren() override; 120 121 lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; 122 123 lldb::ChildCacheState Update() override; 124 125 bool MightHaveChildren() override; 126 127 size_t GetIndexOfChildWithName(ConstString name) override; 128 129 ~LibcxxUniquePtrSyntheticFrontEnd() override; 130 131 private: 132 lldb::ValueObjectSP m_value_ptr_sp; 133 lldb::ValueObjectSP m_deleter_sp; 134 }; 135 136 SyntheticChildrenFrontEnd * 137 LibcxxBitsetSyntheticFrontEndCreator(CXXSyntheticChildren *, 138 lldb::ValueObjectSP); 139 140 SyntheticChildrenFrontEnd * 141 LibcxxSharedPtrSyntheticFrontEndCreator(CXXSyntheticChildren *, 142 lldb::ValueObjectSP); 143 144 SyntheticChildrenFrontEnd * 145 LibcxxUniquePtrSyntheticFrontEndCreator(CXXSyntheticChildren *, 146 lldb::ValueObjectSP); 147 148 SyntheticChildrenFrontEnd * 149 LibcxxStdVectorSyntheticFrontEndCreator(CXXSyntheticChildren *, 150 lldb::ValueObjectSP); 151 152 SyntheticChildrenFrontEnd * 153 LibcxxStdValarraySyntheticFrontEndCreator(CXXSyntheticChildren *, 154 lldb::ValueObjectSP); 155 156 SyntheticChildrenFrontEnd * 157 LibcxxStdSliceArraySyntheticFrontEndCreator(CXXSyntheticChildren *, 158 lldb::ValueObjectSP); 159 160 SyntheticChildrenFrontEnd * 161 LibcxxStdProxyArraySyntheticFrontEndCreator(CXXSyntheticChildren *, 162 lldb::ValueObjectSP); 163 164 SyntheticChildrenFrontEnd * 165 LibcxxStdListSyntheticFrontEndCreator(CXXSyntheticChildren *, 166 lldb::ValueObjectSP); 167 168 SyntheticChildrenFrontEnd * 169 LibcxxStdForwardListSyntheticFrontEndCreator(CXXSyntheticChildren *, 170 lldb::ValueObjectSP); 171 172 SyntheticChildrenFrontEnd * 173 LibcxxStdMapSyntheticFrontEndCreator(CXXSyntheticChildren *, 174 lldb::ValueObjectSP); 175 176 SyntheticChildrenFrontEnd * 177 LibCxxMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *, 178 lldb::ValueObjectSP); 179 180 SyntheticChildrenFrontEnd * 181 LibcxxStdUnorderedMapSyntheticFrontEndCreator(CXXSyntheticChildren *, 182 lldb::ValueObjectSP); 183 184 SyntheticChildrenFrontEnd * 185 LibCxxUnorderedMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *, 186 lldb::ValueObjectSP); 187 188 SyntheticChildrenFrontEnd * 189 LibcxxInitializerListSyntheticFrontEndCreator(CXXSyntheticChildren *, 190 lldb::ValueObjectSP); 191 192 SyntheticChildrenFrontEnd *LibcxxQueueFrontEndCreator(CXXSyntheticChildren *, 193 lldb::ValueObjectSP); 194 195 SyntheticChildrenFrontEnd *LibcxxTupleFrontEndCreator(CXXSyntheticChildren *, 196 lldb::ValueObjectSP); 197 198 SyntheticChildrenFrontEnd * 199 LibcxxOptionalSyntheticFrontEndCreator(CXXSyntheticChildren *, 200 lldb::ValueObjectSP valobj_sp); 201 202 SyntheticChildrenFrontEnd * 203 LibcxxVariantFrontEndCreator(CXXSyntheticChildren *, 204 lldb::ValueObjectSP valobj_sp); 205 206 SyntheticChildrenFrontEnd * 207 LibcxxStdSpanSyntheticFrontEndCreator(CXXSyntheticChildren *, 208 lldb::ValueObjectSP); 209 210 SyntheticChildrenFrontEnd * 211 LibcxxStdRangesRefViewSyntheticFrontEndCreator(CXXSyntheticChildren *, 212 lldb::ValueObjectSP); 213 214 bool LibcxxChronoSysSecondsSummaryProvider( 215 ValueObject &valobj, Stream &stream, 216 const TypeSummaryOptions &options); // libc++ std::chrono::sys_seconds 217 218 bool LibcxxChronoSysDaysSummaryProvider( 219 ValueObject &valobj, Stream &stream, 220 const TypeSummaryOptions &options); // libc++ std::chrono::sys_days 221 222 bool LibcxxChronoLocalSecondsSummaryProvider( 223 ValueObject &valobj, Stream &stream, 224 const TypeSummaryOptions &options); // libc++ std::chrono::local_seconds 225 226 bool LibcxxChronoLocalDaysSummaryProvider( 227 ValueObject &valobj, Stream &stream, 228 const TypeSummaryOptions &options); // libc++ std::chrono::local_days 229 230 bool LibcxxChronoMonthSummaryProvider( 231 ValueObject &valobj, Stream &stream, 232 const TypeSummaryOptions &options); // libc++ std::chrono::month 233 234 bool LibcxxChronoWeekdaySummaryProvider( 235 ValueObject &valobj, Stream &stream, 236 const TypeSummaryOptions &options); // libc++ std::chrono::weekday 237 238 bool LibcxxChronoYearMonthDaySummaryProvider( 239 ValueObject &valobj, Stream &stream, 240 const TypeSummaryOptions &options); // libc++ std::chrono::year_month_day 241 242 } // namespace formatters 243 } // namespace lldb_private 244 245 #endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXX_H 246