1293116Semaste//===-- AppleObjCRuntime.h --------------------------------------*- C++ -*-===// 2293116Semaste// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6293116Semaste// 7293116Semaste//===----------------------------------------------------------------------===// 8293116Semaste 9293116Semaste#ifndef liblldb_AppleObjCRuntime_h_ 10293116Semaste#define liblldb_AppleObjCRuntime_h_ 11293116Semaste 12293116Semaste#include "llvm/ADT/Optional.h" 13293116Semaste 14314564Sdim#include "AppleObjCTrampolineHandler.h" 15314564Sdim#include "AppleThreadPlanStepThroughObjCTrampoline.h" 16293116Semaste#include "lldb/Target/LanguageRuntime.h" 17314564Sdim#include "lldb/lldb-private.h" 18293116Semaste 19353358Sdim#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h" 20353358Sdim 21293116Semastenamespace lldb_private { 22314564Sdim 23314564Sdimclass AppleObjCRuntime : public lldb_private::ObjCLanguageRuntime { 24293116Semastepublic: 25314564Sdim ~AppleObjCRuntime() override; 26293116Semaste 27314564Sdim // Static Functions 28314564Sdim // Note there is no CreateInstance, Initialize & Terminate functions here, 29314564Sdim // because 30314564Sdim // you can't make an instance of this generic runtime. 31293116Semaste 32353358Sdim static char ID; 33353358Sdim 34353358Sdim bool isA(const void *ClassID) const override { 35353358Sdim return ClassID == &ID || ObjCLanguageRuntime::isA(ClassID); 36314564Sdim } 37293116Semaste 38353358Sdim static bool classof(const LanguageRuntime *runtime) { 39353358Sdim return runtime->isA(&ID); 40353358Sdim } 41353358Sdim 42314564Sdim // These are generic runtime functions: 43314564Sdim bool GetObjectDescription(Stream &str, Value &value, 44314564Sdim ExecutionContextScope *exe_scope) override; 45293116Semaste 46314564Sdim bool GetObjectDescription(Stream &str, ValueObject &object) override; 47293116Semaste 48314564Sdim bool CouldHaveDynamicValue(ValueObject &in_value) override; 49293116Semaste 50314564Sdim bool GetDynamicTypeAndAddress(ValueObject &in_value, 51314564Sdim lldb::DynamicValueType use_dynamic, 52314564Sdim TypeAndOrName &class_type_or_name, 53314564Sdim Address &address, 54314564Sdim Value::ValueType &value_type) override; 55293116Semaste 56314564Sdim TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name, 57314564Sdim ValueObject &static_value) override; 58314564Sdim 59314564Sdim // These are the ObjC specific functions. 60314564Sdim 61314564Sdim bool IsModuleObjCLibrary(const lldb::ModuleSP &module_sp) override; 62314564Sdim 63314564Sdim bool ReadObjCLibrary(const lldb::ModuleSP &module_sp) override; 64314564Sdim 65314564Sdim bool HasReadObjCLibrary() override { return m_read_objc_library; } 66314564Sdim 67314564Sdim lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, 68314564Sdim bool stop_others) override; 69314564Sdim 70314564Sdim // Get the "libobjc.A.dylib" module from the current target if we can find 71314564Sdim // it, also cache it once it is found to ensure quick lookups. 72314564Sdim lldb::ModuleSP GetObjCModule(); 73314564Sdim 74314564Sdim // Sync up with the target 75314564Sdim 76314564Sdim void ModulesDidLoad(const ModuleList &module_list) override; 77314564Sdim 78314564Sdim void SetExceptionBreakpoints() override; 79314564Sdim 80314564Sdim void ClearExceptionBreakpoints() override; 81314564Sdim 82314564Sdim bool ExceptionBreakpointsAreSet() override; 83314564Sdim 84314564Sdim bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override; 85314564Sdim 86314564Sdim lldb::SearchFilterSP CreateExceptionSearchFilter() override; 87344779Sdim 88344779Sdim static std::tuple<FileSpec, ConstString> GetExceptionThrowLocation(); 89314564Sdim 90344779Sdim lldb::ValueObjectSP GetExceptionObjectForThread( 91344779Sdim lldb::ThreadSP thread_sp) override; 92344779Sdim 93344779Sdim lldb::ThreadSP GetBacktraceThreadFromException( 94344779Sdim lldb::ValueObjectSP thread_sp) override; 95344779Sdim 96314564Sdim uint32_t GetFoundationVersion(); 97314564Sdim 98314564Sdim virtual void GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true, 99314564Sdim lldb::addr_t &cf_false); 100327952Sdim 101327952Sdim virtual bool IsTaggedPointer (lldb::addr_t addr) { return false; } 102314564Sdim 103293116Semasteprotected: 104314564Sdim // Call CreateInstance instead. 105314564Sdim AppleObjCRuntime(Process *process); 106293116Semaste 107314564Sdim bool CalculateHasNewLiteralsAndIndexing() override; 108293116Semaste 109314564Sdim static bool AppleIsModuleObjCLibrary(const lldb::ModuleSP &module_sp); 110293116Semaste 111314564Sdim static ObjCRuntimeVersions GetObjCVersion(Process *process, 112314564Sdim lldb::ModuleSP &objc_module_sp); 113293116Semaste 114314564Sdim void ReadObjCLibraryIfNeeded(const ModuleList &module_list); 115314564Sdim 116314564Sdim Address *GetPrintForDebuggerAddr(); 117314564Sdim 118314564Sdim std::unique_ptr<Address> m_PrintForDebugger_addr; 119314564Sdim bool m_read_objc_library; 120314564Sdim std::unique_ptr<lldb_private::AppleObjCTrampolineHandler> 121353358Sdim m_objc_trampoline_handler_up; 122314564Sdim lldb::BreakpointSP m_objc_exception_bp_sp; 123314564Sdim lldb::ModuleWP m_objc_module_wp; 124314564Sdim std::unique_ptr<FunctionCaller> m_print_object_caller_up; 125314564Sdim 126314564Sdim llvm::Optional<uint32_t> m_Foundation_major; 127293116Semaste}; 128314564Sdim 129293116Semaste} // namespace lldb_private 130293116Semaste 131293116Semaste#endif // liblldb_AppleObjCRuntime_h_ 132