xref: /freebsd-src/contrib/llvm-project/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h (revision 5956d97f4b3204318ceb6aa9c77bd0bc6ea87a41)
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 class LibCxxMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
78 public:
79   LibCxxMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
80 
81   size_t CalculateNumChildren() override;
82 
83   lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
84 
85   bool Update() override;
86 
87   bool MightHaveChildren() override;
88 
89   size_t GetIndexOfChildWithName(ConstString name) override;
90 
91   ~LibCxxMapIteratorSyntheticFrontEnd() override;
92 
93 private:
94   ValueObject *m_pair_ptr;
95   lldb::ValueObjectSP m_pair_sp;
96 };
97 
98 SyntheticChildrenFrontEnd *
99 LibCxxMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *,
100                                           lldb::ValueObjectSP);
101 
102 SyntheticChildrenFrontEnd *
103 LibCxxVectorIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *,
104                                              lldb::ValueObjectSP);
105 
106 class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
107 public:
108   LibcxxSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
109 
110   size_t CalculateNumChildren() override;
111 
112   lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
113 
114   bool Update() override;
115 
116   bool MightHaveChildren() override;
117 
118   size_t GetIndexOfChildWithName(ConstString name) override;
119 
120   ~LibcxxSharedPtrSyntheticFrontEnd() override;
121 
122 private:
123   ValueObject *m_cntrl;
124 };
125 
126 class LibcxxUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
127 public:
128   LibcxxUniquePtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
129 
130   size_t CalculateNumChildren() override;
131 
132   lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
133 
134   bool Update() override;
135 
136   bool MightHaveChildren() override;
137 
138   size_t GetIndexOfChildWithName(ConstString name) override;
139 
140   ~LibcxxUniquePtrSyntheticFrontEnd() override;
141 
142 private:
143   lldb::ValueObjectSP m_value_ptr_sp;
144 };
145 
146 SyntheticChildrenFrontEnd *
147 LibcxxBitsetSyntheticFrontEndCreator(CXXSyntheticChildren *,
148                                      lldb::ValueObjectSP);
149 
150 SyntheticChildrenFrontEnd *
151 LibcxxSharedPtrSyntheticFrontEndCreator(CXXSyntheticChildren *,
152                                         lldb::ValueObjectSP);
153 
154 SyntheticChildrenFrontEnd *
155 LibcxxUniquePtrSyntheticFrontEndCreator(CXXSyntheticChildren *,
156                                         lldb::ValueObjectSP);
157 
158 SyntheticChildrenFrontEnd *
159 LibcxxStdVectorSyntheticFrontEndCreator(CXXSyntheticChildren *,
160                                         lldb::ValueObjectSP);
161 
162 SyntheticChildrenFrontEnd *
163 LibcxxStdListSyntheticFrontEndCreator(CXXSyntheticChildren *,
164                                       lldb::ValueObjectSP);
165 
166 SyntheticChildrenFrontEnd *
167 LibcxxStdForwardListSyntheticFrontEndCreator(CXXSyntheticChildren *,
168                                              lldb::ValueObjectSP);
169 
170 SyntheticChildrenFrontEnd *
171 LibcxxStdMapSyntheticFrontEndCreator(CXXSyntheticChildren *,
172                                      lldb::ValueObjectSP);
173 
174 SyntheticChildrenFrontEnd *
175 LibcxxStdUnorderedMapSyntheticFrontEndCreator(CXXSyntheticChildren *,
176                                               lldb::ValueObjectSP);
177 
178 SyntheticChildrenFrontEnd *
179 LibcxxInitializerListSyntheticFrontEndCreator(CXXSyntheticChildren *,
180                                               lldb::ValueObjectSP);
181 
182 SyntheticChildrenFrontEnd *LibcxxQueueFrontEndCreator(CXXSyntheticChildren *,
183                                                       lldb::ValueObjectSP);
184 
185 SyntheticChildrenFrontEnd *LibcxxTupleFrontEndCreator(CXXSyntheticChildren *,
186                                                       lldb::ValueObjectSP);
187 
188 SyntheticChildrenFrontEnd *
189 LibcxxOptionalSyntheticFrontEndCreator(CXXSyntheticChildren *,
190                                        lldb::ValueObjectSP valobj_sp);
191 
192 SyntheticChildrenFrontEnd *
193 LibcxxVariantFrontEndCreator(CXXSyntheticChildren *,
194                              lldb::ValueObjectSP valobj_sp);
195 
196 } // namespace formatters
197 } // namespace lldb_private
198 
199 #endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXX_H
200