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