From: Fred Riss Date: Fri, 13 Mar 2020 23:17:38 +0000 (-0700) Subject: [lldb/ObjC] Make the NonPointerIsaCache initialization lazy X-Git-Tag: llvmorg-14-init~11302 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c4fee95746caad924cd33ace36bad44a3dbffd79;p=platform%2Fupstream%2Fllvm.git [lldb/ObjC] Make the NonPointerIsaCache initialization lazy The objc_debug_isa_class_mask magic value that the objc runtime vends is now initialized using a static initializer instead of a constant value. The runtime plugin itself will be initialized before the value is computed and as a result, the cache will get the wrong value. Making the creation of the NonPointerIsaCache fully lazy fixes this. --- diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 2d48c798912d..30e094bd3649 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -414,16 +414,15 @@ static void RegisterObjCExceptionRecognizer(Process *process); AppleObjCRuntimeV2::AppleObjCRuntimeV2(Process *process, const ModuleSP &objc_module_sp) - : AppleObjCRuntime(process), m_get_class_info_code(), - m_get_class_info_args(LLDB_INVALID_ADDRESS), + : AppleObjCRuntime(process), m_objc_module_sp(objc_module_sp), + m_get_class_info_code(), m_get_class_info_args(LLDB_INVALID_ADDRESS), m_get_class_info_args_mutex(), m_get_shared_cache_class_info_code(), m_get_shared_cache_class_info_args(LLDB_INVALID_ADDRESS), m_get_shared_cache_class_info_args_mutex(), m_decl_vendor_up(), m_tagged_pointer_obfuscator(LLDB_INVALID_ADDRESS), m_isa_hash_table_ptr(LLDB_INVALID_ADDRESS), m_hash_signature(), m_has_object_getClass(false), m_loaded_objc_opt(false), - m_non_pointer_isa_cache_up( - NonPointerISACache::CreateInstance(*this, objc_module_sp)), + m_non_pointer_isa_cache_up(), m_tagged_pointer_vendor_up( TaggedPointerVendorV2::CreateInstance(*this, objc_module_sp)), m_encoding_to_type_sp(), m_noclasses_warning_emitted(false), @@ -642,6 +641,7 @@ protected: ivar.m_type.GetDisplayTypeName().AsCString(""), ivar.m_size, ivar.m_offset); } + iterator->second->Describe( nullptr, [&std_out](const char *name, const char *type) -> bool { @@ -1179,8 +1179,8 @@ bool AppleObjCRuntimeV2::HashTableSignature::NeedsUpdate( ObjCLanguageRuntime::ClassDescriptorSP AppleObjCRuntimeV2::GetClassDescriptorFromISA(ObjCISA isa) { ObjCLanguageRuntime::ClassDescriptorSP class_descriptor_sp; - if (m_non_pointer_isa_cache_up) - class_descriptor_sp = m_non_pointer_isa_cache_up->GetClassDescriptor(isa); + if (auto *non_pointer_isa_cache = GetNonPointerIsaCache()) + class_descriptor_sp = non_pointer_isa_cache->GetClassDescriptor(isa); if (!class_descriptor_sp) class_descriptor_sp = ObjCLanguageRuntime::GetClassDescriptorFromISA(isa); return class_descriptor_sp; @@ -2561,8 +2561,8 @@ lldb_private::AppleObjCRuntime::ObjCISA AppleObjCRuntimeV2::GetPointerISA(ObjCISA isa) { ObjCISA ret = isa; - if (m_non_pointer_isa_cache_up) - m_non_pointer_isa_cache_up->EvaluateNonPointerISA(isa, ret); + if (auto *non_pointer_isa_cache = GetNonPointerIsaCache()) + non_pointer_isa_cache->EvaluateNonPointerISA(isa, ret); return ret; } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h index 3121431adca1..456dc09d2c6d 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h @@ -320,8 +320,17 @@ private: bool GetCFBooleanValuesIfNeeded(); + NonPointerISACache *GetNonPointerIsaCache() { + if (!m_non_pointer_isa_cache_up) + m_non_pointer_isa_cache_up.reset( + NonPointerISACache::CreateInstance(*this, m_objc_module_sp)); + return m_non_pointer_isa_cache_up.get(); + } + friend class ClassDescriptorV2; + lldb::ModuleSP m_objc_module_sp; + std::unique_ptr m_get_class_info_code; lldb::addr_t m_get_class_info_args; std::mutex m_get_class_info_args_mutex;