[lldb] Adjust for the new class_rw_t layout.
authorJonas Devlieghere <jonas@devlieghere.com>
Tue, 22 Oct 2019 17:18:02 +0000 (10:18 -0700)
committerJonas Devlieghere <jonas@devlieghere.com>
Tue, 22 Oct 2019 17:22:06 +0000 (10:22 -0700)
The field holding the "ro" will now be a union. If the low bit is set,
then it isn't an ro and it needs to be dereferenced once more to get to
it. If the low bit isn't set, then it is a proper class_ro_t

No dedicated test is needed as this code path will trigger when running
the existing Objective-C tests under a current version of the runtime.

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp

index 93aa07f..859b693 100644 (file)
@@ -111,6 +111,18 @@ bool ClassDescriptorV2::class_rw_t::Read(Process *process, lldb::addr_t addr) {
   m_firstSubclass = extractor.GetAddress_unchecked(&cursor);
   m_nextSiblingClass = extractor.GetAddress_unchecked(&cursor);
 
+  if (m_ro_ptr & 1) {
+    DataBufferHeap buffer(ptr_size, '\0');
+    process->ReadMemory(m_ro_ptr ^ 1, buffer.GetBytes(), ptr_size, error);
+    if (error.Fail())
+      return false;
+    cursor = 0;
+    DataExtractor extractor(buffer.GetBytes(), ptr_size,
+                            process->GetByteOrder(),
+                            process->GetAddressByteSize());
+    m_ro_ptr = extractor.GetAddress_unchecked(&cursor);
+  }
+
   return true;
 }