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 bool LibcxxStringSummaryProviderASCII(
22     ValueObject &valobj, Stream &stream,
23     const TypeSummaryOptions &summary_options); // libc++ std::string
24 
25 bool LibcxxStringSummaryProviderUTF16(
26     ValueObject &valobj, Stream &stream,
27     const TypeSummaryOptions &summary_options); // libc++ std::u16string
28 
29 bool LibcxxStringSummaryProviderUTF32(
30     ValueObject &valobj, Stream &stream,
31     const TypeSummaryOptions &summary_options); // libc++ std::u32string
32 
33 bool LibcxxWStringSummaryProvider(
34     ValueObject &valobj, Stream &stream,
35     const TypeSummaryOptions &options); // libc++ std::wstring
36 
37 bool LibcxxStringViewSummaryProviderASCII(
38     ValueObject &valueObj, Stream &stream,
39     const TypeSummaryOptions &summary_options); // libc++ std::string_view
40 
41 bool LibcxxStringViewSummaryProviderUTF16(
42     ValueObject &valobj, Stream &stream,
43     const TypeSummaryOptions &summary_options); // libc++ std::u16string_view
44 
45 bool LibcxxStringViewSummaryProviderUTF32(
46     ValueObject &valobj, Stream &stream,
47     const TypeSummaryOptions &summary_options); // libc++ std::u32string_view
48 
49 bool LibcxxWStringViewSummaryProvider(
50     ValueObject &valobj, Stream &stream,
51     const TypeSummaryOptions &options); // libc++ std::wstring_view
52 
53 bool LibcxxOptionalSummaryProvider(
54     ValueObject &valobj, Stream &stream,
55     const TypeSummaryOptions &options); // libc++ std::optional<>
56 
57 bool LibcxxSmartPointerSummaryProvider(
58     ValueObject &valobj, Stream &stream,
59     const TypeSummaryOptions
60         &options); // libc++ std::shared_ptr<> and std::weak_ptr<>
61 
62 // libc++ std::unique_ptr<>
63 bool LibcxxUniquePointerSummaryProvider(ValueObject &valobj, Stream &stream,
64                                         const TypeSummaryOptions &options);
65 
66 bool LibcxxFunctionSummaryProvider(
67     ValueObject &valobj, Stream &stream,
68     const TypeSummaryOptions &options); // libc++ std::function<>
69 
70 SyntheticChildrenFrontEnd *
71 LibcxxVectorBoolSyntheticFrontEndCreator(CXXSyntheticChildren *,
72                                          lldb::ValueObjectSP);
73 
74 bool LibcxxContainerSummaryProvider(ValueObject &valobj, Stream &stream,
75                                     const TypeSummaryOptions &options);
76 
77 /// Formatter for libc++ std::span<>.
78 bool LibcxxSpanSummaryProvider(ValueObject &valobj, Stream &stream,
79                                const TypeSummaryOptions &options);
80 
81 class LibCxxMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
82 public:
83   LibCxxMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
84 
85   size_t CalculateNumChildren() override;
86 
87   lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
88 
89   bool Update() override;
90 
91   bool MightHaveChildren() override;
92 
93   size_t GetIndexOfChildWithName(ConstString name) override;
94 
95   ~LibCxxMapIteratorSyntheticFrontEnd() override;
96 
97 private:
98   ValueObject *m_pair_ptr;
99   lldb::ValueObjectSP m_pair_sp;
100 };
101 
102 SyntheticChildrenFrontEnd *
103 LibCxxMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *,
104                                           lldb::ValueObjectSP);
105 
106 SyntheticChildrenFrontEnd *
107 LibCxxVectorIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *,
108                                              lldb::ValueObjectSP);
109 
110 class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
111 public:
112   LibcxxSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
113 
114   size_t CalculateNumChildren() override;
115 
116   lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
117 
118   bool Update() override;
119 
120   bool MightHaveChildren() override;
121 
122   size_t GetIndexOfChildWithName(ConstString name) override;
123 
124   ~LibcxxSharedPtrSyntheticFrontEnd() override;
125 
126 private:
127   ValueObject *m_cntrl;
128 };
129 
130 class LibcxxUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
131 public:
132   LibcxxUniquePtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
133 
134   size_t CalculateNumChildren() override;
135 
136   lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
137 
138   bool Update() override;
139 
140   bool MightHaveChildren() override;
141 
142   size_t GetIndexOfChildWithName(ConstString name) override;
143 
144   ~LibcxxUniquePtrSyntheticFrontEnd() override;
145 
146 private:
147   lldb::ValueObjectSP m_value_ptr_sp;
148 };
149 
150 SyntheticChildrenFrontEnd *
151 LibcxxBitsetSyntheticFrontEndCreator(CXXSyntheticChildren *,
152                                      lldb::ValueObjectSP);
153 
154 SyntheticChildrenFrontEnd *
155 LibcxxSharedPtrSyntheticFrontEndCreator(CXXSyntheticChildren *,
156                                         lldb::ValueObjectSP);
157 
158 SyntheticChildrenFrontEnd *
159 LibcxxUniquePtrSyntheticFrontEndCreator(CXXSyntheticChildren *,
160                                         lldb::ValueObjectSP);
161 
162 SyntheticChildrenFrontEnd *
163 LibcxxStdVectorSyntheticFrontEndCreator(CXXSyntheticChildren *,
164                                         lldb::ValueObjectSP);
165 
166 SyntheticChildrenFrontEnd *
167 LibcxxStdListSyntheticFrontEndCreator(CXXSyntheticChildren *,
168                                       lldb::ValueObjectSP);
169 
170 SyntheticChildrenFrontEnd *
171 LibcxxStdForwardListSyntheticFrontEndCreator(CXXSyntheticChildren *,
172                                              lldb::ValueObjectSP);
173 
174 SyntheticChildrenFrontEnd *
175 LibcxxStdMapSyntheticFrontEndCreator(CXXSyntheticChildren *,
176                                      lldb::ValueObjectSP);
177 
178 SyntheticChildrenFrontEnd *
179 LibcxxStdUnorderedMapSyntheticFrontEndCreator(CXXSyntheticChildren *,
180                                               lldb::ValueObjectSP);
181 
182 SyntheticChildrenFrontEnd *
183 LibcxxInitializerListSyntheticFrontEndCreator(CXXSyntheticChildren *,
184                                               lldb::ValueObjectSP);
185 
186 SyntheticChildrenFrontEnd *LibcxxQueueFrontEndCreator(CXXSyntheticChildren *,
187                                                       lldb::ValueObjectSP);
188 
189 SyntheticChildrenFrontEnd *LibcxxTupleFrontEndCreator(CXXSyntheticChildren *,
190                                                       lldb::ValueObjectSP);
191 
192 SyntheticChildrenFrontEnd *
193 LibcxxOptionalSyntheticFrontEndCreator(CXXSyntheticChildren *,
194                                        lldb::ValueObjectSP valobj_sp);
195 
196 SyntheticChildrenFrontEnd *
197 LibcxxVariantFrontEndCreator(CXXSyntheticChildren *,
198                              lldb::ValueObjectSP valobj_sp);
199 
200 SyntheticChildrenFrontEnd *
201 LibcxxStdSpanSyntheticFrontEndCreator(CXXSyntheticChildren *,
202                                       lldb::ValueObjectSP);
203 
204 } // namespace formatters
205 } // namespace lldb_private
206 
207 #endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXX_H
208