LLDB  mainline
LibCxx.h
Go to the documentation of this file.
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"
16 #include "lldb/Utility/Stream.h"
17 
18 namespace lldb_private {
19 namespace formatters {
20 
21 /// Find a child member of \c obj_sp, trying all alternative names in order.
22 lldb::ValueObjectSP
23 GetChildMemberWithName(ValueObject &obj,
24  llvm::ArrayRef<ConstString> alternative_names);
25 
27  ValueObject &valobj, Stream &stream,
28  const TypeSummaryOptions &summary_options); // libc++ std::string
29 
31  ValueObject &valobj, Stream &stream,
32  const TypeSummaryOptions &summary_options); // libc++ std::u16string
33 
35  ValueObject &valobj, Stream &stream,
36  const TypeSummaryOptions &summary_options); // libc++ std::u32string
37 
39  ValueObject &valobj, Stream &stream,
40  const TypeSummaryOptions &options); // libc++ std::wstring
41 
43  ValueObject &valueObj, Stream &stream,
44  const TypeSummaryOptions &summary_options); // libc++ std::string_view
45 
47  ValueObject &valobj, Stream &stream,
48  const TypeSummaryOptions &summary_options); // libc++ std::u16string_view
49 
51  ValueObject &valobj, Stream &stream,
52  const TypeSummaryOptions &summary_options); // libc++ std::u32string_view
53 
55  ValueObject &valobj, Stream &stream,
56  const TypeSummaryOptions &options); // libc++ std::wstring_view
57 
59  ValueObject &valobj, Stream &stream,
60  const TypeSummaryOptions &options); // libc++ std::optional<>
61 
63  ValueObject &valobj, Stream &stream,
64  const TypeSummaryOptions
65  &options); // libc++ std::shared_ptr<> and std::weak_ptr<>
66 
67 // libc++ std::unique_ptr<>
68 bool LibcxxUniquePointerSummaryProvider(ValueObject &valobj, Stream &stream,
69  const TypeSummaryOptions &options);
70 
72  ValueObject &valobj, Stream &stream,
73  const TypeSummaryOptions &options); // libc++ std::function<>
74 
75 SyntheticChildrenFrontEnd *
76 LibcxxVectorBoolSyntheticFrontEndCreator(CXXSyntheticChildren *,
77  lldb::ValueObjectSP);
78 
79 bool LibcxxContainerSummaryProvider(ValueObject &valobj, Stream &stream,
80  const TypeSummaryOptions &options);
81 
82 /// Formatter for libc++ std::span<>.
83 bool LibcxxSpanSummaryProvider(ValueObject &valobj, Stream &stream,
84  const TypeSummaryOptions &options);
85 
87 public:
88  LibCxxMapIteratorSyntheticFrontEnd(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 
101 
102 private:
104  lldb::ValueObjectSP m_pair_sp;
105 };
106 
109  lldb::ValueObjectSP);
110 
111 /// Formats libcxx's std::unordered_map iterators
112 ///
113 /// In raw form a std::unordered_map::iterator is represented as follows:
114 ///
115 /// (lldb) var it --raw --ptr-depth 1
116 /// (std::__1::__hash_map_iterator<
117 /// std::__1::__hash_iterator<
118 /// std::__1::__hash_node<
119 /// std::__1::__hash_value_type<
120 /// std::__1::basic_string<char, std::__1::char_traits<char>,
121 /// std::__1::allocator<char> >, std::__1::basic_string<char,
122 /// std::__1::char_traits<char>, std::__1::allocator<char> > >,
123 /// void *> *> >)
124 /// it = {
125 /// __i_ = {
126 /// __node_ = 0x0000600001700040 {
127 /// __next_ = 0x0000600001704000
128 /// }
129 /// }
130 /// }
132  : public SyntheticChildrenFrontEnd {
133 public:
134  LibCxxUnorderedMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
135 
137 
138  size_t CalculateNumChildren() override;
139 
140  lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
141 
142  bool Update() override;
143 
144  bool MightHaveChildren() override;
145 
146  size_t GetIndexOfChildWithName(ConstString name) override;
147 
148 private:
149  ValueObject *m_iter_ptr = nullptr; ///< Held, not owned. Child of iterator
150  ///< ValueObject supplied at construction.
151 
152  lldb::ValueObjectSP m_pair_sp; ///< ValueObject for the key/value pair
153  ///< that the iterator currently points
154  ///< to.
155 };
156 
159  lldb::ValueObjectSP);
160 
163  lldb::ValueObjectSP);
164 
166 public:
167  LibcxxSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
168 
169  size_t CalculateNumChildren() override;
170 
171  lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
172 
173  bool Update() override;
174 
175  bool MightHaveChildren() override;
176 
177  size_t GetIndexOfChildWithName(ConstString name) override;
178 
180 
181 private:
183 };
184 
186 public:
187  LibcxxUniquePtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
188 
189  size_t CalculateNumChildren() override;
190 
191  lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
192 
193  bool Update() override;
194 
195  bool MightHaveChildren() override;
196 
197  size_t GetIndexOfChildWithName(ConstString name) override;
198 
200 
201 private:
202  lldb::ValueObjectSP m_value_ptr_sp;
203 };
204 
207  lldb::ValueObjectSP);
208 
211  lldb::ValueObjectSP);
212 
215  lldb::ValueObjectSP);
216 
219  lldb::ValueObjectSP);
220 
223  lldb::ValueObjectSP);
224 
227  lldb::ValueObjectSP);
228 
231  lldb::ValueObjectSP);
232 
235  lldb::ValueObjectSP);
236 
239  lldb::ValueObjectSP);
240 
242  lldb::ValueObjectSP);
243 
245  lldb::ValueObjectSP);
246 
249  lldb::ValueObjectSP valobj_sp);
250 
253  lldb::ValueObjectSP valobj_sp);
254 
257  lldb::ValueObjectSP);
258 
259 } // namespace formatters
260 } // namespace lldb_private
261 
262 #endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXX_H
lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::GetIndexOfChildWithName
size_t GetIndexOfChildWithName(ConstString name) override
Definition: LibCxx.cpp:525
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::m_pair_sp
lldb::ValueObjectSP m_pair_sp
Definition: LibCxx.h:104
lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEndCreator
SyntheticChildrenFrontEnd * LibcxxStdUnorderedMapSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
Definition: LibCxxUnorderedMap.cpp:245
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::~LibCxxMapIteratorSyntheticFrontEnd
~LibCxxMapIteratorSyntheticFrontEnd() override
Definition: LibCxx.cpp:378
lldb_private::formatters::LibcxxStringSummaryProviderUTF16
bool LibcxxStringSummaryProviderUTF16(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options)
Definition: LibCxx.cpp:987
lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::~LibCxxUnorderedMapIteratorSyntheticFrontEnd
~LibCxxUnorderedMapIteratorSyntheticFrontEnd() override=default
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetIndexOfChildWithName
size_t GetIndexOfChildWithName(ConstString name) override
Definition: LibCxx.cpp:623
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::CalculateNumChildren
size_t CalculateNumChildren() override
Definition: LibCxx.cpp:349
lldb_private::formatters::LibcxxStringSummaryProviderUTF32
bool LibcxxStringSummaryProviderUTF32(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options)
Definition: LibCxx.cpp:994
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::GetChildAtIndex
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override
Definition: LibCxx.cpp:354
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::m_value_ptr_sp
lldb::ValueObjectSP m_value_ptr_sp
Definition: LibCxx.h:202
lldb_private::SyntheticChildrenFrontEnd
Definition: TypeSynthetic.h:27
lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator
SyntheticChildrenFrontEnd * LibcxxStdMapSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
Definition: LibCxxMap.cpp:461
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::LibcxxUniquePtrSyntheticFrontEnd
LibcxxUniquePtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
Definition: LibCxx.cpp:642
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::m_pair_ptr
ValueObject * m_pair_ptr
Definition: LibCxx.h:103
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEndCreator
SyntheticChildrenFrontEnd * LibCxxMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
Definition: LibCxx.cpp:384
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::CalculateNumChildren
size_t CalculateNumChildren() override
Definition: LibCxx.cpp:565
lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::LibCxxUnorderedMapIteratorSyntheticFrontEnd
LibCxxUnorderedMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
Definition: LibCxx.cpp:391
lldb_private::formatters::LibcxxSpanSummaryProvider
bool LibcxxSpanSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options)
Formatter for libc++ std::span<>.
lldb_private::formatters::LibcxxWStringSummaryProvider
bool LibcxxWStringSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options)
Definition: LibCxx.cpp:893
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::LibcxxSharedPtrSyntheticFrontEnd
LibcxxSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
Definition: LibCxx.cpp:558
lldb_private::formatters::LibcxxStringViewSummaryProviderASCII
bool LibcxxStringViewSummaryProviderASCII(ValueObject &valueObj, Stream &stream, const TypeSummaryOptions &summary_options)
Definition: LibCxx.cpp:1040
lldb_private::formatters::LibcxxStdVectorSyntheticFrontEndCreator
SyntheticChildrenFrontEnd * LibcxxStdVectorSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
Definition: LibCxxVector.cpp:284
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update
bool Update() override
Definition: LibCxx.cpp:598
lldb_private::formatters::LibcxxFunctionSummaryProvider
bool LibcxxFunctionSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options)
Definition: LibCxx.cpp:70
lldb_private::formatters::LibcxxSmartPointerSummaryProvider
bool LibcxxSmartPointerSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options)
Definition: LibCxx.cpp:118
lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEndCreator
SyntheticChildrenFrontEnd * LibCxxUnorderedMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
Definition: LibCxx.cpp:534
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override
Definition: LibCxx.cpp:570
lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::Update
bool Update() override
Definition: LibCxx.cpp:398
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::~LibcxxUniquePtrSyntheticFrontEnd
~LibcxxUniquePtrSyntheticFrontEnd() override
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update
bool Update() override
Definition: LibCxx.cpp:227
lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::CalculateNumChildren
size_t CalculateNumChildren() override
Definition: LibCxx.cpp:508
lldb_private::ConstString
Definition: ConstString.h:39
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd
Definition: LibCxx.h:185
lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::GetChildAtIndex
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override
Definition: LibCxx.cpp:513
lldb_private::formatters::LibcxxStringSummaryProviderASCII
bool LibcxxStringSummaryProviderASCII(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options)
Definition: LibCxx.cpp:980
lldb_private::formatters::LibcxxInitializerListSyntheticFrontEndCreator
SyntheticChildrenFrontEnd * LibcxxInitializerListSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
Definition: LibCxxInitializerList.cpp:117
lldb_private::formatters::LibcxxBitsetSyntheticFrontEndCreator
SyntheticChildrenFrontEnd * LibcxxBitsetSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
Definition: GenericBitset.cpp:143
lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEndCreator
SyntheticChildrenFrontEnd * LibcxxVectorBoolSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
ValueObject.h
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::Update
bool Update() override
Definition: LibCxx.cpp:683
lldb_private::formatters::GetChildMemberWithName
lldb::ValueObjectSP GetChildMemberWithName(ValueObject &obj, llvm::ArrayRef< ConstString > alternative_names)
Find a child member of obj_sp, trying all alternative names in order.
Definition: LibCxx.cpp:37
lldb_private::formatters::LibcxxStringViewSummaryProviderUTF16
bool LibcxxStringViewSummaryProviderUTF16(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options)
Definition: LibCxx.cpp:1047
lldb_private::formatters::LibcxxStdListSyntheticFrontEndCreator
SyntheticChildrenFrontEnd * LibcxxStdListSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
Definition: LibCxxList.cpp:424
lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::m_pair_sp
lldb::ValueObjectSP m_pair_sp
ValueObject for the key/value pair that the iterator currently points to.
Definition: LibCxx.h:152
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::m_cntrl
ValueObject * m_cntrl
Definition: LibCxx.h:182
lldb_private::ValueObject
ValueObject:
Definition: ValueObject.h:105
lldb_private::formatters::LibcxxContainerSummaryProvider
bool LibcxxContainerSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options)
Definition: LibCxx.cpp:712
lldb_private::formatters::LibcxxStdForwardListSyntheticFrontEndCreator
SyntheticChildrenFrontEnd * LibcxxStdForwardListSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
Definition: LibCxxList.cpp:430
TypeSummary.h
lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::m_iter_ptr
ValueObject * m_iter_ptr
Held, not owned.
Definition: LibCxx.h:149
lldb_private::formatters::LibcxxStdSpanSyntheticFrontEndCreator
SyntheticChildrenFrontEnd * LibcxxStdSpanSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
Definition: LibCxxSpan.cpp:140
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::~LibcxxSharedPtrSyntheticFrontEnd
~LibcxxSharedPtrSyntheticFrontEnd() override
TypeSynthetic.h
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEndCreator
SyntheticChildrenFrontEnd * LibcxxUniquePtrSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
Definition: LibCxx.cpp:652
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator
SyntheticChildrenFrontEnd * LibcxxSharedPtrSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
Definition: LibCxx.cpp:635
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::GetIndexOfChildWithName
size_t GetIndexOfChildWithName(ConstString name) override
Definition: LibCxx.cpp:369
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::MightHaveChildren
bool MightHaveChildren() override
Definition: LibCxx.cpp:699
lldb_private::formatters::LibcxxStringViewSummaryProviderUTF32
bool LibcxxStringViewSummaryProviderUTF32(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options)
Definition: LibCxx.cpp:1054
lldb_private::formatters::LibcxxQueueFrontEndCreator
SyntheticChildrenFrontEnd * LibcxxQueueFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
Definition: LibCxxQueue.cpp:60
lldb_private::formatters::LibcxxVariantFrontEndCreator
SyntheticChildrenFrontEnd * LibcxxVariantFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp)
Definition: LibCxxVariant.cpp:252
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::GetIndexOfChildWithName
size_t GetIndexOfChildWithName(ConstString name) override
Definition: LibCxx.cpp:704
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::GetChildAtIndex
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override
Definition: LibCxx.cpp:664
lldb_private::formatters::LibcxxUniquePointerSummaryProvider
bool LibcxxUniquePointerSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options)
Definition: LibCxx.cpp:161
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::formatters::LibcxxOptionalSyntheticFrontEndCreator
SyntheticChildrenFrontEnd * LibcxxOptionalSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp)
Definition: GenericOptional.cpp:133
lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::MightHaveChildren
bool MightHaveChildren() override
Definition: LibCxx.cpp:520
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::MightHaveChildren
bool MightHaveChildren() override
Definition: LibCxx.cpp:364
lldb_private::formatters::LibCxxVectorIteratorSyntheticFrontEndCreator
SyntheticChildrenFrontEnd * LibCxxVectorIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
Definition: LibCxx.cpp:550
Stream.h
lldb_private::formatters::LibcxxWStringViewSummaryProvider
bool LibcxxWStringViewSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options)
Definition: LibCxx.cpp:1061
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::CalculateNumChildren
size_t CalculateNumChildren() override
Definition: LibCxx.cpp:659
lldb_private::CXXSyntheticChildren
Definition: TypeSynthetic.h:358
lldb_private::formatters::LibcxxOptionalSummaryProvider
bool LibcxxOptionalSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options)
Definition: LibCxx.cpp:48
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd
Definition: LibCxx.h:165
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd
Definition: LibCxx.h:86
lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd
Formats libcxx's std::unordered_map iterators.
Definition: LibCxx.h:131
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::MightHaveChildren
bool MightHaveChildren() override
Definition: LibCxx.cpp:618
lldb_private::formatters::LibcxxTupleFrontEndCreator
SyntheticChildrenFrontEnd * LibcxxTupleFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
Definition: LibCxxTuple.cpp:88
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::LibCxxMapIteratorSyntheticFrontEnd
LibCxxMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
Definition: LibCxx.cpp:221