AppleObjCRuntime.h revision 293127
1//===-- AppleObjCRuntime.h --------------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef liblldb_AppleObjCRuntime_h_ 11#define liblldb_AppleObjCRuntime_h_ 12 13// C Includes 14// C++ Includes 15// Other libraries and framework includes 16#include "llvm/ADT/Optional.h" 17 18// Project includes 19#include "lldb/lldb-private.h" 20#include "lldb/Target/LanguageRuntime.h" 21#include "lldb/Target/ObjCLanguageRuntime.h" 22#include "AppleObjCTrampolineHandler.h" 23#include "AppleThreadPlanStepThroughObjCTrampoline.h" 24 25namespace lldb_private { 26 27class AppleObjCRuntime : 28 public lldb_private::ObjCLanguageRuntime 29{ 30public: 31 ~AppleObjCRuntime() override; 32 33 //------------------------------------------------------------------ 34 // Static Functions 35 //------------------------------------------------------------------ 36 // Note there is no CreateInstance, Initialize & Terminate functions here, because 37 // you can't make an instance of this generic runtime. 38 39 static bool classof(const ObjCLanguageRuntime* runtime) 40 { 41 switch (runtime->GetRuntimeVersion()) 42 { 43 case ObjCRuntimeVersions::eAppleObjC_V1: 44 case ObjCRuntimeVersions::eAppleObjC_V2: 45 return true; 46 default: 47 return false; 48 } 49 } 50 51 // These are generic runtime functions: 52 bool 53 GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope) override; 54 55 bool 56 GetObjectDescription (Stream &str, ValueObject &object) override; 57 58 bool 59 CouldHaveDynamicValue (ValueObject &in_value) override; 60 61 bool 62 GetDynamicTypeAndAddress (ValueObject &in_value, 63 lldb::DynamicValueType use_dynamic, 64 TypeAndOrName &class_type_or_name, 65 Address &address, 66 Value::ValueType &value_type) override; 67 68 TypeAndOrName 69 FixUpDynamicType (const TypeAndOrName& type_and_or_name, 70 ValueObject& static_value) override; 71 72 // These are the ObjC specific functions. 73 74 bool 75 IsModuleObjCLibrary (const lldb::ModuleSP &module_sp) override; 76 77 bool 78 ReadObjCLibrary (const lldb::ModuleSP &module_sp) override; 79 80 bool 81 HasReadObjCLibrary () override 82 { 83 return m_read_objc_library; 84 } 85 86 lldb::ThreadPlanSP 87 GetStepThroughTrampolinePlan (Thread &thread, bool stop_others) override; 88 89 // Get the "libobjc.A.dylib" module from the current target if we can find 90 // it, also cache it once it is found to ensure quick lookups. 91 lldb::ModuleSP 92 GetObjCModule (); 93 94 // Sync up with the target 95 96 void 97 ModulesDidLoad (const ModuleList &module_list) override; 98 99 void 100 SetExceptionBreakpoints() override; 101 102 void 103 ClearExceptionBreakpoints() override; 104 105 bool 106 ExceptionBreakpointsAreSet() override; 107 108 bool 109 ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override; 110 111 lldb::SearchFilterSP 112 CreateExceptionSearchFilter() override; 113 114 uint32_t 115 GetFoundationVersion(); 116 117protected: 118 // Call CreateInstance instead. 119 AppleObjCRuntime(Process *process); 120 121 bool 122 CalculateHasNewLiteralsAndIndexing() override; 123 124 static bool 125 AppleIsModuleObjCLibrary(const lldb::ModuleSP &module_sp); 126 127 static ObjCRuntimeVersions 128 GetObjCVersion(Process *process, lldb::ModuleSP &objc_module_sp); 129 130 void 131 ReadObjCLibraryIfNeeded(const ModuleList &module_list); 132 133 Address * 134 GetPrintForDebuggerAddr(); 135 136 std::unique_ptr<Address> m_PrintForDebugger_addr; 137 bool m_read_objc_library; 138 std::unique_ptr<lldb_private::AppleObjCTrampolineHandler> m_objc_trampoline_handler_ap; 139 lldb::BreakpointSP m_objc_exception_bp_sp; 140 lldb::ModuleWP m_objc_module_wp; 141 std::unique_ptr<FunctionCaller> m_print_object_caller_up; 142 143 llvm::Optional<uint32_t> m_Foundation_major; 144}; 145 146} // namespace lldb_private 147 148#endif // liblldb_AppleObjCRuntime_h_ 149