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 LLDB_TARGET_LANGUAGERUNTIME_H
11 #define LLDB_TARGET_LANGUAGERUNTIME_H
12 
16 #include "lldb/Core/Value.h"
17 #include "lldb/Core/ValueObject.h"
19 #include "lldb/Symbol/DeclVendor.h"
21 #include "lldb/lldb-private.h"
22 #include "lldb/lldb-public.h"
23 
24 namespace lldb_private {
25 
27 public:
28  ExceptionSearchFilter(const lldb::TargetSP &target_sp,
29  lldb::LanguageType language,
30  bool update_module_list = true);
31 
32  ~ExceptionSearchFilter() override = default;
33 
34  bool ModulePasses(const lldb::ModuleSP &module_sp) override;
35 
36  bool ModulePasses(const FileSpec &spec) override;
37 
38  void Search(Searcher &searcher) override;
39 
40  void GetDescription(Stream *s) override;
41 
42  static SearchFilter *
44  const StructuredData::Dictionary &data_dict,
45  Status &error);
46 
48 
49 protected:
52  lldb::SearchFilterSP m_filter_sp;
53 
54  lldb::SearchFilterSP DoCreateCopy() override;
55 
57 };
58 
60 public:
61  ~LanguageRuntime() override;
62 
63  static LanguageRuntime *FindPlugin(Process *process,
64  lldb::LanguageType language);
65 
66  static void InitializeCommands(CommandObject *parent);
67 
68  virtual lldb::LanguageType GetLanguageType() const = 0;
69 
70  virtual bool GetObjectDescription(Stream &str, ValueObject &object) = 0;
71 
72  virtual bool GetObjectDescription(Stream &str, Value &value,
73  ExecutionContextScope *exe_scope) = 0;
74 
75  // this call should return true if it could set the name and/or the type
76  virtual bool GetDynamicTypeAndAddress(ValueObject &in_value,
77  lldb::DynamicValueType use_dynamic,
78  TypeAndOrName &class_type_or_name,
79  Address &address,
80  Value::ValueType &value_type) = 0;
81 
82  // This call should return a CompilerType given a generic type name and an
83  // ExecutionContextScope in which one can actually fetch any specialization
84  // information required.
86  ConstString abstract_type_name) {
87  return CompilerType();
88  }
89 
90  // This should be a fast test to determine whether it is likely that this
91  // value would have a dynamic type.
92  virtual bool CouldHaveDynamicValue(ValueObject &in_value) = 0;
93 
94  // The contract for GetDynamicTypeAndAddress() is to return a "bare-bones"
95  // dynamic type For instance, given a Base* pointer,
96  // GetDynamicTypeAndAddress() will return the type of Derived, not Derived*.
97  // The job of this API is to correct this misalignment between the static
98  // type and the discovered dynamic type
99  virtual TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name,
100  ValueObject &static_value) = 0;
101 
102  virtual void SetExceptionBreakpoints() {}
103 
104  virtual void ClearExceptionBreakpoints() {}
105 
106  virtual bool ExceptionBreakpointsAreSet() { return false; }
107 
108  virtual bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) {
109  return false;
110  }
111 
112  static lldb::BreakpointSP
113  CreateExceptionBreakpoint(Target &target, lldb::LanguageType language,
114  bool catch_bp, bool throw_bp,
115  bool is_internal = false);
116 
117  static lldb::BreakpointPreconditionSP
118  GetExceptionPrecondition(lldb::LanguageType language, bool throw_bp);
119 
120  virtual lldb::ValueObjectSP GetExceptionObjectForThread(
121  lldb::ThreadSP thread_sp) {
122  return lldb::ValueObjectSP();
123  }
124 
125  virtual lldb::ThreadSP GetBacktraceThreadFromException(
126  lldb::ValueObjectSP thread_sp) {
127  return lldb::ThreadSP();
128  }
129 
130  Process *GetProcess() { return m_process; }
131 
132  Target &GetTargetRef() { return m_process->GetTarget(); }
133 
134  virtual DeclVendor *GetDeclVendor() { return nullptr; }
135 
136  virtual lldb::BreakpointResolverSP
137  CreateExceptionResolver(const lldb::BreakpointSP &bkpt,
138  bool catch_bp, bool throw_bp) = 0;
139 
140  virtual lldb::SearchFilterSP CreateExceptionSearchFilter() {
141  return m_process->GetTarget().GetSearchFilterForModule(nullptr);
142  }
143 
144  virtual bool GetTypeBitSize(const CompilerType &compiler_type,
145  uint64_t &size) {
146  return false;
147  }
148 
149  virtual void SymbolsDidLoad(const ModuleList &module_list) { return; }
150 
151  virtual lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
152  bool stop_others) = 0;
153 
154  /// Identify whether a name is a runtime value that should not be hidden by
155  /// from the user interface.
156  virtual bool IsAllowedRuntimeValue(ConstString name) { return false; }
157 
158  virtual llvm::Optional<CompilerType> GetRuntimeType(CompilerType base_type) {
159  return llvm::None;
160  }
161 
162  virtual void ModulesDidLoad(const ModuleList &module_list) {}
163 
164  // Called by ClangExpressionParser::PrepareForExecution to query for any
165  // custom LLVM IR passes that need to be run before an expression is
166  // assembled and run.
167  virtual bool GetIRPasses(LLVMUserExpression::IRPasses &custom_passes) {
168  return false;
169  }
170 
171  // Given the name of a runtime symbol (e.g. in Objective-C, an ivar offset
172  // symbol), try to determine from the runtime what the value of that symbol
173  // would be. Useful when the underlying binary is stripped.
175  return LLDB_INVALID_ADDRESS;
176  }
177 
178  virtual bool isA(const void *ClassID) const { return ClassID == &ID; }
179  static char ID;
180 
181 protected:
182  // Classes that inherit from LanguageRuntime can see and modify these
183 
184  LanguageRuntime(Process *process);
186 
187 private:
188  LanguageRuntime(const LanguageRuntime &) = delete;
189  const LanguageRuntime &operator=(const LanguageRuntime &) = delete;
190 };
191 
192 } // namespace lldb_private
193 
194 #endif // LLDB_TARGET_LANGUAGERUNTIME_H
lldb::SearchFilterSP DoCreateCopy() override
A class that represents a running process on the host machine.
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&#39;t have debug infor...
Definition: Type.h:381
virtual llvm::Optional< CompilerType > GetRuntimeType(CompilerType base_type)
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.
virtual bool isA(const void *ClassID) const
virtual bool GetIRPasses(LLVMUserExpression::IRPasses &custom_passes)
A file utility class.
Definition: FileSpec.h:56
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 lldb::ValueObjectSP GetExceptionObjectForThread(lldb::ThreadSP thread_sp)
~ExceptionSearchFilter() override=default
virtual DeclVendor * GetDeclVendor()
#define LLDB_INVALID_ADDRESS
Invalid value definitions.
Definition: lldb-defines.h:85
LanguageType
Programming language type.
static llvm::raw_ostream & error(Stream &strm)
A collection class for Module objects.
Definition: ModuleList.h:71
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:83
General Outline: Provides the callback and search depth for the SearchFilter search.
Definition: SearchFilter.h:42
"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:362
virtual bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason)
static char ID
A section + offset based address class.
Definition: Address.h:59
virtual bool IsAllowedRuntimeValue(ConstString name)
Identify whether a name is a runtime value that should not be hidden by from the user interface...
void Search(Searcher &searcher) override
Call this method to do the search using the Searcher.
uint64_t addr_t
Definition: lldb-types.h:83
A uniqued constant string class.
Definition: ConstString.h:40
virtual lldb::addr_t LookupRuntimeSymbol(ConstString name)
Represents a generic type in a programming language.
Definition: CompilerType.h:33
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::SearchFilterSP CreateExceptionSearchFilter()
virtual lldb::ThreadSP GetBacktraceThreadFromException(lldb::ValueObjectSP thread_sp)
virtual void SymbolsDidLoad(const ModuleList &module_list)
virtual void ModulesDidLoad(const ModuleList &module_list)
An error handling class.
Definition: Status.h:44