AppleObjCRuntimeV1.h revision 102b2c2681c9a830afe25bfea35557421905e42c
1//===-- AppleObjCRuntimeV1.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_AppleObjCRuntimeV1_h_ 11#define liblldb_AppleObjCRuntimeV1_h_ 12 13// C Includes 14// C++ Includes 15// Other libraries and framework includes 16// Project includes 17#include "lldb/lldb-private.h" 18#include "lldb/Target/ObjCLanguageRuntime.h" 19#include "AppleObjCRuntime.h" 20 21namespace lldb_private { 22 23class AppleObjCRuntimeV1 : 24 public AppleObjCRuntime 25{ 26public: 27 28 class ClassDescriptorV1 : public ObjCLanguageRuntime::ClassDescriptor 29 { 30 public: 31 ClassDescriptorV1 (ValueObject &isa_pointer); 32 ClassDescriptorV1 (ObjCISA isa, lldb::ProcessSP process_sp); 33 34 virtual ConstString 35 GetClassName () 36 { 37 return m_name; 38 } 39 40 virtual ClassDescriptorSP 41 GetSuperclass (); 42 43 virtual bool 44 IsValid () 45 { 46 return m_valid; 47 } 48 49 // v1 does not support tagged pointers 50 virtual bool 51 GetTaggedPointerInfo (uint64_t* info_bits = NULL, 52 uint64_t* value_bits = NULL) 53 { 54 return false; 55 } 56 57 virtual uint64_t 58 GetInstanceSize () 59 { 60 return m_instance_size; 61 } 62 63 virtual ObjCISA 64 GetISA () 65 { 66 return m_isa; 67 } 68 69 virtual bool 70 Describe (std::function <void (ObjCLanguageRuntime::ObjCISA)> const &superclass_func, 71 std::function <bool (const char *, const char *)> const &instance_method_func, 72 std::function <bool (const char *, const char *)> const &class_method_func, 73 std::function <bool (const char *, const char *, lldb::addr_t, uint64_t)> const &ivar_func); 74 75 virtual 76 ~ClassDescriptorV1 () 77 {} 78 79 protected: 80 void 81 Initialize (ObjCISA isa, lldb::ProcessSP process_sp); 82 83 private: 84 ConstString m_name; 85 ObjCISA m_isa; 86 ObjCISA m_parent_isa; 87 bool m_valid; 88 lldb::ProcessWP m_process_wp; 89 uint64_t m_instance_size; 90 }; 91 92 virtual ~AppleObjCRuntimeV1() { } 93 94 // These are generic runtime functions: 95 virtual bool 96 GetDynamicTypeAndAddress (ValueObject &in_value, 97 lldb::DynamicValueType use_dynamic, 98 TypeAndOrName &class_type_or_name, 99 Address &address); 100 101 virtual ClangUtilityFunction * 102 CreateObjectChecker (const char *); 103 104 //------------------------------------------------------------------ 105 // Static Functions 106 //------------------------------------------------------------------ 107 static void 108 Initialize(); 109 110 static void 111 Terminate(); 112 113 static lldb_private::LanguageRuntime * 114 CreateInstance (Process *process, lldb::LanguageType language); 115 116 //------------------------------------------------------------------ 117 // PluginInterface protocol 118 //------------------------------------------------------------------ 119 virtual const char * 120 GetPluginName(); 121 122 virtual const char * 123 GetShortPluginName(); 124 125 virtual uint32_t 126 GetPluginVersion(); 127 128 virtual ObjCRuntimeVersions 129 GetRuntimeVersion () 130 { 131 return eAppleObjC_V1; 132 } 133 134 virtual void 135 UpdateISAToDescriptorMapIfNeeded(); 136 137 virtual TypeVendor * 138 GetTypeVendor(); 139 140protected: 141 virtual lldb::BreakpointResolverSP 142 CreateExceptionResolver (Breakpoint *bkpt, bool catch_bp, bool throw_bp); 143 144 145 class HashTableSignature 146 { 147 public: 148 HashTableSignature () : 149 m_count (0), 150 m_num_buckets (0), 151 m_buckets_ptr (LLDB_INVALID_ADDRESS) 152 { 153 } 154 155 bool 156 NeedsUpdate (uint32_t count, 157 uint32_t num_buckets, 158 lldb::addr_t buckets_ptr) 159 { 160 return m_count != count || 161 m_num_buckets != num_buckets || 162 m_buckets_ptr != buckets_ptr ; 163 } 164 165 void 166 UpdateSignature (uint32_t count, 167 uint32_t num_buckets, 168 lldb::addr_t buckets_ptr) 169 { 170 m_count = count; 171 m_num_buckets = num_buckets; 172 m_buckets_ptr = buckets_ptr; 173 } 174 175 protected: 176 uint32_t m_count; 177 uint32_t m_num_buckets; 178 lldb::addr_t m_buckets_ptr; 179 }; 180 181 182 lldb::addr_t 183 GetISAHashTablePointer (); 184 185 HashTableSignature m_hash_signature; 186 lldb::addr_t m_isa_hash_table_ptr; 187 std::unique_ptr<TypeVendor> m_type_vendor_ap; 188private: 189 AppleObjCRuntimeV1(Process *process); 190}; 191 192} // namespace lldb_private 193 194#endif // liblldb_AppleObjCRuntimeV1_h_ 195