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 LibcxxOptionalSummaryProvider(
38     ValueObject &valobj, Stream &stream,
39     const TypeSummaryOptions &options); // libc++ std::optional<>
40 
41 bool LibcxxSmartPointerSummaryProvider(
42     ValueObject &valobj, Stream &stream,
43     const TypeSummaryOptions
44         &options); // libc++ std::shared_ptr<> and std::weak_ptr<>
45 
46 // libc++ std::unique_ptr<>
47 bool LibcxxUniquePointerSummaryProvider(ValueObject &valobj, Stream &stream,
48                                         const TypeSummaryOptions &options);
49 
50 bool LibcxxFunctionSummaryProvider(
51     ValueObject &valobj, Stream &stream,
52     const TypeSummaryOptions &options); // libc++ std::function<>
53 
54 SyntheticChildrenFrontEnd *
55 LibcxxVectorBoolSyntheticFrontEndCreator(CXXSyntheticChildren *,
56                                          lldb::ValueObjectSP);
57 
58 bool LibcxxContainerSummaryProvider(ValueObject &valobj, Stream &stream,
59                                     const TypeSummaryOptions &options);
60 
61 class LibCxxMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
62 public:
63   LibCxxMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
64 
65   size_t CalculateNumChildren() override;
66 
67   lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
68 
69   bool Update() override;
70 
71   bool MightHaveChildren() override;
72 
73   size_t GetIndexOfChildWithName(ConstString name) override;
74 
75   ~LibCxxMapIteratorSyntheticFrontEnd() override;
76 
77 private:
78   ValueObject *m_pair_ptr;
79   lldb::ValueObjectSP m_pair_sp;
80 };
81 
82 SyntheticChildrenFrontEnd *
83 LibCxxMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *,
84                                           lldb::ValueObjectSP);
85 
86 SyntheticChildrenFrontEnd *
87 LibCxxVectorIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *,
88                                              lldb::ValueObjectSP);
89 
90 class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
91 public:
92   LibcxxSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
93 
94   size_t CalculateNumChildren() override;
95 
96   lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
97 
98   bool Update() override;
99 
100   bool MightHaveChildren() override;
101 
102   size_t GetIndexOfChildWithName(ConstString name) override;
103 
104   ~LibcxxSharedPtrSyntheticFrontEnd() override;
105 
106 private:
107   ValueObject *m_cntrl;
108 };
109 
110 class LibcxxUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
111 public:
112   LibcxxUniquePtrSyntheticFrontEnd(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   ~LibcxxUniquePtrSyntheticFrontEnd() override;
125 
126 private:
127   lldb::ValueObjectSP m_value_ptr_sp;
128 };
129 
130 SyntheticChildrenFrontEnd *
131 LibcxxBitsetSyntheticFrontEndCreator(CXXSyntheticChildren *,
132                                      lldb::ValueObjectSP);
133 
134 SyntheticChildrenFrontEnd *
135 LibcxxSharedPtrSyntheticFrontEndCreator(CXXSyntheticChildren *,
136                                         lldb::ValueObjectSP);
137 
138 SyntheticChildrenFrontEnd *
139 LibcxxUniquePtrSyntheticFrontEndCreator(CXXSyntheticChildren *,
140                                         lldb::ValueObjectSP);
141 
142 SyntheticChildrenFrontEnd *
143 LibcxxStdVectorSyntheticFrontEndCreator(CXXSyntheticChildren *,
144                                         lldb::ValueObjectSP);
145 
146 SyntheticChildrenFrontEnd *
147 LibcxxStdListSyntheticFrontEndCreator(CXXSyntheticChildren *,
148                                       lldb::ValueObjectSP);
149 
150 SyntheticChildrenFrontEnd *
151 LibcxxStdForwardListSyntheticFrontEndCreator(CXXSyntheticChildren *,
152                                              lldb::ValueObjectSP);
153 
154 SyntheticChildrenFrontEnd *
155 LibcxxStdMapSyntheticFrontEndCreator(CXXSyntheticChildren *,
156                                      lldb::ValueObjectSP);
157 
158 SyntheticChildrenFrontEnd *
159 LibcxxStdUnorderedMapSyntheticFrontEndCreator(CXXSyntheticChildren *,
160                                               lldb::ValueObjectSP);
161 
162 SyntheticChildrenFrontEnd *
163 LibcxxInitializerListSyntheticFrontEndCreator(CXXSyntheticChildren *,
164                                               lldb::ValueObjectSP);
165 
166 SyntheticChildrenFrontEnd *LibcxxQueueFrontEndCreator(CXXSyntheticChildren *,
167                                                       lldb::ValueObjectSP);
168 
169 SyntheticChildrenFrontEnd *LibcxxTupleFrontEndCreator(CXXSyntheticChildren *,
170                                                       lldb::ValueObjectSP);
171 
172 SyntheticChildrenFrontEnd *
173 LibcxxOptionalFrontEndCreator(CXXSyntheticChildren *,
174                               lldb::ValueObjectSP valobj_sp);
175 
176 SyntheticChildrenFrontEnd *
177 LibcxxVariantFrontEndCreator(CXXSyntheticChildren *,
178                              lldb::ValueObjectSP valobj_sp);
179 
180 } // namespace formatters
181 } // namespace lldb_private
182 
183 #endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXX_H
184