AppleObjCRuntime.h revision 344779
1293116Semaste//===-- AppleObjCRuntime.h --------------------------------------*- C++ -*-===// 2293116Semaste// 3293116Semaste// The LLVM Compiler Infrastructure 4293116Semaste// 5293116Semaste// This file is distributed under the University of Illinois Open Source 6293116Semaste// License. See LICENSE.TXT for details. 7293116Semaste// 8293116Semaste//===----------------------------------------------------------------------===// 9293116Semaste 10293116Semaste#ifndef liblldb_AppleObjCRuntime_h_ 11293116Semaste#define liblldb_AppleObjCRuntime_h_ 12293116Semaste 13293116Semaste#include "llvm/ADT/Optional.h" 14293116Semaste 15314564Sdim#include "AppleObjCTrampolineHandler.h" 16314564Sdim#include "AppleThreadPlanStepThroughObjCTrampoline.h" 17293116Semaste#include "lldb/Target/LanguageRuntime.h" 18293116Semaste#include "lldb/Target/ObjCLanguageRuntime.h" 19314564Sdim#include "lldb/lldb-private.h" 20293116Semaste 21293116Semastenamespace lldb_private { 22314564Sdim 23314564Sdimclass AppleObjCRuntime : public lldb_private::ObjCLanguageRuntime { 24293116Semastepublic: 25314564Sdim ~AppleObjCRuntime() override; 26293116Semaste 27314564Sdim //------------------------------------------------------------------ 28314564Sdim // Static Functions 29314564Sdim //------------------------------------------------------------------ 30314564Sdim // Note there is no CreateInstance, Initialize & Terminate functions here, 31314564Sdim // because 32314564Sdim // you can't make an instance of this generic runtime. 33293116Semaste 34314564Sdim static bool classof(const ObjCLanguageRuntime *runtime) { 35314564Sdim switch (runtime->GetRuntimeVersion()) { 36314564Sdim case ObjCRuntimeVersions::eAppleObjC_V1: 37314564Sdim case ObjCRuntimeVersions::eAppleObjC_V2: 38314564Sdim return true; 39314564Sdim default: 40314564Sdim return false; 41293116Semaste } 42314564Sdim } 43293116Semaste 44314564Sdim // These are generic runtime functions: 45314564Sdim bool GetObjectDescription(Stream &str, Value &value, 46314564Sdim ExecutionContextScope *exe_scope) override; 47293116Semaste 48314564Sdim bool GetObjectDescription(Stream &str, ValueObject &object) override; 49293116Semaste 50314564Sdim bool CouldHaveDynamicValue(ValueObject &in_value) override; 51293116Semaste 52314564Sdim bool GetDynamicTypeAndAddress(ValueObject &in_value, 53314564Sdim lldb::DynamicValueType use_dynamic, 54314564Sdim TypeAndOrName &class_type_or_name, 55314564Sdim Address &address, 56314564Sdim Value::ValueType &value_type) override; 57293116Semaste 58314564Sdim TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name, 59314564Sdim ValueObject &static_value) override; 60314564Sdim 61314564Sdim // These are the ObjC specific functions. 62314564Sdim 63314564Sdim bool IsModuleObjCLibrary(const lldb::ModuleSP &module_sp) override; 64314564Sdim 65314564Sdim bool ReadObjCLibrary(const lldb::ModuleSP &module_sp) override; 66314564Sdim 67314564Sdim bool HasReadObjCLibrary() override { return m_read_objc_library; } 68314564Sdim 69314564Sdim lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, 70314564Sdim bool stop_others) override; 71314564Sdim 72314564Sdim // Get the "libobjc.A.dylib" module from the current target if we can find 73314564Sdim // it, also cache it once it is found to ensure quick lookups. 74314564Sdim lldb::ModuleSP GetObjCModule(); 75314564Sdim 76314564Sdim // Sync up with the target 77314564Sdim 78314564Sdim void ModulesDidLoad(const ModuleList &module_list) override; 79314564Sdim 80314564Sdim void SetExceptionBreakpoints() override; 81314564Sdim 82314564Sdim void ClearExceptionBreakpoints() override; 83314564Sdim 84314564Sdim bool ExceptionBreakpointsAreSet() override; 85314564Sdim 86314564Sdim bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override; 87314564Sdim 88314564Sdim lldb::SearchFilterSP CreateExceptionSearchFilter() override; 89344779Sdim 90344779Sdim static std::tuple<FileSpec, ConstString> GetExceptionThrowLocation(); 91314564Sdim 92344779Sdim lldb::ValueObjectSP GetExceptionObjectForThread( 93344779Sdim lldb::ThreadSP thread_sp) override; 94344779Sdim 95344779Sdim lldb::ThreadSP GetBacktraceThreadFromException( 96344779Sdim lldb::ValueObjectSP thread_sp) override; 97344779Sdim 98314564Sdim uint32_t GetFoundationVersion(); 99314564Sdim 100314564Sdim virtual void GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true, 101314564Sdim lldb::addr_t &cf_false); 102327952Sdim 103327952Sdim virtual bool IsTaggedPointer (lldb::addr_t addr) { return false; } 104314564Sdim 105293116Semasteprotected: 106314564Sdim // Call CreateInstance instead. 107314564Sdim AppleObjCRuntime(Process *process); 108293116Semaste 109314564Sdim bool CalculateHasNewLiteralsAndIndexing() override; 110293116Semaste 111314564Sdim static bool AppleIsModuleObjCLibrary(const lldb::ModuleSP &module_sp); 112293116Semaste 113314564Sdim static ObjCRuntimeVersions GetObjCVersion(Process *process, 114314564Sdim lldb::ModuleSP &objc_module_sp); 115293116Semaste 116314564Sdim void ReadObjCLibraryIfNeeded(const ModuleList &module_list); 117314564Sdim 118314564Sdim Address *GetPrintForDebuggerAddr(); 119314564Sdim 120314564Sdim std::unique_ptr<Address> m_PrintForDebugger_addr; 121314564Sdim bool m_read_objc_library; 122314564Sdim std::unique_ptr<lldb_private::AppleObjCTrampolineHandler> 123314564Sdim m_objc_trampoline_handler_ap; 124314564Sdim lldb::BreakpointSP m_objc_exception_bp_sp; 125314564Sdim lldb::ModuleWP m_objc_module_wp; 126314564Sdim std::unique_ptr<FunctionCaller> m_print_object_caller_up; 127314564Sdim 128314564Sdim llvm::Optional<uint32_t> m_Foundation_major; 129293116Semaste}; 130314564Sdim 131293116Semaste} // namespace lldb_private 132293116Semaste 133293116Semaste#endif // liblldb_AppleObjCRuntime_h_ 134