LLDB  mainline
LanguageRuntime.h
Go to the documentation of this file.
1 //===-- LanguageRuntime.h ---------------------------------------------------*-
2 // C++ -*-===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef liblldb_LanguageRuntime_h_
11 #define liblldb_LanguageRuntime_h_
12 
16 #include "lldb/Core/Value.h"
17 #include "lldb/Core/ValueObject.h"
20 #include "lldb/lldb-private.h"
21 #include "lldb/lldb-public.h"
22 
23 #include "clang/Basic/TargetOptions.h"
24 
25 namespace lldb_private {
26 
28 public:
29  ExceptionSearchFilter(const lldb::TargetSP &target_sp,
30  lldb::LanguageType language,
31  bool update_module_list = true);
32 
33  ~ExceptionSearchFilter() override = default;
34 
35  bool ModulePasses(const lldb::ModuleSP &module_sp) override;
36 
37  bool ModulePasses(const FileSpec &spec) override;
38 
39  void Search(Searcher &searcher) override;
40 
41  void GetDescription(Stream *s) override;
42 
43  static SearchFilter *
45  const StructuredData::Dictionary &data_dict,
46  Status &error);
47 
49 
50 protected:
53  lldb::SearchFilterSP m_filter_sp;
54 
55  lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override;
56 
58 };
59 
61 public:
62  ~LanguageRuntime() override;
63 
64  static LanguageRuntime *FindPlugin(Process *process,
65  lldb::LanguageType language);
66 
67  static void InitializeCommands(CommandObject *parent);
68 
69  virtual lldb::LanguageType GetLanguageType() const = 0;
70 
71  virtual bool GetObjectDescription(Stream &str, ValueObject &object) = 0;
72 
73  virtual bool GetObjectDescription(Stream &str, Value &value,
74  ExecutionContextScope *exe_scope) = 0;
75 
76  // this call should return true if it could set the name and/or the type
77  virtual bool GetDynamicTypeAndAddress(ValueObject &in_value,
78  lldb::DynamicValueType use_dynamic,
79  TypeAndOrName &class_type_or_name,
80  Address &address,
81  Value::ValueType &value_type) = 0;
82 
83  // This call should return a CompilerType given a generic type name and an
84  // ExecutionContextScope in which one can actually fetch any specialization
85  // information required.
87  ConstString abstract_type_name) {
88  return CompilerType();
89  }
90 
91  // This should be a fast test to determine whether it is likely that this
92  // value would have a dynamic type.
93  virtual bool CouldHaveDynamicValue(ValueObject &in_value) = 0;
94 
95  // The contract for GetDynamicTypeAndAddress() is to return a "bare-bones"
96  // dynamic type For instance, given a Base* pointer,
97  // GetDynamicTypeAndAddress() will return the type of Derived, not Derived*.
98  // The job of this API is to correct this misalignment between the static
99  // type and the discovered dynamic type
100  virtual TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name,
101  ValueObject &static_value) = 0;
102 
103  virtual void SetExceptionBreakpoints() {}
104 
105  virtual void ClearExceptionBreakpoints() {}
106 
107  virtual bool ExceptionBreakpointsAreSet() { return false; }
108 
109  virtual bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) {
110  return false;
111  }
112 
113  static lldb::BreakpointSP
114  CreateExceptionBreakpoint(Target &target, lldb::LanguageType language,
115  bool catch_bp, bool throw_bp,
116  bool is_internal = false);
117 
119  CreateExceptionPrecondition(lldb::LanguageType language, bool catch_bp,
120  bool throw_bp);
121 
122  virtual lldb::ValueObjectSP GetExceptionObjectForThread(
123  lldb::ThreadSP thread_sp) {
124  return lldb::ValueObjectSP();
125  }
126 
127  virtual lldb::ThreadSP GetBacktraceThreadFromException(
128  lldb::ValueObjectSP thread_sp) {
129  return lldb::ThreadSP();
130  }
131 
132  Process *GetProcess() { return m_process; }
133 
134  Target &GetTargetRef() { return m_process->GetTarget(); }
135 
136  virtual lldb::BreakpointResolverSP
137  CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp, bool throw_bp) = 0;
138 
139  virtual lldb::SearchFilterSP CreateExceptionSearchFilter();
140 
141  virtual bool GetTypeBitSize(const CompilerType &compiler_type,
142  uint64_t &size) {
143  return false;
144  }
145 
146  /// Identify whether a value is a language implementation detaul
147  /// that should be hidden from the user interface by default.
148  virtual bool IsRuntimeSupportValue(ValueObject &valobj) { return false; }
149 
150  virtual void ModulesDidLoad(const ModuleList &module_list) {}
151 
152  // Called by the Clang expression evaluation engine to allow runtimes to
153  // alter the set of target options provided to the compiler. If the options
154  // prototype is modified, runtimes must return true, false otherwise.
155  virtual bool GetOverrideExprOptions(clang::TargetOptions &prototype) {
156  return false;
157  }
158 
159  // Called by ClangExpressionParser::PrepareForExecution to query for any
160  // custom LLVM IR passes that need to be run before an expression is
161  // assembled and run.
162  virtual bool GetIRPasses(LLVMUserExpression::IRPasses &custom_passes) {
163  return false;
164  }
165 
166 protected:
167  // Classes that inherit from LanguageRuntime can see and modify these
168 
169  LanguageRuntime(Process *process);
171 
172 private:
173  DISALLOW_COPY_AND_ASSIGN(LanguageRuntime);
174 };
175 
176 } // namespace lldb_private
177 
178 #endif // liblldb_LanguageRuntime_h_
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
StructuredData::ObjectSP SerializeToStructuredData() override
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
Sometimes you can find the name of the type corresponding to an object, but we don't have debug infor...
Definition: Type.h:396
virtual void SetExceptionBreakpoints()
bool ModulePasses(const lldb::ModuleSP &module_sp) override
Call this method with a Module to see if that module passes the filter.
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
Definition: Breakpoint.h:78
virtual bool GetIRPasses(LLVMUserExpression::IRPasses &custom_passes)
A file utility class.
Definition: FileSpec.h:55
virtual CompilerType GetConcreteType(ExecutionContextScope *exe_scope, ConstString abstract_type_name)
ExceptionSearchFilter(const lldb::TargetSP &target_sp, lldb::LanguageType language, bool update_module_list=true)
virtual bool IsRuntimeSupportValue(ValueObject &valobj)
Identify whether a value is a language implementation detaul that should be hidden from the user inte...
virtual lldb::ValueObjectSP GetExceptionObjectForThread(lldb::ThreadSP thread_sp)
~ExceptionSearchFilter() override=default
LanguageType
Programming language type.
virtual bool GetOverrideExprOptions(clang::TargetOptions &prototype)
A collection class for Module objects.
Definition: ModuleList.h:91
virtual bool GetTypeBitSize(const CompilerType &compiler_type, uint64_t &size)
General Outline: Provides the callback and search depth for the SearchFilter search.
Definition: SearchFilter.h:101
General Outline: Provides the callback and search depth for the SearchFilter search.
Definition: SearchFilter.h:60
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
A plug-in interface definition class for debugging a process.
Definition: Process.h:353
virtual bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason)
A section + offset based address class.
Definition: Address.h:80
std::shared_ptr< BreakpointPrecondition > BreakpointPreconditionSP
Definition: Breakpoint.h:154
void Search(Searcher &searcher) override
Call this method to do the search using the Searcher.
A uniqued constant string class.
Definition: ConstString.h:38
lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override
static SearchFilter * CreateFromStructuredData(Target &target, const StructuredData::Dictionary &data_dict, Status &error)
std::shared_ptr< Object > ObjectSP
virtual void ClearExceptionBreakpoints()
virtual bool ExceptionBreakpointsAreSet()
void GetDescription(Stream *s) override
Prints a canonical description for the search filter to the stream s.
virtual lldb::ThreadSP GetBacktraceThreadFromException(lldb::ValueObjectSP thread_sp)
virtual void ModulesDidLoad(const ModuleList &module_list)
An error handling class.
Definition: Status.h:44