xref: /openbsd-src/gnu/llvm/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h (revision f6aab3d83b51b91c24247ad2c2573574de475a82)
1061da546Spatrick //===-- CPPLanguageRuntime.h
2061da546Spatrick //
3061da546Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4061da546Spatrick // See https://llvm.org/LICENSE.txt for license information.
5061da546Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6061da546Spatrick //
7061da546Spatrick //===----------------------------------------------------------------------===//
8061da546Spatrick 
9dda28197Spatrick #ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_CPLUSPLUS_CPPLANGUAGERUNTIME_H
10dda28197Spatrick #define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_CPLUSPLUS_CPPLANGUAGERUNTIME_H
11061da546Spatrick 
12061da546Spatrick #include <vector>
13061da546Spatrick 
14061da546Spatrick #include "llvm/ADT/StringMap.h"
15061da546Spatrick 
16061da546Spatrick #include "lldb/Core/PluginInterface.h"
17061da546Spatrick #include "lldb/Target/LanguageRuntime.h"
18061da546Spatrick #include "lldb/lldb-private.h"
19061da546Spatrick 
20061da546Spatrick namespace lldb_private {
21061da546Spatrick 
22061da546Spatrick class CPPLanguageRuntime : public LanguageRuntime {
23061da546Spatrick public:
24061da546Spatrick   enum class LibCppStdFunctionCallableCase {
25061da546Spatrick     Lambda = 0,
26061da546Spatrick     CallableObject,
27061da546Spatrick     FreeOrMemberFunction,
28061da546Spatrick     Invalid
29061da546Spatrick   };
30061da546Spatrick 
31061da546Spatrick   struct LibCppStdFunctionCallableInfo {
32061da546Spatrick     Symbol callable_symbol;
33061da546Spatrick     Address callable_address;
34061da546Spatrick     LineEntry callable_line_entry;
35*f6aab3d8Srobert     lldb::addr_t member_f_pointer_value = 0u;
36061da546Spatrick     LibCppStdFunctionCallableCase callable_case =
37061da546Spatrick         LibCppStdFunctionCallableCase::Invalid;
38061da546Spatrick   };
39061da546Spatrick 
40061da546Spatrick   LibCppStdFunctionCallableInfo
41061da546Spatrick   FindLibCppStdFunctionCallableInfo(lldb::ValueObjectSP &valobj_sp);
42061da546Spatrick 
43061da546Spatrick   static char ID;
44061da546Spatrick 
isA(const void * ClassID)45061da546Spatrick   bool isA(const void *ClassID) const override {
46061da546Spatrick     return ClassID == &ID || LanguageRuntime::isA(ClassID);
47061da546Spatrick   }
48061da546Spatrick 
classof(const LanguageRuntime * runtime)49061da546Spatrick   static bool classof(const LanguageRuntime *runtime) {
50061da546Spatrick     return runtime->isA(&ID);
51061da546Spatrick   }
52061da546Spatrick 
GetLanguageType()53061da546Spatrick   lldb::LanguageType GetLanguageType() const override {
54061da546Spatrick     return lldb::eLanguageTypeC_plus_plus;
55061da546Spatrick   }
56061da546Spatrick 
Get(Process & process)57061da546Spatrick   static CPPLanguageRuntime *Get(Process &process) {
58061da546Spatrick     return llvm::cast_or_null<CPPLanguageRuntime>(
59061da546Spatrick         process.GetLanguageRuntime(lldb::eLanguageTypeC_plus_plus));
60061da546Spatrick   }
61061da546Spatrick 
62061da546Spatrick   bool GetObjectDescription(Stream &str, ValueObject &object) override;
63061da546Spatrick 
64061da546Spatrick   bool GetObjectDescription(Stream &str, Value &value,
65061da546Spatrick                             ExecutionContextScope *exe_scope) override;
66061da546Spatrick 
67061da546Spatrick   /// Obtain a ThreadPlan to get us into C++ constructs such as std::function.
68061da546Spatrick   ///
69061da546Spatrick   /// \param[in] thread
70dda28197Spatrick   ///     Current thrad of execution.
71061da546Spatrick   ///
72061da546Spatrick   /// \param[in] stop_others
73061da546Spatrick   ///     True if other threads should pause during execution.
74061da546Spatrick   ///
75061da546Spatrick   /// \return
76061da546Spatrick   ///      A ThreadPlan Shared pointer
77061da546Spatrick   lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
78061da546Spatrick                                                   bool stop_others) override;
79061da546Spatrick 
80dda28197Spatrick   bool IsAllowedRuntimeValue(ConstString name) override;
81061da546Spatrick protected:
82061da546Spatrick   // Classes that inherit from CPPLanguageRuntime can see and modify these
83061da546Spatrick   CPPLanguageRuntime(Process *process);
84061da546Spatrick 
85061da546Spatrick private:
86061da546Spatrick   using OperatorStringToCallableInfoMap =
87061da546Spatrick     llvm::StringMap<CPPLanguageRuntime::LibCppStdFunctionCallableInfo>;
88061da546Spatrick 
89061da546Spatrick   OperatorStringToCallableInfoMap CallableLookupCache;
90061da546Spatrick };
91061da546Spatrick 
92061da546Spatrick } // namespace lldb_private
93061da546Spatrick 
94dda28197Spatrick #endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_CPLUSPLUS_CPPLANGUAGERUNTIME_H
95