From ffc0533855871f4c784f6535044ce7c2bd076392 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Fri, 25 Jun 2021 12:57:36 -0700 Subject: [PATCH] [lldb] Use the non-locking variant of objc_copyRealizedClassList 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 ourselves from the gdb_objc_realized_classes struct. Worst case this will crash if the list is getting edited, which won't do any harm and we'll just try again later. Differential revision: https://reviews.llvm.org/D104951 --- .../LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 069368c..a3a0827 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -172,7 +172,7 @@ static const char *g_get_dynamic_class_info2_body = R"( 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 @@ __lldb_apple_objc_v2_get_dynamic_class_info2(void *gdb_objc_realized_classes_ptr 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 @@ AppleObjCRuntimeV2::AppleObjCRuntimeV2(Process *process, 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); -- 2.7.4