diff options
-rw-r--r-- | lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp | 44 | ||||
-rw-r--r-- | lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h | 7 |
2 files changed, 22 insertions, 29 deletions
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 65bf6dbca7b..179fde28754 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -107,7 +107,8 @@ AppleObjCRuntimeV2::AppleObjCRuntimeV2 (Process *process, const ModuleSP &objc_module_sp) : AppleObjCRuntime (process), m_get_class_name_args(LLDB_INVALID_ADDRESS), - m_get_class_name_args_mutex(Mutex::eMutexTypeNormal) + m_get_class_name_args_mutex(Mutex::eMutexTypeNormal), + m_process_wp (process->shared_from_this()) { static const ConstString g_gdb_object_getClass("gdb_object_getClass"); m_has_object_getClass = (objc_module_sp->FindFirstSymbolWithNameAndType(g_gdb_object_getClass, eSymbolTypeCode) != NULL); @@ -973,28 +974,12 @@ private: class ClassDescriptorV2 : public ObjCLanguageRuntime::ClassDescriptor { public: - ClassDescriptorV2 (ObjCLanguageRuntime &runtime, ValueObject &ptr_to_object) : - m_runtime (runtime), - m_valid (false), - m_objc_class_ptr (0), - m_objc_class (), - m_name (), - m_instance_size (0), - m_realized (eLazyBoolCalculate), - m_process_wp () - { - lldb::addr_t object_ptr = ptr_to_object.GetValueAsUnsigned(0); - lldb::ProcessSP process_sp = ptr_to_object.GetProcessSP(); - - Error error; - ObjCLanguageRuntime::ObjCISA isa = process_sp->ReadPointerFromMemory(object_ptr, - error); - - if (isa != LLDB_INVALID_ADDRESS) - Initialize (isa, process_sp); - } + friend class lldb_private::AppleObjCRuntimeV2; - ClassDescriptorV2 (ObjCLanguageRuntime &runtime, ObjCLanguageRuntime::ObjCISA isa, lldb::ProcessSP process_sp) : +private: + // The constructor should only be invoked by the runtime as it builds its caches + // or populates them. A ClassDescriptorV2 should only ever exist in a cache. + ClassDescriptorV2 (AppleObjCRuntimeV2 &runtime, ObjCLanguageRuntime::ObjCISA isa) : m_runtime (runtime), m_valid (false), m_objc_class_ptr (0), @@ -1004,9 +989,10 @@ public: m_realized (eLazyBoolCalculate), m_process_wp () { - Initialize (isa, process_sp); + Initialize (isa, m_runtime.GetProcessSP()); } +public: virtual ConstString GetClassName () { @@ -1062,7 +1048,7 @@ public: if (!m_valid) return ObjCLanguageRuntime::ClassDescriptorSP(); - return m_runtime.GetClassDescriptor(m_objc_class.m_superclass); + return m_runtime.ObjCLanguageRuntime::GetClassDescriptor(m_objc_class.m_superclass); } virtual bool @@ -1178,7 +1164,7 @@ public: if (class_method_func) { - ObjCLanguageRuntime::ClassDescriptorSP metaclass = m_runtime.GetClassDescriptor(m_objc_class.m_isa); + ObjCLanguageRuntime::ClassDescriptorSP metaclass = m_runtime.ObjCLanguageRuntime::GetClassDescriptor(m_objc_class.m_isa); // We don't care about the metaclass's superclass, or its class methods. Its instance methods are // our class methods. @@ -1590,7 +1576,7 @@ private: } }; - ObjCLanguageRuntime &m_runtime; // The runtime, so we can read our metaclass. + AppleObjCRuntimeV2 &m_runtime; // The runtime, so we can read our metaclass. bool m_valid; // Gates whether we trust anything here at all. lldb::addr_t m_objc_class_ptr; // The address of the objc_class_t. objc_class_t m_objc_class; @@ -1800,7 +1786,7 @@ AppleObjCRuntimeV2::CreateClassDescriptor (ObjCISA isa) { ClassDescriptorSP objc_class_sp; if (isa != 0) - objc_class_sp.reset (new ClassDescriptorV2(*this, isa, m_process->CalculateProcess())); + objc_class_sp.reset (new ClassDescriptorV2(*this, isa)); return objc_class_sp; } @@ -1904,7 +1890,7 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMap_Impl() if (m_isa_to_descriptor_cache.count(elt.second)) continue; - ClassDescriptorSP descriptor_sp = ClassDescriptorSP(new ClassDescriptorV2(*this, elt.second, process_sp)); + ClassDescriptorSP descriptor_sp = ClassDescriptorSP(new ClassDescriptorV2(*this, elt.second)); if (log && log->GetVerbose()) log->Printf("AppleObjCRuntimeV2 added (ObjCISA)0x%llx (%s) from dynamic table to isa->descriptor cache", elt.second, elt.first.AsCString()); @@ -1950,7 +1936,7 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMap_Impl() if (m_isa_to_descriptor_cache.count(objc_isa)) continue; - ClassDescriptorSP descriptor_sp = ClassDescriptorSP(new ClassDescriptorV2(*this, objc_isa, process_sp)); + ClassDescriptorSP descriptor_sp = ClassDescriptorSP(new ClassDescriptorV2(*this, objc_isa)); if (log && log->GetVerbose()) log->Printf("AppleObjCRuntimeV2 added (ObjCISA)0x%llx (%s) from static table to isa->descriptor cache", objc_isa, descriptor_sp->GetClassName().AsCString()); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h index 6c5b773763c..361ebcfa3ee 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h @@ -110,6 +110,12 @@ public: virtual TypeVendor * GetTypeVendor(); + lldb::ProcessSP + GetProcessSP () + { + return m_process_wp.lock(); + } + protected: virtual lldb::BreakpointResolverSP CreateExceptionResolver (Breakpoint *bkpt, bool catch_bp, bool throw_bp); @@ -131,6 +137,7 @@ private: Mutex m_get_class_name_args_mutex; std::auto_ptr<TypeVendor> m_type_vendor_ap; + lldb::ProcessWP m_process_wp; // used by class descriptors to lazily fill their own data static const char *g_find_class_name_function_name; static const char *g_find_class_name_function_body; |