Skip to content

Commit c08f61b

Browse files
committed
[lldb] Instantiate lazily named classes on macOS Ventura.
Recent revisions of the Objective-C runtime changed objc_debug_class_getNameRaw() in a way that no longer triggers lazy names to be instantiated. This has the unintended side-effect of making generic bridged Swift classes, such as _SwiftDeferredNSDictionary<U,V> to become invisible to the Objective-C runtime. This patch detects this situation and forces the names to be instantiated by calling class_getName() and discarding the result before calling objc_debug_class_getNameRaw() again. Many thanks to Mike Ash for outlining the solution and Adrian for authoring the downstream patch. rdar://95245318 Differential revision: https://reviews.llvm.org/D128306
1 parent 7a9ad25 commit c08f61b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ __lldb_apple_objc_v2_get_dynamic_class_info2(void *gdb_objc_realized_classes_ptr
205205
{
206206
Class isa = realized_class_list[i];
207207
const char *name_ptr = objc_debug_class_getNameRaw(isa);
208-
if (name_ptr == NULL)
208+
if (!name_ptr)
209209
continue;
210210
const char *s = name_ptr;
211211
uint32_t h = 5381;
@@ -239,6 +239,7 @@ extern "C" {
239239
void free(void *ptr);
240240
size_t objc_getRealizedClassList_trylock(Class *buffer, size_t len);
241241
const char* objc_debug_class_getNameRaw(Class cls);
242+
const char* class_getName(Class cls);
242243
}
243244
244245
#define DEBUG_PRINTF(fmt, ...) if (should_log) printf(fmt, ## __VA_ARGS__)
@@ -278,7 +279,11 @@ __lldb_apple_objc_v2_get_dynamic_class_info3(void *gdb_objc_realized_classes_ptr
278279
{
279280
Class isa = realized_class_list[i];
280281
const char *name_ptr = objc_debug_class_getNameRaw(isa);
281-
if (name_ptr == NULL)
282+
if (!name_ptr) {
283+
class_getName(isa); // Realize name of lazy classes.
284+
name_ptr = objc_debug_class_getNameRaw(isa);
285+
}
286+
if (!name_ptr)
282287
continue;
283288
const char *s = name_ptr;
284289
uint32_t h = 5381;

0 commit comments

Comments
 (0)