LLDB  mainline
AppleObjCRuntime.h
Go to the documentation of this file.
1 //===-- AppleObjCRuntime.h --------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef liblldb_AppleObjCRuntime_h_
10 #define liblldb_AppleObjCRuntime_h_
11 
12 #include "llvm/ADT/Optional.h"
13 
18 #include "lldb/lldb-private.h"
19 
20 namespace lldb_private {
21 
23 public:
24  ~AppleObjCRuntime() override;
25 
26  // Static Functions
27  // Note there is no CreateInstance, Initialize & Terminate functions here,
28  // because
29  // you can't make an instance of this generic runtime.
30 
31  static bool classof(const ObjCLanguageRuntime *runtime) {
32  switch (runtime->GetRuntimeVersion()) {
35  return true;
36  default:
37  return false;
38  }
39  }
40 
41  // These are generic runtime functions:
42  bool GetObjectDescription(Stream &str, Value &value,
43  ExecutionContextScope *exe_scope) override;
44 
45  bool GetObjectDescription(Stream &str, ValueObject &object) override;
46 
47  bool CouldHaveDynamicValue(ValueObject &in_value) override;
48 
50  lldb::DynamicValueType use_dynamic,
51  TypeAndOrName &class_type_or_name,
52  Address &address,
53  Value::ValueType &value_type) override;
54 
55  TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name,
56  ValueObject &static_value) override;
57 
58  // These are the ObjC specific functions.
59 
60  bool IsModuleObjCLibrary(const lldb::ModuleSP &module_sp) override;
61 
62  bool ReadObjCLibrary(const lldb::ModuleSP &module_sp) override;
63 
64  bool HasReadObjCLibrary() override { return m_read_objc_library; }
65 
66  lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
67  bool stop_others) override;
68 
69  // Get the "libobjc.A.dylib" module from the current target if we can find
70  // it, also cache it once it is found to ensure quick lookups.
71  lldb::ModuleSP GetObjCModule();
72 
73  // Sync up with the target
74 
75  void ModulesDidLoad(const ModuleList &module_list) override;
76 
77  void SetExceptionBreakpoints() override;
78 
79  void ClearExceptionBreakpoints() override;
80 
81  bool ExceptionBreakpointsAreSet() override;
82 
83  bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override;
84 
85  lldb::SearchFilterSP CreateExceptionSearchFilter() override;
86 
87  static std::tuple<FileSpec, ConstString> GetExceptionThrowLocation();
88 
89  lldb::ValueObjectSP GetExceptionObjectForThread(
90  lldb::ThreadSP thread_sp) override;
91 
92  lldb::ThreadSP GetBacktraceThreadFromException(
93  lldb::ValueObjectSP thread_sp) override;
94 
96 
97  virtual void GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true,
98  lldb::addr_t &cf_false);
99 
100  virtual bool IsTaggedPointer (lldb::addr_t addr) { return false; }
101 
102 protected:
103  // Call CreateInstance instead.
104  AppleObjCRuntime(Process *process);
105 
106  bool CalculateHasNewLiteralsAndIndexing() override;
107 
108  static bool AppleIsModuleObjCLibrary(const lldb::ModuleSP &module_sp);
109 
111  lldb::ModuleSP &objc_module_sp);
112 
113  void ReadObjCLibraryIfNeeded(const ModuleList &module_list);
114 
116 
117  std::unique_ptr<Address> m_PrintForDebugger_addr;
119  std::unique_ptr<lldb_private::AppleObjCTrampolineHandler>
121  lldb::BreakpointSP m_objc_exception_bp_sp;
122  lldb::ModuleWP m_objc_module_wp;
123  std::unique_ptr<FunctionCaller> m_print_object_caller_up;
124 
125  llvm::Optional<uint32_t> m_Foundation_major;
126 };
127 
128 } // namespace lldb_private
129 
130 #endif // liblldb_AppleObjCRuntime_h_
bool GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic, TypeAndOrName &class_type_or_name, Address &address, Value::ValueType &value_type) override
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
void ModulesDidLoad(const ModuleList &module_list) 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:396
virtual void GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true, lldb::addr_t &cf_false)
bool GetObjectDescription(Stream &str, Value &value, ExecutionContextScope *exe_scope) override
std::unique_ptr< FunctionCaller > m_print_object_caller_up
bool ReadObjCLibrary(const lldb::ModuleSP &module_sp) override
static std::tuple< FileSpec, ConstString > GetExceptionThrowLocation()
bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override
lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, bool stop_others) override
TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name, ValueObject &static_value) override
A collection class for Module objects.
Definition: ModuleList.h:91
virtual bool IsTaggedPointer(lldb::addr_t addr)
llvm::Optional< uint32_t > m_Foundation_major
lldb::ValueObjectSP GetExceptionObjectForThread(lldb::ThreadSP thread_sp) override
"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
bool CouldHaveDynamicValue(ValueObject &in_value) override
A section + offset based address class.
Definition: Address.h:80
void ReadObjCLibraryIfNeeded(const ModuleList &module_list)
bool IsModuleObjCLibrary(const lldb::ModuleSP &module_sp) override
lldb::ThreadSP GetBacktraceThreadFromException(lldb::ValueObjectSP thread_sp) override
uint64_t addr_t
Definition: lldb-types.h:83
lldb::BreakpointSP m_objc_exception_bp_sp
static bool AppleIsModuleObjCLibrary(const lldb::ModuleSP &module_sp)
std::unique_ptr< Address > m_PrintForDebugger_addr
std::unique_ptr< lldb_private::AppleObjCTrampolineHandler > m_objc_trampoline_handler_up
static bool classof(const ObjCLanguageRuntime *runtime)
lldb::SearchFilterSP CreateExceptionSearchFilter() override
virtual ObjCRuntimeVersions GetRuntimeVersion() const
static ObjCRuntimeVersions GetObjCVersion(Process *process, lldb::ModuleSP &objc_module_sp)
bool CalculateHasNewLiteralsAndIndexing() override