Author: Fred Riss Date: 2020-07-01T20:27:37-07:00 New Revision: 4a674b623796dc5c5778fc6998f788044137d61d
URL: https://github.com/llvm/llvm-project/commit/4a674b623796dc5c5778fc6998f788044137d61d DIFF: https://github.com/llvm/llvm-project/commit/4a674b623796dc5c5778fc6998f788044137d61d.diff LOG: [lldb/ObjC] Add support for direct selector references On macOS 11 (and other aligned OSs), the shared cache method lists get an additional optimization which removes one level of indirection to get to the selector. This patch supports this new optimization. Both codepaths are covered byt the existing Objective-C tests. Added: Modified: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h Removed: ################################################################################ diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp index ff9c86608b8a..bdd5c29db848 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp @@ -243,6 +243,7 @@ bool ClassDescriptorV2::method_list_t::Read(Process *process, uint32_t entsize = extractor.GetU32_unchecked(&cursor); m_is_small = (entsize & 0x80000000) != 0; + m_has_direct_selector = (entsize & 0x40000000) != 0; m_entsize = entsize & 0xfffc; m_count = extractor.GetU32_unchecked(&cursor); m_first_ptr = addr + cursor; @@ -251,7 +252,7 @@ bool ClassDescriptorV2::method_list_t::Read(Process *process, } bool ClassDescriptorV2::method_t::Read(Process *process, lldb::addr_t addr, - bool is_small) { + bool is_small, bool has_direct_sel) { size_t ptr_size = process->GetAddressByteSize(); size_t size = GetSize(process, is_small); @@ -272,12 +273,15 @@ bool ClassDescriptorV2::method_t::Read(Process *process, lldb::addr_t addr, uint32_t types_offset = extractor.GetU32_unchecked(&cursor); uint32_t imp_offset = extractor.GetU32_unchecked(&cursor); - // The SEL offset points to a SELRef. We need to dereference twice. - lldb::addr_t selref_addr = addr + nameref_offset; - m_name_ptr = - process->ReadUnsignedIntegerFromMemory(selref_addr, ptr_size, 0, error); - if (!error.Success()) - return false; + m_name_ptr = addr + nameref_offset; + + if (!has_direct_sel) { + // The SEL offset points to a SELRef. We need to dereference twice. + m_name_ptr = process->ReadUnsignedIntegerFromMemory(m_name_ptr, ptr_size, + 0, error); + if (!error.Success()) + return false; + } m_types_ptr = addr + 4 + types_offset; m_imp_ptr = addr + 8 + imp_offset; } else { @@ -380,6 +384,8 @@ bool ClassDescriptorV2::Describe( return false; bool is_small = base_method_list->m_is_small; + bool has_direct_selector = base_method_list->m_has_direct_selector; + if (base_method_list->m_entsize != method_t::GetSize(process, is_small)) return false; @@ -390,7 +396,7 @@ bool ClassDescriptorV2::Describe( method->Read(process, base_method_list->m_first_ptr + (i * base_method_list->m_entsize), - is_small); + is_small, has_direct_selector); if (instance_method_func(method->m_name.c_str(), method->m_types.c_str())) break; diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h index a8db060c5b56..9ef21c6e7208 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h @@ -135,6 +135,7 @@ class ClassDescriptorV2 : public ObjCLanguageRuntime::ClassDescriptor { struct method_list_t { uint16_t m_entsize; bool m_is_small; + bool m_has_direct_selector; uint32_t m_count; lldb::addr_t m_first_ptr; @@ -161,7 +162,7 @@ class ClassDescriptorV2 : public ObjCLanguageRuntime::ClassDescriptor { + field_size; // IMP imp; } - bool Read(Process *process, lldb::addr_t addr, bool); + bool Read(Process *process, lldb::addr_t addr, bool, bool); }; struct ivar_list_t { _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits