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 LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCRUNTIME_H
10 #define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCRUNTIME_H
11 
12 #include "llvm/ADT/Optional.h"
13 
17 #include "lldb/lldb-private.h"
18 
20 
21 namespace lldb_private {
22 
24 public:
25  ~AppleObjCRuntime() override;
26 
27  // Static Functions
28  // Note there is no CreateInstance, Initialize & Terminate functions here,
29  // because
30  // you can't make an instance of this generic runtime.
31 
32  static char ID;
33 
34  static void Initialize();
35 
36  static void Terminate();
37 
38  bool isA(const void *ClassID) const override {
39  return ClassID == &ID || ObjCLanguageRuntime::isA(ClassID);
40  }
41 
42  static bool classof(const LanguageRuntime *runtime) {
43  return runtime->isA(&ID);
44  }
45 
46  // These are generic runtime functions:
47  bool GetObjectDescription(Stream &str, Value &value,
48  ExecutionContextScope *exe_scope) override;
49 
50  bool GetObjectDescription(Stream &str, ValueObject &object) override;
51 
52  bool CouldHaveDynamicValue(ValueObject &in_value) override;
53 
55  lldb::DynamicValueType use_dynamic,
56  TypeAndOrName &class_type_or_name,
57  Address &address,
58  Value::ValueType &value_type) override;
59 
60  TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name,
61  ValueObject &static_value) override;
62 
63  // These are the ObjC specific functions.
64 
65  bool IsModuleObjCLibrary(const lldb::ModuleSP &module_sp) override;
66 
67  bool ReadObjCLibrary(const lldb::ModuleSP &module_sp) override;
68 
69  bool HasReadObjCLibrary() override { return m_read_objc_library; }
70 
71  lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
72  bool stop_others) override;
73 
74  // Get the "libobjc.A.dylib" module from the current target if we can find
75  // it, also cache it once it is found to ensure quick lookups.
76  lldb::ModuleSP GetObjCModule();
77 
78  // Sync up with the target
79 
80  void ModulesDidLoad(const ModuleList &module_list) override;
81 
82  void SetExceptionBreakpoints() override;
83 
84  void ClearExceptionBreakpoints() override;
85 
86  bool ExceptionBreakpointsAreSet() override;
87 
88  bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override;
89 
90  lldb::SearchFilterSP CreateExceptionSearchFilter() override;
91 
92  static std::tuple<FileSpec, ConstString> GetExceptionThrowLocation();
93 
94  lldb::ValueObjectSP GetExceptionObjectForThread(
95  lldb::ThreadSP thread_sp) override;
96 
97  lldb::ThreadSP GetBacktraceThreadFromException(
98  lldb::ValueObjectSP thread_sp) override;
99 
101 
102  virtual void GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true,
103  lldb::addr_t &cf_false);
104 
105  virtual bool IsTaggedPointer (lldb::addr_t addr) { return false; }
106 
107 protected:
108  // Call CreateInstance instead.
109  AppleObjCRuntime(Process *process);
110 
111  bool CalculateHasNewLiteralsAndIndexing() override;
112 
113  static bool AppleIsModuleObjCLibrary(const lldb::ModuleSP &module_sp);
114 
116  lldb::ModuleSP &objc_module_sp);
117 
118  void ReadObjCLibraryIfNeeded(const ModuleList &module_list);
119 
121 
122  std::unique_ptr<Address> m_PrintForDebugger_addr;
124  std::unique_ptr<lldb_private::AppleObjCTrampolineHandler>
126  lldb::BreakpointSP m_objc_exception_bp_sp;
127  lldb::ModuleWP m_objc_module_wp;
128  std::unique_ptr<FunctionCaller> m_print_object_caller_up;
129 
130  llvm::Optional<uint32_t> m_Foundation_major;
131 };
132 
133 } // namespace lldb_private
134 
135 #endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCRUNTIME_H
bool GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic, TypeAndOrName &class_type_or_name, Address &address, Value::ValueType &value_type) override
A class that represents a running process on the host machine.
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:381
virtual void GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true, lldb::addr_t &cf_false)
virtual bool isA(const void *ClassID) const
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:71
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:362
bool CouldHaveDynamicValue(ValueObject &in_value) override
A section + offset based address class.
Definition: Address.h:59
void ReadObjCLibraryIfNeeded(const ModuleList &module_list)
bool IsModuleObjCLibrary(const lldb::ModuleSP &module_sp) override
lldb::ThreadSP GetBacktraceThreadFromException(lldb::ValueObjectSP thread_sp) override
bool isA(const void *ClassID) const 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 LanguageRuntime *runtime)
lldb::SearchFilterSP CreateExceptionSearchFilter() override
bool isA(const void *ClassID) const override
static ObjCRuntimeVersions GetObjCVersion(Process *process, lldb::ModuleSP &objc_module_sp)
bool CalculateHasNewLiteralsAndIndexing() override