1 | //===-- Coroutines.h --------------------------------------------*- C++ -*-===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_COROUTINES_H |
10 | #define LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_COROUTINES_H |
11 | |
12 | #include "lldb/Core/ValueObject.h" |
13 | #include "lldb/DataFormatters/TypeSummary.h" |
14 | #include "lldb/DataFormatters/TypeSynthetic.h" |
15 | #include "lldb/Utility/Stream.h" |
16 | |
17 | namespace lldb_private { |
18 | |
19 | namespace formatters { |
20 | |
21 | /// Summary provider for `std::coroutine_handle<T>` from libc++, libstdc++ and |
22 | /// MSVC STL. |
23 | bool StdlibCoroutineHandleSummaryProvider(ValueObject &valobj, Stream &stream, |
24 | const TypeSummaryOptions &options); |
25 | |
26 | /// Synthetic children frontend for `std::coroutine_handle<promise_type>` from |
27 | /// libc++, libstdc++ and MSVC STL. Shows the compiler-generated `resume` and |
28 | /// `destroy` function pointers as well as the `promise`, if the promise type |
29 | /// is `promise_type != void`. |
30 | class StdlibCoroutineHandleSyntheticFrontEnd |
31 | : public SyntheticChildrenFrontEnd { |
32 | public: |
33 | StdlibCoroutineHandleSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); |
34 | |
35 | ~StdlibCoroutineHandleSyntheticFrontEnd() override; |
36 | |
37 | llvm::Expected<uint32_t> CalculateNumChildren() override; |
38 | |
39 | lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; |
40 | |
41 | lldb::ChildCacheState Update() override; |
42 | |
43 | bool MightHaveChildren() override; |
44 | |
45 | size_t GetIndexOfChildWithName(ConstString name) override; |
46 | |
47 | private: |
48 | lldb::ValueObjectSP m_resume_ptr_sp; |
49 | lldb::ValueObjectSP m_destroy_ptr_sp; |
50 | lldb::ValueObjectSP m_promise_ptr_sp; |
51 | }; |
52 | |
53 | SyntheticChildrenFrontEnd * |
54 | StdlibCoroutineHandleSyntheticFrontEndCreator(CXXSyntheticChildren *, |
55 | lldb::ValueObjectSP); |
56 | |
57 | } // namespace formatters |
58 | } // namespace lldb_private |
59 | |
60 | #endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_COROUTINES_H |
61 | |