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