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
lldb_private::AppleObjCRuntime::isA
bool isA(const void *ClassID) const override
Definition: AppleObjCRuntime.h:38
lldb_private::AppleObjCRuntime::Terminate
static void Terminate()
Definition: AppleObjCRuntime.cpp:64
lldb_private::AppleObjCRuntime::GetPrintForDebuggerAddr
Address * GetPrintForDebuggerAddr()
Definition: AppleObjCRuntime.cpp:236
lldb_private::ObjCLanguageRuntime
Definition: ObjCLanguageRuntime.h:34
lldb_private::AppleObjCRuntime::IsTaggedPointer
virtual bool IsTaggedPointer(lldb::addr_t addr)
Definition: AppleObjCRuntime.h:105
lldb_private::Value
Definition: Value.h:38
lldb_private::AppleObjCRuntime::GetDynamicTypeAndAddress
bool GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic, TypeAndOrName &class_type_or_name, Address &address, Value::ValueType &value_type) override
Definition: AppleObjCRuntime.cpp:268
lldb_private::AppleObjCRuntime::ReadObjCLibraryIfNeeded
void ReadObjCLibraryIfNeeded(const ModuleList &module_list)
Definition: AppleObjCRuntime.cpp:608
lldb_private::AppleObjCRuntime::SetExceptionBreakpoints
void SetExceptionBreakpoints() override
Definition: AppleObjCRuntime.cpp:409
lldb_private::Process
Definition: Process.h:340
lldb_private::AppleObjCRuntime::m_objc_exception_bp_sp
lldb::BreakpointSP m_objc_exception_bp_sp
Definition: AppleObjCRuntime.h:126
lldb_private::Stream
Definition: Stream.h:28
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::LanguageRuntime::isA
virtual bool isA(const void *ClassID) const
Definition: LanguageRuntime.h:173
lldb_private::AppleObjCRuntime::GetExceptionObjectForThread
lldb::ValueObjectSP GetExceptionObjectForThread(lldb::ThreadSP thread_sp) override
Definition: AppleObjCRuntime.cpp:481
lldb_private::AppleObjCRuntime::m_Foundation_major
llvm::Optional< uint32_t > m_Foundation_major
Definition: AppleObjCRuntime.h:130
lldb_private::AppleObjCRuntime::m_print_object_caller_up
std::unique_ptr< FunctionCaller > m_print_object_caller_up
Definition: AppleObjCRuntime.h:128
lldb_private::AppleObjCRuntime::ID
static char ID
Definition: AppleObjCRuntime.h:32
lldb_private::AppleObjCRuntime::m_objc_module_wp
lldb::ModuleWP m_objc_module_wp
Definition: AppleObjCRuntime.h:127
lldb_private::AppleObjCRuntime::GetBacktraceThreadFromException
lldb::ThreadSP GetBacktraceThreadFromException(lldb::ValueObjectSP thread_sp) override
Definition: AppleObjCRuntime.cpp:512
lldb_private::AppleObjCRuntime::GetObjectDescription
bool GetObjectDescription(Stream &str, Value &value, ExecutionContextScope *exe_scope) override
Definition: AppleObjCRuntime.cpp:97
lldb_private::AppleObjCRuntime::AppleObjCRuntime
AppleObjCRuntime(Process *process)
Definition: AppleObjCRuntime.cpp:53
lldb_private::ModuleList
Definition: ModuleList.h:72
lldb_private::ExecutionContextScope
Definition: ExecutionContextScope.h:32
lldb_private::ObjCLanguageRuntime::isA
bool isA(const void *ClassID) const override
Definition: ObjCLanguageRuntime.h:205
lldb_private::AppleObjCRuntime::GetObjCVersion
static ObjCRuntimeVersions GetObjCVersion(Process *process, lldb::ModuleSP &objc_module_sp)
Definition: AppleObjCRuntime.cpp:371
lldb_private::Thread
Definition: Thread.h:60
AppleThreadPlanStepThroughObjCTrampoline.h
lldb_private::AppleObjCRuntime::CouldHaveDynamicValue
bool CouldHaveDynamicValue(ValueObject &in_value) override
Definition: AppleObjCRuntime.cpp:261
lldb_private::AppleObjCRuntime::GetStepThroughTrampolinePlan
lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, bool stop_others) override
Definition: AppleObjCRuntime.cpp:360
lldb_private::AppleObjCRuntime::CalculateHasNewLiteralsAndIndexing
bool CalculateHasNewLiteralsAndIndexing() override
Definition: AppleObjCRuntime.cpp:450
lldb_private::Value::ValueType
ValueType
Type that describes Value::m_value.
Definition: Value.h:41
lldb_private::ObjCLanguageRuntime::ObjCRuntimeVersions
ObjCRuntimeVersions
Definition: ObjCLanguageRuntime.h:36
lldb_private::AppleObjCRuntime
Definition: AppleObjCRuntime.h:23
lldb_private::AppleObjCRuntime::Initialize
static void Initialize()
Definition: AppleObjCRuntime.cpp:59
lldb_private::AppleObjCRuntime::GetObjCModule
lldb::ModuleSP GetObjCModule()
Definition: AppleObjCRuntime.cpp:217
lldb::DynamicValueType
DynamicValueType
Definition: lldb-enumerations.h:494
lldb_private::LanguageRuntime
Definition: LanguageRuntime.h:60
lldb_private::AppleObjCRuntime::IsModuleObjCLibrary
bool IsModuleObjCLibrary(const lldb::ModuleSP &module_sp) override
Definition: AppleObjCRuntime.cpp:343
lldb_private::AppleObjCRuntime::GetExceptionThrowLocation
static std::tuple< FileSpec, ConstString > GetExceptionThrowLocation()
Definition: AppleObjCRuntime.cpp:603
lldb_private::AppleObjCRuntime::HasReadObjCLibrary
bool HasReadObjCLibrary() override
Definition: AppleObjCRuntime.h:69
lldb_private::AppleObjCRuntime::ExceptionBreakpointsExplainStop
bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override
Definition: AppleObjCRuntime.cpp:437
lldb_private::AppleObjCRuntime::FixUpDynamicType
TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name, ValueObject &static_value) override
Definition: AppleObjCRuntime.cpp:276
lldb_private::AppleObjCRuntime::classof
static bool classof(const LanguageRuntime *runtime)
Definition: AppleObjCRuntime.h:42
lldb_private::AppleObjCRuntime::GetValuesForGlobalCFBooleans
virtual void GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true, lldb::addr_t &cf_false)
Definition: AppleObjCRuntime.cpp:338
lldb-private.h
lldb_private::AppleObjCRuntime::~AppleObjCRuntime
~AppleObjCRuntime() override
lldb_private::AppleObjCRuntime::ModulesDidLoad
void ModulesDidLoad(const ModuleList &module_list) override
Called when modules have been loaded in the process.
Definition: AppleObjCRuntime.cpp:623
lldb_private::ValueObject
ValueObject:
Definition: ValueObject.h:105
lldb_private::AppleObjCRuntime::m_PrintForDebugger_addr
std::unique_ptr< Address > m_PrintForDebugger_addr
Definition: AppleObjCRuntime.h:122
uint32_t
lldb_private::AppleObjCRuntime::CreateExceptionSearchFilter
lldb::SearchFilterSP CreateExceptionSearchFilter() override
Definition: AppleObjCRuntime.cpp:471
lldb_private::Address
Definition: Address.h:59
lldb_private::AppleObjCRuntime::m_objc_trampoline_handler_up
std::unique_ptr< lldb_private::AppleObjCTrampolineHandler > m_objc_trampoline_handler_up
Definition: AppleObjCRuntime.h:125
lldb_private::AppleObjCRuntime::GetFoundationVersion
uint32_t GetFoundationVersion()
Definition: AppleObjCRuntime.cpp:320
ObjCLanguageRuntime.h
lldb_private::AppleObjCRuntime::AppleIsModuleObjCLibrary
static bool AppleIsModuleObjCLibrary(const lldb::ModuleSP &module_sp)
Definition: AppleObjCRuntime.cpp:305
LanguageRuntime.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::TypeAndOrName
Sometimes you can find the name of the type corresponding to an object, but we don't have debug infor...
Definition: Type.h:394
lldb_private::AppleObjCRuntime::m_read_objc_library
bool m_read_objc_library
Definition: AppleObjCRuntime.h:123
lldb_private::AppleObjCRuntime::ExceptionBreakpointsAreSet
bool ExceptionBreakpointsAreSet() override
Definition: AppleObjCRuntime.cpp:433
lldb_private::AppleObjCRuntime::ClearExceptionBreakpoints
void ClearExceptionBreakpoints() override
Definition: AppleObjCRuntime.cpp:424
AppleObjCTrampolineHandler.h
lldb_private::AppleObjCRuntime::ReadObjCLibrary
bool ReadObjCLibrary(const lldb::ModuleSP &module_sp) override
Definition: AppleObjCRuntime.cpp:347