[Lldb-commits] [PATCH] D128306: [lldb] Instantiate lazily named classes on macOS Ventura.
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Jun 21 14:20:54 PDT 2022
JDevlieghere created this revision.
JDevlieghere added a reviewer: aprantl.
Herald added a project: All.
JDevlieghere requested review of this revision.
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
https://reviews.llvm.org/D128306
Files:
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
===================================================================
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -205,7 +205,7 @@
{
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 @@
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 @@
{
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128306.438837.patch
Type: text/x-patch
Size: 1426 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220621/99927600/attachment.bin>
More information about the lldb-commits
mailing list