AppleObjCRuntime.h revision 353358
1330449Seadler//===-- AppleObjCRuntime.h --------------------------------------*- C++ -*-===// 2330449Seadler// 3330449Seadler// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 417717Swosch// See https://llvm.org/LICENSE.txt for license information. 517717Swosch// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 617717Swosch// 717717Swosch//===----------------------------------------------------------------------===// 817717Swosch 917717Swosch#ifndef liblldb_AppleObjCRuntime_h_ 1017717Swosch#define liblldb_AppleObjCRuntime_h_ 1117717Swosch 1217717Swosch#include "llvm/ADT/Optional.h" 1317717Swosch 1417717Swosch#include "AppleObjCTrampolineHandler.h" 1517717Swosch#include "AppleThreadPlanStepThroughObjCTrampoline.h" 1617717Swosch#include "lldb/Target/LanguageRuntime.h" 1717717Swosch#include "lldb/lldb-private.h" 1817717Swosch 1917717Swosch#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h" 2017717Swosch 2117717Swoschnamespace lldb_private { 2217717Swosch 2317717Swoschclass AppleObjCRuntime : public lldb_private::ObjCLanguageRuntime { 2417717Swoschpublic: 2517717Swosch ~AppleObjCRuntime() override; 2617717Swosch 2717717Swosch // Static Functions 2850477Speter // Note there is no CreateInstance, Initialize & Terminate functions here, 2917717Swosch // because 3017717Swosch // you can't make an instance of this generic runtime. 3117717Swosch 3217717Swosch static char ID; 3317717Swosch 3492920Simp bool isA(const void *ClassID) const override { 3517717Swosch return ClassID == &ID || ObjCLanguageRuntime::isA(ClassID); 3617717Swosch } 37 38 static bool classof(const LanguageRuntime *runtime) { 39 return runtime->isA(&ID); 40 } 41 42 // These are generic runtime functions: 43 bool GetObjectDescription(Stream &str, Value &value, 44 ExecutionContextScope *exe_scope) override; 45 46 bool GetObjectDescription(Stream &str, ValueObject &object) override; 47 48 bool CouldHaveDynamicValue(ValueObject &in_value) override; 49 50 bool GetDynamicTypeAndAddress(ValueObject &in_value, 51 lldb::DynamicValueType use_dynamic, 52 TypeAndOrName &class_type_or_name, 53 Address &address, 54 Value::ValueType &value_type) override; 55 56 TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name, 57 ValueObject &static_value) override; 58 59 // These are the ObjC specific functions. 60 61 bool IsModuleObjCLibrary(const lldb::ModuleSP &module_sp) override; 62 63 bool ReadObjCLibrary(const lldb::ModuleSP &module_sp) override; 64 65 bool HasReadObjCLibrary() override { return m_read_objc_library; } 66 67 lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, 68 bool stop_others) override; 69 70 // Get the "libobjc.A.dylib" module from the current target if we can find 71 // it, also cache it once it is found to ensure quick lookups. 72 lldb::ModuleSP GetObjCModule(); 73 74 // Sync up with the target 75 76 void ModulesDidLoad(const ModuleList &module_list) override; 77 78 void SetExceptionBreakpoints() override; 79 80 void ClearExceptionBreakpoints() override; 81 82 bool ExceptionBreakpointsAreSet() override; 83 84 bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override; 85 86 lldb::SearchFilterSP CreateExceptionSearchFilter() override; 87 88 static std::tuple<FileSpec, ConstString> GetExceptionThrowLocation(); 89 90 lldb::ValueObjectSP GetExceptionObjectForThread( 91 lldb::ThreadSP thread_sp) override; 92 93 lldb::ThreadSP GetBacktraceThreadFromException( 94 lldb::ValueObjectSP thread_sp) override; 95 96 uint32_t GetFoundationVersion(); 97 98 virtual void GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true, 99 lldb::addr_t &cf_false); 100 101 virtual bool IsTaggedPointer (lldb::addr_t addr) { return false; } 102 103protected: 104 // Call CreateInstance instead. 105 AppleObjCRuntime(Process *process); 106 107 bool CalculateHasNewLiteralsAndIndexing() override; 108 109 static bool AppleIsModuleObjCLibrary(const lldb::ModuleSP &module_sp); 110 111 static ObjCRuntimeVersions GetObjCVersion(Process *process, 112 lldb::ModuleSP &objc_module_sp); 113 114 void ReadObjCLibraryIfNeeded(const ModuleList &module_list); 115 116 Address *GetPrintForDebuggerAddr(); 117 118 std::unique_ptr<Address> m_PrintForDebugger_addr; 119 bool m_read_objc_library; 120 std::unique_ptr<lldb_private::AppleObjCTrampolineHandler> 121 m_objc_trampoline_handler_up; 122 lldb::BreakpointSP m_objc_exception_bp_sp; 123 lldb::ModuleWP m_objc_module_wp; 124 std::unique_ptr<FunctionCaller> m_print_object_caller_up; 125 126 llvm::Optional<uint32_t> m_Foundation_major; 127}; 128 129} // namespace lldb_private 130 131#endif // liblldb_AppleObjCRuntime_h_ 132