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
18namespace lldb_private {
19namespace formatters {
20
21/// Find a child member of \c obj_sp, trying all alternative names in order.
22lldb::ValueObjectSP
23GetChildMemberWithName(ValueObject &obj,
24 llvm::ArrayRef<ConstString> alternative_names);
25
26lldb::ValueObjectSP GetFirstValueOfLibCXXCompressedPair(ValueObject &pair);
27lldb::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.
40std::pair<lldb::ValueObjectSP, bool>
41GetValueOrOldCompressedPair(ValueObject &obj, size_t anon_struct_idx,
42 llvm::StringRef child_name,
43 llvm::StringRef compressed_pair_name);
44bool isStdTemplate(ConstString type_name, llvm::StringRef type);
45
46bool LibcxxStringSummaryProviderASCII(
47 ValueObject &valobj, Stream &stream,
48 const TypeSummaryOptions &summary_options); // libc++ std::string
49
50bool LibcxxStringSummaryProviderUTF16(
51 ValueObject &valobj, Stream &stream,
52 const TypeSummaryOptions &summary_options); // libc++ std::u16string
53
54bool LibcxxStringSummaryProviderUTF32(
55 ValueObject &valobj, Stream &stream,
56 const TypeSummaryOptions &summary_options); // libc++ std::u32string
57
58bool LibcxxWStringSummaryProvider(
59 ValueObject &valobj, Stream &stream,
60 const TypeSummaryOptions &options); // libc++ std::wstring
61
62bool LibcxxStringViewSummaryProviderASCII(
63 ValueObject &valueObj, Stream &stream,
64 const TypeSummaryOptions &summary_options); // libc++ std::string_view
65
66bool LibcxxStringViewSummaryProviderUTF16(
67 ValueObject &valobj, Stream &stream,
68 const TypeSummaryOptions &summary_options); // libc++ std::u16string_view
69
70bool LibcxxStringViewSummaryProviderUTF32(
71 ValueObject &valobj, Stream &stream,
72 const TypeSummaryOptions &summary_options); // libc++ std::u32string_view
73
74bool LibcxxWStringViewSummaryProvider(
75 ValueObject &valobj, Stream &stream,
76 const TypeSummaryOptions &options); // libc++ std::wstring_view
77
78bool LibcxxStdSliceArraySummaryProvider(
79 ValueObject &valobj, Stream &stream,
80 const TypeSummaryOptions &options); // libc++ std::slice_array
81
82bool 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<>
88bool LibcxxUniquePointerSummaryProvider(ValueObject &valobj, Stream &stream,
89 const TypeSummaryOptions &options);
90
91bool LibcxxFunctionSummaryProvider(
92 ValueObject &valobj, Stream &stream,
93 const TypeSummaryOptions &options); // libc++ std::function<>
94
95SyntheticChildrenFrontEnd *
96LibcxxVectorBoolSyntheticFrontEndCreator(CXXSyntheticChildren *,
97 lldb::ValueObjectSP);
98
99/// Formatter for libc++ std::span<>.
100bool LibcxxSpanSummaryProvider(ValueObject &valobj, Stream &stream,
101 const TypeSummaryOptions &options);
102
103SyntheticChildrenFrontEnd *
104LibCxxVectorIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *,
105 lldb::ValueObjectSP);
106
107class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
108public:
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
121private:
122 ValueObject *m_cntrl;
123 ValueObject *m_ptr_obj;
124};
125
126class LibcxxUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
127public:
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
140private:
141 lldb::ValueObjectSP m_value_ptr_sp;
142 lldb::ValueObjectSP m_deleter_sp;
143};
144
145SyntheticChildrenFrontEnd *
146LibcxxBitsetSyntheticFrontEndCreator(CXXSyntheticChildren *,
147 lldb::ValueObjectSP);
148
149SyntheticChildrenFrontEnd *
150LibcxxSharedPtrSyntheticFrontEndCreator(CXXSyntheticChildren *,
151 lldb::ValueObjectSP);
152
153SyntheticChildrenFrontEnd *
154LibcxxUniquePtrSyntheticFrontEndCreator(CXXSyntheticChildren *,
155 lldb::ValueObjectSP);
156
157SyntheticChildrenFrontEnd *
158LibcxxStdVectorSyntheticFrontEndCreator(CXXSyntheticChildren *,
159 lldb::ValueObjectSP);
160
161SyntheticChildrenFrontEnd *
162LibcxxStdValarraySyntheticFrontEndCreator(CXXSyntheticChildren *,
163 lldb::ValueObjectSP);
164
165SyntheticChildrenFrontEnd *
166LibcxxStdSliceArraySyntheticFrontEndCreator(CXXSyntheticChildren *,
167 lldb::ValueObjectSP);
168
169SyntheticChildrenFrontEnd *
170LibcxxStdProxyArraySyntheticFrontEndCreator(CXXSyntheticChildren *,
171 lldb::ValueObjectSP);
172
173SyntheticChildrenFrontEnd *
174LibcxxStdListSyntheticFrontEndCreator(CXXSyntheticChildren *,
175 lldb::ValueObjectSP);
176
177SyntheticChildrenFrontEnd *
178LibcxxStdForwardListSyntheticFrontEndCreator(CXXSyntheticChildren *,
179 lldb::ValueObjectSP);
180
181SyntheticChildrenFrontEnd *
182LibcxxStdMapSyntheticFrontEndCreator(CXXSyntheticChildren *,
183 lldb::ValueObjectSP);
184
185SyntheticChildrenFrontEnd *
186LibCxxMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *,
187 lldb::ValueObjectSP);
188
189SyntheticChildrenFrontEnd *
190LibcxxStdUnorderedMapSyntheticFrontEndCreator(CXXSyntheticChildren *,
191 lldb::ValueObjectSP);
192
193SyntheticChildrenFrontEnd *
194LibCxxUnorderedMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *,
195 lldb::ValueObjectSP);
196
197SyntheticChildrenFrontEnd *
198LibcxxInitializerListSyntheticFrontEndCreator(CXXSyntheticChildren *,
199 lldb::ValueObjectSP);
200
201SyntheticChildrenFrontEnd *LibcxxQueueFrontEndCreator(CXXSyntheticChildren *,
202 lldb::ValueObjectSP);
203
204SyntheticChildrenFrontEnd *LibcxxTupleFrontEndCreator(CXXSyntheticChildren *,
205 lldb::ValueObjectSP);
206
207SyntheticChildrenFrontEnd *
208LibcxxOptionalSyntheticFrontEndCreator(CXXSyntheticChildren *,
209 lldb::ValueObjectSP valobj_sp);
210
211SyntheticChildrenFrontEnd *
212LibcxxVariantFrontEndCreator(CXXSyntheticChildren *,
213 lldb::ValueObjectSP valobj_sp);
214
215SyntheticChildrenFrontEnd *
216LibcxxStdSpanSyntheticFrontEndCreator(CXXSyntheticChildren *,
217 lldb::ValueObjectSP);
218
219SyntheticChildrenFrontEnd *
220LibcxxStdRangesRefViewSyntheticFrontEndCreator(CXXSyntheticChildren *,
221 lldb::ValueObjectSP);
222
223bool LibcxxChronoSysSecondsSummaryProvider(
224 ValueObject &valobj, Stream &stream,
225 const TypeSummaryOptions &options); // libc++ std::chrono::sys_seconds
226
227bool LibcxxChronoSysDaysSummaryProvider(
228 ValueObject &valobj, Stream &stream,
229 const TypeSummaryOptions &options); // libc++ std::chrono::sys_days
230
231bool LibcxxChronoLocalSecondsSummaryProvider(
232 ValueObject &valobj, Stream &stream,
233 const TypeSummaryOptions &options); // libc++ std::chrono::local_seconds
234
235bool LibcxxChronoLocalDaysSummaryProvider(
236 ValueObject &valobj, Stream &stream,
237 const TypeSummaryOptions &options); // libc++ std::chrono::local_days
238
239bool LibcxxChronoMonthSummaryProvider(
240 ValueObject &valobj, Stream &stream,
241 const TypeSummaryOptions &options); // libc++ std::chrono::month
242
243bool LibcxxChronoWeekdaySummaryProvider(
244 ValueObject &valobj, Stream &stream,
245 const TypeSummaryOptions &options); // libc++ std::chrono::weekday
246
247bool 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

source code of lldb/source/Plugins/Language/CPlusPlus/LibCxx.h