| 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 | |
| 29 | /// Returns the ValueObjectSP of the child of \c obj. If \c obj has no |
| 30 | /// child named \c child_name, returns the __compressed_pair child instead |
| 31 | /// with \c compressed_pair_name, if one exists. |
| 32 | /// |
| 33 | /// Latest libc++ wrap the compressed children in an anonymous structure. |
| 34 | /// The \c anon_struct_idx indicates the location of this struct. |
| 35 | /// |
| 36 | /// The returned boolean is \c true if the returned child was has an old-style |
| 37 | /// libc++ __compressed_pair layout. |
| 38 | /// |
| 39 | /// If no child was found returns a nullptr. |
| 40 | std::pair<lldb::ValueObjectSP, bool> |
| 41 | GetValueOrOldCompressedPair(ValueObject &obj, size_t anon_struct_idx, |
| 42 | llvm::StringRef child_name, |
| 43 | llvm::StringRef compressed_pair_name); |
| 44 | bool isStdTemplate(ConstString type_name, llvm::StringRef type); |
| 45 | |
| 46 | bool LibcxxStringSummaryProviderASCII( |
| 47 | ValueObject &valobj, Stream &stream, |
| 48 | const TypeSummaryOptions &summary_options); // libc++ std::string |
| 49 | |
| 50 | bool LibcxxStringSummaryProviderUTF16( |
| 51 | ValueObject &valobj, Stream &stream, |
| 52 | const TypeSummaryOptions &summary_options); // libc++ std::u16string |
| 53 | |
| 54 | bool LibcxxStringSummaryProviderUTF32( |
| 55 | ValueObject &valobj, Stream &stream, |
| 56 | const TypeSummaryOptions &summary_options); // libc++ std::u32string |
| 57 | |
| 58 | bool LibcxxWStringSummaryProvider( |
| 59 | ValueObject &valobj, Stream &stream, |
| 60 | const TypeSummaryOptions &options); // libc++ std::wstring |
| 61 | |
| 62 | bool LibcxxStringViewSummaryProviderASCII( |
| 63 | ValueObject &valueObj, Stream &stream, |
| 64 | const TypeSummaryOptions &summary_options); // libc++ std::string_view |
| 65 | |
| 66 | bool LibcxxStringViewSummaryProviderUTF16( |
| 67 | ValueObject &valobj, Stream &stream, |
| 68 | const TypeSummaryOptions &summary_options); // libc++ std::u16string_view |
| 69 | |
| 70 | bool LibcxxStringViewSummaryProviderUTF32( |
| 71 | ValueObject &valobj, Stream &stream, |
| 72 | const TypeSummaryOptions &summary_options); // libc++ std::u32string_view |
| 73 | |
| 74 | bool LibcxxWStringViewSummaryProvider( |
| 75 | ValueObject &valobj, Stream &stream, |
| 76 | const TypeSummaryOptions &options); // libc++ std::wstring_view |
| 77 | |
| 78 | bool LibcxxStdSliceArraySummaryProvider( |
| 79 | ValueObject &valobj, Stream &stream, |
| 80 | const TypeSummaryOptions &options); // libc++ std::slice_array |
| 81 | |
| 82 | bool LibcxxSmartPointerSummaryProvider( |
| 83 | ValueObject &valobj, Stream &stream, |
| 84 | const TypeSummaryOptions |
| 85 | &options); // libc++ std::shared_ptr<> and std::weak_ptr<> |
| 86 | |
| 87 | // libc++ std::unique_ptr<> |
| 88 | bool LibcxxUniquePointerSummaryProvider(ValueObject &valobj, Stream &stream, |
| 89 | const TypeSummaryOptions &options); |
| 90 | |
| 91 | bool LibcxxFunctionSummaryProvider( |
| 92 | ValueObject &valobj, Stream &stream, |
| 93 | const TypeSummaryOptions &options); // libc++ std::function<> |
| 94 | |
| 95 | SyntheticChildrenFrontEnd * |
| 96 | LibcxxVectorBoolSyntheticFrontEndCreator(CXXSyntheticChildren *, |
| 97 | lldb::ValueObjectSP); |
| 98 | |
| 99 | /// Formatter for libc++ std::span<>. |
| 100 | bool LibcxxSpanSummaryProvider(ValueObject &valobj, Stream &stream, |
| 101 | const TypeSummaryOptions &options); |
| 102 | |
| 103 | SyntheticChildrenFrontEnd * |
| 104 | LibCxxVectorIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *, |
| 105 | lldb::ValueObjectSP); |
| 106 | |
| 107 | class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd { |
| 108 | public: |
| 109 | LibcxxSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); |
| 110 | |
| 111 | llvm::Expected<uint32_t> CalculateNumChildren() override; |
| 112 | |
| 113 | lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; |
| 114 | |
| 115 | lldb::ChildCacheState Update() override; |
| 116 | |
| 117 | llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override; |
| 118 | |
| 119 | ~LibcxxSharedPtrSyntheticFrontEnd() override; |
| 120 | |
| 121 | private: |
| 122 | ValueObject *m_cntrl; |
| 123 | ValueObject *m_ptr_obj; |
| 124 | }; |
| 125 | |
| 126 | class LibcxxUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd { |
| 127 | public: |
| 128 | LibcxxUniquePtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); |
| 129 | |
| 130 | llvm::Expected<uint32_t> CalculateNumChildren() override; |
| 131 | |
| 132 | lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; |
| 133 | |
| 134 | lldb::ChildCacheState Update() override; |
| 135 | |
| 136 | llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override; |
| 137 | |
| 138 | ~LibcxxUniquePtrSyntheticFrontEnd() override; |
| 139 | |
| 140 | private: |
| 141 | lldb::ValueObjectSP m_value_ptr_sp; |
| 142 | lldb::ValueObjectSP m_deleter_sp; |
| 143 | }; |
| 144 | |
| 145 | SyntheticChildrenFrontEnd * |
| 146 | LibcxxBitsetSyntheticFrontEndCreator(CXXSyntheticChildren *, |
| 147 | lldb::ValueObjectSP); |
| 148 | |
| 149 | SyntheticChildrenFrontEnd * |
| 150 | LibcxxSharedPtrSyntheticFrontEndCreator(CXXSyntheticChildren *, |
| 151 | lldb::ValueObjectSP); |
| 152 | |
| 153 | SyntheticChildrenFrontEnd * |
| 154 | LibcxxUniquePtrSyntheticFrontEndCreator(CXXSyntheticChildren *, |
| 155 | lldb::ValueObjectSP); |
| 156 | |
| 157 | SyntheticChildrenFrontEnd * |
| 158 | LibcxxStdVectorSyntheticFrontEndCreator(CXXSyntheticChildren *, |
| 159 | lldb::ValueObjectSP); |
| 160 | |
| 161 | SyntheticChildrenFrontEnd * |
| 162 | LibcxxStdValarraySyntheticFrontEndCreator(CXXSyntheticChildren *, |
| 163 | lldb::ValueObjectSP); |
| 164 | |
| 165 | SyntheticChildrenFrontEnd * |
| 166 | LibcxxStdSliceArraySyntheticFrontEndCreator(CXXSyntheticChildren *, |
| 167 | lldb::ValueObjectSP); |
| 168 | |
| 169 | SyntheticChildrenFrontEnd * |
| 170 | LibcxxStdProxyArraySyntheticFrontEndCreator(CXXSyntheticChildren *, |
| 171 | lldb::ValueObjectSP); |
| 172 | |
| 173 | SyntheticChildrenFrontEnd * |
| 174 | LibcxxStdListSyntheticFrontEndCreator(CXXSyntheticChildren *, |
| 175 | lldb::ValueObjectSP); |
| 176 | |
| 177 | SyntheticChildrenFrontEnd * |
| 178 | LibcxxStdForwardListSyntheticFrontEndCreator(CXXSyntheticChildren *, |
| 179 | lldb::ValueObjectSP); |
| 180 | |
| 181 | SyntheticChildrenFrontEnd * |
| 182 | LibcxxStdMapSyntheticFrontEndCreator(CXXSyntheticChildren *, |
| 183 | lldb::ValueObjectSP); |
| 184 | |
| 185 | SyntheticChildrenFrontEnd * |
| 186 | LibCxxMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *, |
| 187 | lldb::ValueObjectSP); |
| 188 | |
| 189 | SyntheticChildrenFrontEnd * |
| 190 | LibcxxStdUnorderedMapSyntheticFrontEndCreator(CXXSyntheticChildren *, |
| 191 | lldb::ValueObjectSP); |
| 192 | |
| 193 | SyntheticChildrenFrontEnd * |
| 194 | LibCxxUnorderedMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *, |
| 195 | lldb::ValueObjectSP); |
| 196 | |
| 197 | SyntheticChildrenFrontEnd * |
| 198 | LibcxxInitializerListSyntheticFrontEndCreator(CXXSyntheticChildren *, |
| 199 | lldb::ValueObjectSP); |
| 200 | |
| 201 | SyntheticChildrenFrontEnd *LibcxxQueueFrontEndCreator(CXXSyntheticChildren *, |
| 202 | lldb::ValueObjectSP); |
| 203 | |
| 204 | SyntheticChildrenFrontEnd *LibcxxTupleFrontEndCreator(CXXSyntheticChildren *, |
| 205 | lldb::ValueObjectSP); |
| 206 | |
| 207 | SyntheticChildrenFrontEnd * |
| 208 | LibcxxOptionalSyntheticFrontEndCreator(CXXSyntheticChildren *, |
| 209 | lldb::ValueObjectSP valobj_sp); |
| 210 | |
| 211 | SyntheticChildrenFrontEnd * |
| 212 | LibcxxVariantFrontEndCreator(CXXSyntheticChildren *, |
| 213 | lldb::ValueObjectSP valobj_sp); |
| 214 | |
| 215 | SyntheticChildrenFrontEnd * |
| 216 | LibcxxStdSpanSyntheticFrontEndCreator(CXXSyntheticChildren *, |
| 217 | lldb::ValueObjectSP); |
| 218 | |
| 219 | SyntheticChildrenFrontEnd * |
| 220 | LibcxxStdRangesRefViewSyntheticFrontEndCreator(CXXSyntheticChildren *, |
| 221 | lldb::ValueObjectSP); |
| 222 | |
| 223 | bool LibcxxChronoSysSecondsSummaryProvider( |
| 224 | ValueObject &valobj, Stream &stream, |
| 225 | const TypeSummaryOptions &options); // libc++ std::chrono::sys_seconds |
| 226 | |
| 227 | bool LibcxxChronoSysDaysSummaryProvider( |
| 228 | ValueObject &valobj, Stream &stream, |
| 229 | const TypeSummaryOptions &options); // libc++ std::chrono::sys_days |
| 230 | |
| 231 | bool LibcxxChronoLocalSecondsSummaryProvider( |
| 232 | ValueObject &valobj, Stream &stream, |
| 233 | const TypeSummaryOptions &options); // libc++ std::chrono::local_seconds |
| 234 | |
| 235 | bool LibcxxChronoLocalDaysSummaryProvider( |
| 236 | ValueObject &valobj, Stream &stream, |
| 237 | const TypeSummaryOptions &options); // libc++ std::chrono::local_days |
| 238 | |
| 239 | bool LibcxxChronoMonthSummaryProvider( |
| 240 | ValueObject &valobj, Stream &stream, |
| 241 | const TypeSummaryOptions &options); // libc++ std::chrono::month |
| 242 | |
| 243 | bool LibcxxChronoWeekdaySummaryProvider( |
| 244 | ValueObject &valobj, Stream &stream, |
| 245 | const TypeSummaryOptions &options); // libc++ std::chrono::weekday |
| 246 | |
| 247 | bool LibcxxChronoYearMonthDaySummaryProvider( |
| 248 | ValueObject &valobj, Stream &stream, |
| 249 | const TypeSummaryOptions &options); // libc++ std::chrono::year_month_day |
| 250 | |
| 251 | } // namespace formatters |
| 252 | } // namespace lldb_private |
| 253 | |
| 254 | #endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXX_H |
| 255 | |