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