]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Target/LanguageRuntime.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Target / LanguageRuntime.h
1 //===-- LanguageRuntime.h ---------------------------------------------------*-
2 // C++ -*-===//
3 //
4 //                     The LLVM Compiler Infrastructure
5 //
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10
11 #ifndef liblldb_LanguageRuntime_h_
12 #define liblldb_LanguageRuntime_h_
13
14 #include "lldb/Breakpoint/BreakpointResolver.h"
15 #include "lldb/Breakpoint/BreakpointResolverName.h"
16 #include "lldb/Core/PluginInterface.h"
17 #include "lldb/Core/Value.h"
18 #include "lldb/Core/ValueObject.h"
19 #include "lldb/Expression/LLVMUserExpression.h"
20 #include "lldb/Target/ExecutionContextScope.h"
21 #include "lldb/lldb-private.h"
22 #include "lldb/lldb-public.h"
23
24 #include "clang/Basic/TargetOptions.h"
25
26 namespace lldb_private {
27
28 class ExceptionSearchFilter : public SearchFilter {
29 public:
30   ExceptionSearchFilter(const lldb::TargetSP &target_sp,
31                         lldb::LanguageType language,
32                         bool update_module_list = true);
33
34   ~ExceptionSearchFilter() override = default;
35
36   bool ModulePasses(const lldb::ModuleSP &module_sp) override;
37
38   bool ModulePasses(const FileSpec &spec) override;
39
40   void Search(Searcher &searcher) override;
41
42   void GetDescription(Stream *s) override;
43
44   static SearchFilter *
45   CreateFromStructuredData(Target &target,
46                            const StructuredData::Dictionary &data_dict,
47                            Status &error);
48
49   StructuredData::ObjectSP SerializeToStructuredData() override;
50
51 protected:
52   lldb::LanguageType m_language;
53   LanguageRuntime *m_language_runtime;
54   lldb::SearchFilterSP m_filter_sp;
55
56   lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override;
57
58   void UpdateModuleListIfNeeded();
59 };
60
61 class LanguageRuntime : public PluginInterface {
62 public:
63   ~LanguageRuntime() override;
64
65   static LanguageRuntime *FindPlugin(Process *process,
66                                      lldb::LanguageType language);
67
68   static void InitializeCommands(CommandObject *parent);
69
70   virtual lldb::LanguageType GetLanguageType() const = 0;
71
72   virtual bool GetObjectDescription(Stream &str, ValueObject &object) = 0;
73
74   virtual bool GetObjectDescription(Stream &str, Value &value,
75                                     ExecutionContextScope *exe_scope) = 0;
76
77   // this call should return true if it could set the name and/or the type
78   virtual bool GetDynamicTypeAndAddress(ValueObject &in_value,
79                                         lldb::DynamicValueType use_dynamic,
80                                         TypeAndOrName &class_type_or_name,
81                                         Address &address,
82                                         Value::ValueType &value_type) = 0;
83
84   // This call should return a CompilerType given a generic type name and an
85   // ExecutionContextScope in which one can actually fetch any specialization
86   // information required.
87   virtual CompilerType GetConcreteType(ExecutionContextScope *exe_scope,
88                                        ConstString abstract_type_name) {
89     return CompilerType();
90   }
91
92   // This should be a fast test to determine whether it is likely that this
93   // value would have a dynamic type.
94   virtual bool CouldHaveDynamicValue(ValueObject &in_value) = 0;
95
96   // The contract for GetDynamicTypeAndAddress() is to return a "bare-bones"
97   // dynamic type For instance, given a Base* pointer,
98   // GetDynamicTypeAndAddress() will return the type of Derived, not Derived*.
99   // The job of this API is to correct this misalignment between the static
100   // type and the discovered dynamic type
101   virtual TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name,
102                                          ValueObject &static_value) = 0;
103
104   virtual void SetExceptionBreakpoints() {}
105
106   virtual void ClearExceptionBreakpoints() {}
107
108   virtual bool ExceptionBreakpointsAreSet() { return false; }
109
110   virtual bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) {
111     return false;
112   }
113
114   static lldb::BreakpointSP
115   CreateExceptionBreakpoint(Target &target, lldb::LanguageType language,
116                             bool catch_bp, bool throw_bp,
117                             bool is_internal = false);
118
119   static Breakpoint::BreakpointPreconditionSP
120   CreateExceptionPrecondition(lldb::LanguageType language, bool catch_bp,
121                               bool throw_bp);
122
123   virtual lldb::ValueObjectSP GetExceptionObjectForThread(
124       lldb::ThreadSP thread_sp) {
125     return lldb::ValueObjectSP();
126   }
127
128   virtual lldb::ThreadSP GetBacktraceThreadFromException(
129       lldb::ValueObjectSP thread_sp) {
130     return lldb::ThreadSP();
131   }
132
133   Process *GetProcess() { return m_process; }
134
135   Target &GetTargetRef() { return m_process->GetTarget(); }
136
137   virtual lldb::BreakpointResolverSP
138   CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp, bool throw_bp) = 0;
139
140   virtual lldb::SearchFilterSP CreateExceptionSearchFilter();
141
142   virtual bool GetTypeBitSize(const CompilerType &compiler_type,
143                               uint64_t &size) {
144     return false;
145   }
146
147   virtual bool IsRuntimeSupportValue(ValueObject &valobj) { return false; }
148
149   virtual void ModulesDidLoad(const ModuleList &module_list) {}
150
151   // Called by the Clang expression evaluation engine to allow runtimes to
152   // alter the set of target options provided to the compiler. If the options
153   // prototype is modified, runtimes must return true, false otherwise.
154   virtual bool GetOverrideExprOptions(clang::TargetOptions &prototype) {
155     return false;
156   }
157
158   // Called by ClangExpressionParser::PrepareForExecution to query for any
159   // custom LLVM IR passes that need to be run before an expression is
160   // assembled and run.
161   virtual bool GetIRPasses(LLVMUserExpression::IRPasses &custom_passes) {
162     return false;
163   }
164
165 protected:
166   //------------------------------------------------------------------
167   // Classes that inherit from LanguageRuntime can see and modify these
168   //------------------------------------------------------------------
169
170   LanguageRuntime(Process *process);
171   Process *m_process;
172
173 private:
174   DISALLOW_COPY_AND_ASSIGN(LanguageRuntime);
175 };
176
177 } // namespace lldb_private
178
179 #endif // liblldb_LanguageRuntime_h_