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   lldb::ValueObjectSP m_count_sp;
109   lldb::ValueObjectSP m_weak_count_sp;
110   uint8_t m_ptr_size;
111   lldb::ByteOrder m_byte_order;
112 };
113 
114 class LibcxxUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
115 public:
116   LibcxxUniquePtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
117 
118   size_t CalculateNumChildren() override;
119 
120   lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
121 
122   bool Update() override;
123 
124   bool MightHaveChildren() override;
125 
126   size_t GetIndexOfChildWithName(ConstString name) override;
127 
128   ~LibcxxUniquePtrSyntheticFrontEnd() override;
129 
130 private:
131   lldb::ValueObjectSP m_compressed_pair_sp;
132 };
133 
134 SyntheticChildrenFrontEnd *
135 LibcxxBitsetSyntheticFrontEndCreator(CXXSyntheticChildren *,
136                                      lldb::ValueObjectSP);
137 
138 SyntheticChildrenFrontEnd *
139 LibcxxSharedPtrSyntheticFrontEndCreator(CXXSyntheticChildren *,
140                                         lldb::ValueObjectSP);
141 
142 SyntheticChildrenFrontEnd *
143 LibcxxUniquePtrSyntheticFrontEndCreator(CXXSyntheticChildren *,
144                                         lldb::ValueObjectSP);
145 
146 SyntheticChildrenFrontEnd *
147 LibcxxStdVectorSyntheticFrontEndCreator(CXXSyntheticChildren *,
148                                         lldb::ValueObjectSP);
149 
150 SyntheticChildrenFrontEnd *
151 LibcxxStdListSyntheticFrontEndCreator(CXXSyntheticChildren *,
152                                       lldb::ValueObjectSP);
153 
154 SyntheticChildrenFrontEnd *
155 LibcxxStdForwardListSyntheticFrontEndCreator(CXXSyntheticChildren *,
156                                              lldb::ValueObjectSP);
157 
158 SyntheticChildrenFrontEnd *
159 LibcxxStdMapSyntheticFrontEndCreator(CXXSyntheticChildren *,
160                                      lldb::ValueObjectSP);
161 
162 SyntheticChildrenFrontEnd *
163 LibcxxStdUnorderedMapSyntheticFrontEndCreator(CXXSyntheticChildren *,
164                                               lldb::ValueObjectSP);
165 
166 SyntheticChildrenFrontEnd *
167 LibcxxInitializerListSyntheticFrontEndCreator(CXXSyntheticChildren *,
168                                               lldb::ValueObjectSP);
169 
170 SyntheticChildrenFrontEnd *LibcxxQueueFrontEndCreator(CXXSyntheticChildren *,
171                                                       lldb::ValueObjectSP);
172 
173 SyntheticChildrenFrontEnd *LibcxxTupleFrontEndCreator(CXXSyntheticChildren *,
174                                                       lldb::ValueObjectSP);
175 
176 SyntheticChildrenFrontEnd *
177 LibcxxOptionalFrontEndCreator(CXXSyntheticChildren *,
178                               lldb::ValueObjectSP valobj_sp);
179 
180 SyntheticChildrenFrontEnd *
181 LibcxxVariantFrontEndCreator(CXXSyntheticChildren *,
182                              lldb::ValueObjectSP valobj_sp);
183 
184 } // namespace formatters
185 } // namespace lldb_private
186 
187 #endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXX_H
188