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