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/Core/ValueObject.h" |
14 | #include "lldb/DataFormatters/TypeSummary.h" |
15 | #include "lldb/DataFormatters/TypeSynthetic.h" |
16 | #include "lldb/Utility/Stream.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 | |
30 | bool LibcxxStringSummaryProviderASCII( |
31 | ValueObject &valobj, Stream &stream, |
32 | const TypeSummaryOptions &summary_options); // libc++ std::string |
33 | |
34 | bool LibcxxStringSummaryProviderUTF16( |
35 | ValueObject &valobj, Stream &stream, |
36 | const TypeSummaryOptions &summary_options); // libc++ std::u16string |
37 | |
38 | bool LibcxxStringSummaryProviderUTF32( |
39 | ValueObject &valobj, Stream &stream, |
40 | const TypeSummaryOptions &summary_options); // libc++ std::u32string |
41 | |
42 | bool LibcxxWStringSummaryProvider( |
43 | ValueObject &valobj, Stream &stream, |
44 | const TypeSummaryOptions &options); // libc++ std::wstring |
45 | |
46 | bool LibcxxStringViewSummaryProviderASCII( |
47 | ValueObject &valueObj, Stream &stream, |
48 | const TypeSummaryOptions &summary_options); // libc++ std::string_view |
49 | |
50 | bool LibcxxStringViewSummaryProviderUTF16( |
51 | ValueObject &valobj, Stream &stream, |
52 | const TypeSummaryOptions &summary_options); // libc++ std::u16string_view |
53 | |
54 | bool LibcxxStringViewSummaryProviderUTF32( |
55 | ValueObject &valobj, Stream &stream, |
56 | const TypeSummaryOptions &summary_options); // libc++ std::u32string_view |
57 | |
58 | bool LibcxxWStringViewSummaryProvider( |
59 | ValueObject &valobj, Stream &stream, |
60 | const TypeSummaryOptions &options); // libc++ std::wstring_view |
61 | |
62 | bool LibcxxStdSliceArraySummaryProvider( |
63 | ValueObject &valobj, Stream &stream, |
64 | const TypeSummaryOptions &options); // libc++ std::slice_array |
65 | |
66 | bool LibcxxSmartPointerSummaryProvider( |
67 | ValueObject &valobj, Stream &stream, |
68 | const TypeSummaryOptions |
69 | &options); // libc++ std::shared_ptr<> and std::weak_ptr<> |
70 | |
71 | // libc++ std::unique_ptr<> |
72 | bool LibcxxUniquePointerSummaryProvider(ValueObject &valobj, Stream &stream, |
73 | const TypeSummaryOptions &options); |
74 | |
75 | bool LibcxxFunctionSummaryProvider( |
76 | ValueObject &valobj, Stream &stream, |
77 | const TypeSummaryOptions &options); // libc++ std::function<> |
78 | |
79 | SyntheticChildrenFrontEnd * |
80 | LibcxxVectorBoolSyntheticFrontEndCreator(CXXSyntheticChildren *, |
81 | lldb::ValueObjectSP); |
82 | |
83 | bool LibcxxContainerSummaryProvider(ValueObject &valobj, Stream &stream, |
84 | const TypeSummaryOptions &options); |
85 | |
86 | /// Formatter for libc++ std::span<>. |
87 | bool LibcxxSpanSummaryProvider(ValueObject &valobj, Stream &stream, |
88 | const TypeSummaryOptions &options); |
89 | |
90 | class LibCxxMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd { |
91 | public: |
92 | LibCxxMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); |
93 | |
94 | llvm::Expected<uint32_t> CalculateNumChildren() override; |
95 | |
96 | lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; |
97 | |
98 | lldb::ChildCacheState Update() override; |
99 | |
100 | bool MightHaveChildren() override; |
101 | |
102 | size_t GetIndexOfChildWithName(ConstString name) override; |
103 | |
104 | ~LibCxxMapIteratorSyntheticFrontEnd() override; |
105 | |
106 | private: |
107 | ValueObject *m_pair_ptr; |
108 | lldb::ValueObjectSP m_pair_sp; |
109 | }; |
110 | |
111 | SyntheticChildrenFrontEnd * |
112 | LibCxxMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *, |
113 | lldb::ValueObjectSP); |
114 | |
115 | /// Formats libcxx's std::unordered_map iterators |
116 | /// |
117 | /// In raw form a std::unordered_map::iterator is represented as follows: |
118 | /// |
119 | /// (lldb) var it --raw --ptr-depth 1 |
120 | /// (std::__1::__hash_map_iterator< |
121 | /// std::__1::__hash_iterator< |
122 | /// std::__1::__hash_node< |
123 | /// std::__1::__hash_value_type< |
124 | /// std::__1::basic_string<char, std::__1::char_traits<char>, |
125 | /// std::__1::allocator<char> >, std::__1::basic_string<char, |
126 | /// std::__1::char_traits<char>, std::__1::allocator<char> > >, |
127 | /// void *> *> >) |
128 | /// it = { |
129 | /// __i_ = { |
130 | /// __node_ = 0x0000600001700040 { |
131 | /// __next_ = 0x0000600001704000 |
132 | /// } |
133 | /// } |
134 | /// } |
135 | class LibCxxUnorderedMapIteratorSyntheticFrontEnd |
136 | : public SyntheticChildrenFrontEnd { |
137 | public: |
138 | LibCxxUnorderedMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); |
139 | |
140 | ~LibCxxUnorderedMapIteratorSyntheticFrontEnd() override = default; |
141 | |
142 | llvm::Expected<uint32_t> CalculateNumChildren() override; |
143 | |
144 | lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; |
145 | |
146 | lldb::ChildCacheState Update() override; |
147 | |
148 | bool MightHaveChildren() override; |
149 | |
150 | size_t GetIndexOfChildWithName(ConstString name) override; |
151 | |
152 | private: |
153 | ValueObject *m_iter_ptr = nullptr; ///< Held, not owned. Child of iterator |
154 | ///< ValueObject supplied at construction. |
155 | |
156 | lldb::ValueObjectSP m_pair_sp; ///< ValueObject for the key/value pair |
157 | ///< that the iterator currently points |
158 | ///< to. |
159 | }; |
160 | |
161 | SyntheticChildrenFrontEnd * |
162 | LibCxxUnorderedMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *, |
163 | lldb::ValueObjectSP); |
164 | |
165 | SyntheticChildrenFrontEnd * |
166 | LibCxxVectorIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *, |
167 | lldb::ValueObjectSP); |
168 | |
169 | class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd { |
170 | public: |
171 | LibcxxSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); |
172 | |
173 | llvm::Expected<uint32_t> CalculateNumChildren() override; |
174 | |
175 | lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; |
176 | |
177 | lldb::ChildCacheState Update() override; |
178 | |
179 | bool MightHaveChildren() override; |
180 | |
181 | size_t GetIndexOfChildWithName(ConstString name) override; |
182 | |
183 | ~LibcxxSharedPtrSyntheticFrontEnd() override; |
184 | |
185 | private: |
186 | ValueObject *m_cntrl; |
187 | }; |
188 | |
189 | class LibcxxUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd { |
190 | public: |
191 | LibcxxUniquePtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); |
192 | |
193 | llvm::Expected<uint32_t> CalculateNumChildren() override; |
194 | |
195 | lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; |
196 | |
197 | lldb::ChildCacheState Update() override; |
198 | |
199 | bool MightHaveChildren() override; |
200 | |
201 | size_t GetIndexOfChildWithName(ConstString name) override; |
202 | |
203 | ~LibcxxUniquePtrSyntheticFrontEnd() override; |
204 | |
205 | private: |
206 | lldb::ValueObjectSP m_value_ptr_sp; |
207 | lldb::ValueObjectSP m_deleter_sp; |
208 | }; |
209 | |
210 | SyntheticChildrenFrontEnd * |
211 | LibcxxBitsetSyntheticFrontEndCreator(CXXSyntheticChildren *, |
212 | lldb::ValueObjectSP); |
213 | |
214 | SyntheticChildrenFrontEnd * |
215 | LibcxxSharedPtrSyntheticFrontEndCreator(CXXSyntheticChildren *, |
216 | lldb::ValueObjectSP); |
217 | |
218 | SyntheticChildrenFrontEnd * |
219 | LibcxxUniquePtrSyntheticFrontEndCreator(CXXSyntheticChildren *, |
220 | lldb::ValueObjectSP); |
221 | |
222 | SyntheticChildrenFrontEnd * |
223 | LibcxxStdVectorSyntheticFrontEndCreator(CXXSyntheticChildren *, |
224 | lldb::ValueObjectSP); |
225 | |
226 | SyntheticChildrenFrontEnd * |
227 | LibcxxStdValarraySyntheticFrontEndCreator(CXXSyntheticChildren *, |
228 | lldb::ValueObjectSP); |
229 | |
230 | SyntheticChildrenFrontEnd * |
231 | LibcxxStdSliceArraySyntheticFrontEndCreator(CXXSyntheticChildren *, |
232 | lldb::ValueObjectSP); |
233 | |
234 | SyntheticChildrenFrontEnd * |
235 | LibcxxStdProxyArraySyntheticFrontEndCreator(CXXSyntheticChildren *, |
236 | lldb::ValueObjectSP); |
237 | |
238 | SyntheticChildrenFrontEnd * |
239 | LibcxxStdListSyntheticFrontEndCreator(CXXSyntheticChildren *, |
240 | lldb::ValueObjectSP); |
241 | |
242 | SyntheticChildrenFrontEnd * |
243 | LibcxxStdForwardListSyntheticFrontEndCreator(CXXSyntheticChildren *, |
244 | lldb::ValueObjectSP); |
245 | |
246 | SyntheticChildrenFrontEnd * |
247 | LibcxxStdMapSyntheticFrontEndCreator(CXXSyntheticChildren *, |
248 | lldb::ValueObjectSP); |
249 | |
250 | SyntheticChildrenFrontEnd * |
251 | LibcxxStdUnorderedMapSyntheticFrontEndCreator(CXXSyntheticChildren *, |
252 | lldb::ValueObjectSP); |
253 | |
254 | SyntheticChildrenFrontEnd * |
255 | LibcxxInitializerListSyntheticFrontEndCreator(CXXSyntheticChildren *, |
256 | lldb::ValueObjectSP); |
257 | |
258 | SyntheticChildrenFrontEnd *LibcxxQueueFrontEndCreator(CXXSyntheticChildren *, |
259 | lldb::ValueObjectSP); |
260 | |
261 | SyntheticChildrenFrontEnd *LibcxxTupleFrontEndCreator(CXXSyntheticChildren *, |
262 | lldb::ValueObjectSP); |
263 | |
264 | SyntheticChildrenFrontEnd * |
265 | LibcxxOptionalSyntheticFrontEndCreator(CXXSyntheticChildren *, |
266 | lldb::ValueObjectSP valobj_sp); |
267 | |
268 | SyntheticChildrenFrontEnd * |
269 | LibcxxVariantFrontEndCreator(CXXSyntheticChildren *, |
270 | lldb::ValueObjectSP valobj_sp); |
271 | |
272 | SyntheticChildrenFrontEnd * |
273 | LibcxxStdSpanSyntheticFrontEndCreator(CXXSyntheticChildren *, |
274 | lldb::ValueObjectSP); |
275 | |
276 | SyntheticChildrenFrontEnd * |
277 | LibcxxStdRangesRefViewSyntheticFrontEndCreator(CXXSyntheticChildren *, |
278 | lldb::ValueObjectSP); |
279 | |
280 | bool LibcxxChronoSysSecondsSummaryProvider( |
281 | ValueObject &valobj, Stream &stream, |
282 | const TypeSummaryOptions &options); // libc++ std::chrono::sys_seconds |
283 | |
284 | bool LibcxxChronoSysDaysSummaryProvider( |
285 | ValueObject &valobj, Stream &stream, |
286 | const TypeSummaryOptions &options); // libc++ std::chrono::sys_days |
287 | |
288 | bool LibcxxChronoLocalSecondsSummaryProvider( |
289 | ValueObject &valobj, Stream &stream, |
290 | const TypeSummaryOptions &options); // libc++ std::chrono::local_seconds |
291 | |
292 | bool LibcxxChronoLocalDaysSummaryProvider( |
293 | ValueObject &valobj, Stream &stream, |
294 | const TypeSummaryOptions &options); // libc++ std::chrono::local_days |
295 | |
296 | bool LibcxxChronoMonthSummaryProvider( |
297 | ValueObject &valobj, Stream &stream, |
298 | const TypeSummaryOptions &options); // libc++ std::chrono::month |
299 | |
300 | bool LibcxxChronoWeekdaySummaryProvider( |
301 | ValueObject &valobj, Stream &stream, |
302 | const TypeSummaryOptions &options); // libc++ std::chrono::weekday |
303 | |
304 | bool LibcxxChronoYearMonthDaySummaryProvider( |
305 | ValueObject &valobj, Stream &stream, |
306 | const TypeSummaryOptions &options); // libc++ std::chrono::year_month_day |
307 | |
308 | } // namespace formatters |
309 | } // namespace lldb_private |
310 | |
311 | #endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXX_H |
312 | |