[lldb] Adjust for changes in objc runtime
authorAlex Langford <alangford@apple.com>
Thu, 22 Jun 2023 23:04:06 +0000 (16:04 -0700)
committerAlex Langford <alangford@apple.com>
Thu, 22 Jun 2023 23:42:22 +0000 (16:42 -0700)
commit28fb39f16af1003e53008b75c11127b3288742f8
tree197209aa1dcc8c62fcf1ba7c1aba89c2865f082a
parent71ba28eaac46f964251a35d9f8d3cf042853e55b
[lldb] Adjust for changes in objc runtime

The Objective-C runtime and the shared cache has changed slightly.
Given a class_ro_t, the baseMethods ivar is now a pointer union and may
either be a method_list_t pointer or a pointer to a relative list of
lists. The entries of this relative list of lists are indexes that refer
to a specific image in the shared cache in addition to a pointer offset
to find the accompanying method_list_t. We have to go over each of these
entries, parse it, and then if the relevant image is loaded in the
process, we add those methods to the relevant clang Decl.

In order to determine if an image is loaded, the Objective-C runtime
exposes a symbol that lets us determine if a particular image is loaded.
We maintain a data structure SharedCacheImageHeaders to keep track of
that information.

There is a known issue where if an image is loaded after we create a
Decl for a class, the Decl will not have the relevant methods from that
image (i.e. for Categories).

rdar://107957209

Differential Revision: https://reviews.llvm.org/D153597
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
lldb/test/API/lang/objc/exceptions/TestObjCExceptions.py