Author: Jonas Devlieghere Date: 2022-06-21T18:51:38-07:00 New Revision: c08f61b45e3b93c25bc0405a489a382a54a5d941
URL: https://github.com/llvm/llvm-project/commit/c08f61b45e3b93c25bc0405a489a382a54a5d941 DIFF: https://github.com/llvm/llvm-project/commit/c08f61b45e3b93c25bc0405a489a382a54a5d941.diff LOG: [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 Added: Modified: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Removed: ################################################################################ diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 4194004fe61c..5c00da8b40ad 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -205,7 +205,7 @@ __lldb_apple_objc_v2_get_dynamic_class_info2(void *gdb_objc_realized_classes_ptr { Class isa = realized_class_list[i]; const char *name_ptr = objc_debug_class_getNameRaw(isa); - if (name_ptr == NULL) + if (!name_ptr) continue; const char *s = name_ptr; uint32_t h = 5381; @@ -239,6 +239,7 @@ extern "C" { void free(void *ptr); size_t objc_getRealizedClassList_trylock(Class *buffer, size_t len); const char* objc_debug_class_getNameRaw(Class cls); + const char* class_getName(Class cls); } #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 { Class isa = realized_class_list[i]; const char *name_ptr = objc_debug_class_getNameRaw(isa); - if (name_ptr == NULL) + if (!name_ptr) { + class_getName(isa); // Realize name of lazy classes. + name_ptr = objc_debug_class_getNameRaw(isa); + } + if (!name_ptr) continue; const char *s = name_ptr; uint32_t h = 5381; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits