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