1 //===-- AppleObjCRuntime.h --------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCRUNTIME_H
10 #define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCRUNTIME_H
13 #include "AppleObjCTrampolineHandler.h"
14 #include "AppleThreadPlanStepThroughObjCTrampoline.h"
15 #include "lldb/Target/LanguageRuntime.h"
16 #include "lldb/lldb-private.h"
18 #include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
21 namespace lldb_private
{
23 class AppleObjCRuntime
: public lldb_private::ObjCLanguageRuntime
{
25 ~AppleObjCRuntime() override
;
28 // Note there is no CreateInstance, Initialize & Terminate functions here,
30 // you can't make an instance of this generic runtime.
34 static void Initialize();
36 static void Terminate();
38 bool isA(const void *ClassID
) const override
{
39 return ClassID
== &ID
|| ObjCLanguageRuntime::isA(ClassID
);
42 static bool classof(const LanguageRuntime
*runtime
) {
43 return runtime
->isA(&ID
);
46 // These are generic runtime functions:
47 llvm::Error
GetObjectDescription(Stream
&str
, Value
&value
,
48 ExecutionContextScope
*exe_scope
) override
;
50 llvm::Error
GetObjectDescription(Stream
&str
, ValueObject
&object
) override
;
52 bool CouldHaveDynamicValue(ValueObject
&in_value
) override
;
54 bool GetDynamicTypeAndAddress(ValueObject
&in_value
,
55 lldb::DynamicValueType use_dynamic
,
56 TypeAndOrName
&class_type_or_name
,
58 Value::ValueType
&value_type
) override
;
60 TypeAndOrName
FixUpDynamicType(const TypeAndOrName
&type_and_or_name
,
61 ValueObject
&static_value
) override
;
63 // These are the ObjC specific functions.
65 bool IsModuleObjCLibrary(const lldb::ModuleSP
&module_sp
) override
;
67 bool ReadObjCLibrary(const lldb::ModuleSP
&module_sp
) override
;
69 bool HasReadObjCLibrary() override
{ return m_read_objc_library
; }
71 lldb::ThreadPlanSP
GetStepThroughTrampolinePlan(Thread
&thread
,
72 bool stop_others
) override
;
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();
78 // Sync up with the target
80 void ModulesDidLoad(const ModuleList
&module_list
) override
;
82 void SetExceptionBreakpoints() override
;
84 void ClearExceptionBreakpoints() override
;
86 bool ExceptionBreakpointsAreSet() override
;
88 bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason
) override
;
90 lldb::SearchFilterSP
CreateExceptionSearchFilter() override
;
92 static std::tuple
<FileSpec
, ConstString
> GetExceptionThrowLocation();
94 lldb::ValueObjectSP
GetExceptionObjectForThread(
95 lldb::ThreadSP thread_sp
) override
;
97 lldb::ThreadSP
GetBacktraceThreadFromException(
98 lldb::ValueObjectSP thread_sp
) override
;
100 uint32_t GetFoundationVersion();
102 virtual void GetValuesForGlobalCFBooleans(lldb::addr_t
&cf_true
,
103 lldb::addr_t
&cf_false
);
105 virtual bool IsTaggedPointer (lldb::addr_t addr
) { return false; }
108 // Call CreateInstance instead.
109 AppleObjCRuntime(Process
*process
);
111 bool CalculateHasNewLiteralsAndIndexing() override
;
113 static bool AppleIsModuleObjCLibrary(const lldb::ModuleSP
&module_sp
);
115 static ObjCRuntimeVersions
GetObjCVersion(Process
*process
,
116 lldb::ModuleSP
&objc_module_sp
);
118 void ReadObjCLibraryIfNeeded(const ModuleList
&module_list
);
120 Address
*GetPrintForDebuggerAddr();
122 std::unique_ptr
<Address
> m_PrintForDebugger_addr
;
123 bool m_read_objc_library
;
124 std::unique_ptr
<lldb_private::AppleObjCTrampolineHandler
>
125 m_objc_trampoline_handler_up
;
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
;
130 std::optional
<uint32_t> m_Foundation_major
;
133 } // namespace lldb_private
135 #endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCRUNTIME_H