| 1 | //===-- CPPLanguageRuntime.h |
|---|---|
| 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_LANGUAGERUNTIME_CPLUSPLUS_CPPLANGUAGERUNTIME_H |
| 10 | #define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_CPLUSPLUS_CPPLANGUAGERUNTIME_H |
| 11 | |
| 12 | #include <vector> |
| 13 | |
| 14 | #include "llvm/ADT/StringMap.h" |
| 15 | |
| 16 | #include "lldb/Core/PluginInterface.h" |
| 17 | #include "lldb/Target/LanguageRuntime.h" |
| 18 | #include "lldb/lldb-private.h" |
| 19 | |
| 20 | namespace lldb_private { |
| 21 | |
| 22 | class CPPLanguageRuntime : public LanguageRuntime { |
| 23 | public: |
| 24 | enum class LibCppStdFunctionCallableCase { |
| 25 | Lambda = 0, |
| 26 | CallableObject, |
| 27 | FreeOrMemberFunction, |
| 28 | Invalid |
| 29 | }; |
| 30 | |
| 31 | struct LibCppStdFunctionCallableInfo { |
| 32 | Symbol callable_symbol; |
| 33 | Address callable_address; |
| 34 | LineEntry callable_line_entry; |
| 35 | lldb::addr_t member_f_pointer_value = 0u; |
| 36 | LibCppStdFunctionCallableCase callable_case = |
| 37 | LibCppStdFunctionCallableCase::Invalid; |
| 38 | }; |
| 39 | |
| 40 | LibCppStdFunctionCallableInfo |
| 41 | FindLibCppStdFunctionCallableInfo(lldb::ValueObjectSP &valobj_sp); |
| 42 | |
| 43 | static char ID; |
| 44 | |
| 45 | bool isA(const void *ClassID) const override { |
| 46 | return ClassID == &ID || LanguageRuntime::isA(ClassID); |
| 47 | } |
| 48 | |
| 49 | static bool classof(const LanguageRuntime *runtime) { |
| 50 | return runtime->isA(ClassID: &ID); |
| 51 | } |
| 52 | |
| 53 | lldb::LanguageType GetLanguageType() const override { |
| 54 | return lldb::eLanguageTypeC_plus_plus; |
| 55 | } |
| 56 | |
| 57 | static CPPLanguageRuntime *Get(Process &process) { |
| 58 | return llvm::cast_or_null<CPPLanguageRuntime>( |
| 59 | Val: process.GetLanguageRuntime(language: lldb::eLanguageTypeC_plus_plus)); |
| 60 | } |
| 61 | |
| 62 | llvm::Error GetObjectDescription(Stream &str, ValueObject &object) override; |
| 63 | |
| 64 | llvm::Error GetObjectDescription(Stream &str, Value &value, |
| 65 | ExecutionContextScope *exe_scope) override; |
| 66 | |
| 67 | /// Obtain a ThreadPlan to get us into C++ constructs such as std::function. |
| 68 | /// |
| 69 | /// \param[in] thread |
| 70 | /// Current thrad of execution. |
| 71 | /// |
| 72 | /// \param[in] stop_others |
| 73 | /// True if other threads should pause during execution. |
| 74 | /// |
| 75 | /// \return |
| 76 | /// A ThreadPlan Shared pointer |
| 77 | lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, |
| 78 | bool stop_others) override; |
| 79 | |
| 80 | bool IsAllowedRuntimeValue(ConstString name) override; |
| 81 | |
| 82 | bool IsSymbolARuntimeThunk(const Symbol &symbol) override; |
| 83 | |
| 84 | protected: |
| 85 | // Classes that inherit from CPPLanguageRuntime can see and modify these |
| 86 | CPPLanguageRuntime(Process *process); |
| 87 | |
| 88 | private: |
| 89 | using OperatorStringToCallableInfoMap = |
| 90 | llvm::StringMap<CPPLanguageRuntime::LibCppStdFunctionCallableInfo>; |
| 91 | |
| 92 | OperatorStringToCallableInfoMap CallableLookupCache; |
| 93 | }; |
| 94 | |
| 95 | } // namespace lldb_private |
| 96 | |
| 97 | #endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_CPLUSPLUS_CPPLANGUAGERUNTIME_H |
| 98 |
