[Lldb-commits] [PATCH] D104951: [lldb] Use the non-locking variant of objc_copyRealizedClassList

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 25 14:05:49 PDT 2021


JDevlieghere created this revision.
JDevlieghere added a reviewer: jingham.
JDevlieghere requested review of this revision.

Avoid standing the Objective-C runtime lock by calling `objc_copyRealizedClassList_nolock` instead of `objc_copyRealizedClassList`. We already guarantee that no other threads can run while we're running this utility expression, similar to when we parse the data ourself from the `gdb_objc_realized_classes` struct.


https://reviews.llvm.org/D104951

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
@@ -172,7 +172,7 @@
 extern "C" {
     int printf(const char * format, ...);
     void free(void *ptr);
-    Class* objc_copyRealizedClassList(unsigned int *outCount);
+    Class* objc_copyRealizedClassList_nolock(unsigned int *outCount);
     const char* objc_debug_class_getNameRaw(Class cls);
 }
 
@@ -199,7 +199,7 @@
     ClassInfo *class_infos = (ClassInfo *)class_infos_ptr;
 
     uint32_t count = 0;
-    Class* realized_class_list = objc_copyRealizedClassList(&count);
+    Class* realized_class_list = objc_copyRealizedClassList_nolock(&count);
     DEBUG_PRINTF ("count = %u\n", count);
 
     uint32_t idx = 0;
@@ -668,7 +668,7 @@
   static const ConstString g_gdb_object_getClass("gdb_object_getClass");
   m_has_object_getClass = HasSymbol(g_gdb_object_getClass);
   static const ConstString g_objc_copyRealizedClassList(
-      "objc_copyRealizedClassList");
+      "objc_copyRealizedClassList_nolock");
   m_has_objc_copyRealizedClassList = HasSymbol(g_objc_copyRealizedClassList);
 
   RegisterObjCExceptionRecognizer(process);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104951.354601.patch
Type: text/x-patch
Size: 1371 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210625/d489b54a/attachment.bin>


More information about the lldb-commits mailing list