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 liblldb_LibCxx_h_
11 #define liblldb_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 bool LibcxxFunctionSummaryProvider(
47     ValueObject &valobj, Stream &stream,
48     const TypeSummaryOptions &options); // libc++ std::function<>
49 
50 SyntheticChildrenFrontEnd *
51 LibcxxVectorBoolSyntheticFrontEndCreator(CXXSyntheticChildren *,
52                                          lldb::ValueObjectSP);
53 
54 bool LibcxxContainerSummaryProvider(ValueObject &valobj, Stream &stream,
55                                     const TypeSummaryOptions &options);
56 
57 class LibCxxMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
58 public:
59   LibCxxMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
60 
61   size_t CalculateNumChildren() override;
62 
63   lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
64 
65   bool Update() override;
66 
67   bool MightHaveChildren() override;
68 
69   size_t GetIndexOfChildWithName(ConstString name) override;
70 
71   ~LibCxxMapIteratorSyntheticFrontEnd() override;
72 
73 private:
74   ValueObject *m_pair_ptr;
75   lldb::ValueObjectSP m_pair_sp;
76 };
77 
78 SyntheticChildrenFrontEnd *
79 LibCxxMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *,
80                                           lldb::ValueObjectSP);
81 
82 SyntheticChildrenFrontEnd *
83 LibCxxVectorIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *,
84                                              lldb::ValueObjectSP);
85 
86 class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
87 public:
88   LibcxxSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
89 
90   size_t CalculateNumChildren() override;
91 
92   lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
93 
94   bool Update() override;
95 
96   bool MightHaveChildren() override;
97 
98   size_t GetIndexOfChildWithName(ConstString name) override;
99 
100   ~LibcxxSharedPtrSyntheticFrontEnd() override;
101 
102 private:
103   ValueObject *m_cntrl;
104   lldb::ValueObjectSP m_count_sp;
105   lldb::ValueObjectSP m_weak_count_sp;
106   uint8_t m_ptr_size;
107   lldb::ByteOrder m_byte_order;
108 };
109 
110 SyntheticChildrenFrontEnd *
111 LibcxxBitsetSyntheticFrontEndCreator(CXXSyntheticChildren *,
112                                      lldb::ValueObjectSP);
113 
114 SyntheticChildrenFrontEnd *
115 LibcxxSharedPtrSyntheticFrontEndCreator(CXXSyntheticChildren *,
116                                         lldb::ValueObjectSP);
117 
118 SyntheticChildrenFrontEnd *
119 LibcxxStdVectorSyntheticFrontEndCreator(CXXSyntheticChildren *,
120                                         lldb::ValueObjectSP);
121 
122 SyntheticChildrenFrontEnd *
123 LibcxxStdListSyntheticFrontEndCreator(CXXSyntheticChildren *,
124                                       lldb::ValueObjectSP);
125 
126 SyntheticChildrenFrontEnd *
127 LibcxxStdForwardListSyntheticFrontEndCreator(CXXSyntheticChildren *,
128                                              lldb::ValueObjectSP);
129 
130 SyntheticChildrenFrontEnd *
131 LibcxxStdMapSyntheticFrontEndCreator(CXXSyntheticChildren *,
132                                      lldb::ValueObjectSP);
133 
134 SyntheticChildrenFrontEnd *
135 LibcxxStdUnorderedMapSyntheticFrontEndCreator(CXXSyntheticChildren *,
136                                               lldb::ValueObjectSP);
137 
138 SyntheticChildrenFrontEnd *
139 LibcxxInitializerListSyntheticFrontEndCreator(CXXSyntheticChildren *,
140                                               lldb::ValueObjectSP);
141 
142 SyntheticChildrenFrontEnd *LibcxxQueueFrontEndCreator(CXXSyntheticChildren *,
143                                                       lldb::ValueObjectSP);
144 
145 SyntheticChildrenFrontEnd *LibcxxTupleFrontEndCreator(CXXSyntheticChildren *,
146                                                       lldb::ValueObjectSP);
147 
148 SyntheticChildrenFrontEnd *
149 LibcxxOptionalFrontEndCreator(CXXSyntheticChildren *,
150                               lldb::ValueObjectSP valobj_sp);
151 
152 SyntheticChildrenFrontEnd *
153 LibcxxVariantFrontEndCreator(CXXSyntheticChildren *,
154                              lldb::ValueObjectSP valobj_sp);
155 
156 } // namespace formatters
157 } // namespace lldb_private
158 
159 #endif // liblldb_LibCxx_h_
160