1 //===-- AppleObjCRuntime.h --------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_AppleObjCRuntime_h_
11 #define liblldb_AppleObjCRuntime_h_
15 // Other libraries and framework includes
16 #include "llvm/ADT/Optional.h"
19 #include "AppleObjCTrampolineHandler.h"
20 #include "AppleThreadPlanStepThroughObjCTrampoline.h"
21 #include "lldb/Target/LanguageRuntime.h"
22 #include "lldb/Target/ObjCLanguageRuntime.h"
23 #include "lldb/lldb-private.h"
25 namespace lldb_private {
27 class AppleObjCRuntime : public lldb_private::ObjCLanguageRuntime {
29 ~AppleObjCRuntime() override;
31 //------------------------------------------------------------------
33 //------------------------------------------------------------------
34 // Note there is no CreateInstance, Initialize & Terminate functions here,
36 // you can't make an instance of this generic runtime.
38 static bool classof(const ObjCLanguageRuntime *runtime) {
39 switch (runtime->GetRuntimeVersion()) {
40 case ObjCRuntimeVersions::eAppleObjC_V1:
41 case ObjCRuntimeVersions::eAppleObjC_V2:
48 // These are generic runtime functions:
49 bool GetObjectDescription(Stream &str, Value &value,
50 ExecutionContextScope *exe_scope) override;
52 bool GetObjectDescription(Stream &str, ValueObject &object) override;
54 bool CouldHaveDynamicValue(ValueObject &in_value) override;
56 bool GetDynamicTypeAndAddress(ValueObject &in_value,
57 lldb::DynamicValueType use_dynamic,
58 TypeAndOrName &class_type_or_name,
60 Value::ValueType &value_type) override;
62 TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name,
63 ValueObject &static_value) override;
65 // These are the ObjC specific functions.
67 bool IsModuleObjCLibrary(const lldb::ModuleSP &module_sp) override;
69 bool ReadObjCLibrary(const lldb::ModuleSP &module_sp) override;
71 bool HasReadObjCLibrary() override { return m_read_objc_library; }
73 lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
74 bool stop_others) override;
76 // Get the "libobjc.A.dylib" module from the current target if we can find
77 // it, also cache it once it is found to ensure quick lookups.
78 lldb::ModuleSP GetObjCModule();
80 // Sync up with the target
82 void ModulesDidLoad(const ModuleList &module_list) override;
84 void SetExceptionBreakpoints() override;
86 void ClearExceptionBreakpoints() override;
88 bool ExceptionBreakpointsAreSet() override;
90 bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override;
92 lldb::SearchFilterSP CreateExceptionSearchFilter() override;
94 uint32_t GetFoundationVersion();
96 virtual void GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true,
97 lldb::addr_t &cf_false);
100 // Call CreateInstance instead.
101 AppleObjCRuntime(Process *process);
103 bool CalculateHasNewLiteralsAndIndexing() override;
105 static bool AppleIsModuleObjCLibrary(const lldb::ModuleSP &module_sp);
107 static ObjCRuntimeVersions GetObjCVersion(Process *process,
108 lldb::ModuleSP &objc_module_sp);
110 void ReadObjCLibraryIfNeeded(const ModuleList &module_list);
112 Address *GetPrintForDebuggerAddr();
114 std::unique_ptr<Address> m_PrintForDebugger_addr;
115 bool m_read_objc_library;
116 std::unique_ptr<lldb_private::AppleObjCTrampolineHandler>
117 m_objc_trampoline_handler_ap;
118 lldb::BreakpointSP m_objc_exception_bp_sp;
119 lldb::ModuleWP m_objc_module_wp;
120 std::unique_ptr<FunctionCaller> m_print_object_caller_up;
122 llvm::Optional<uint32_t> m_Foundation_major;
125 } // namespace lldb_private
127 #endif // liblldb_AppleObjCRuntime_h_