Skip to content

Commit 0917144

Browse files
committed
[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 (cherry picked from commit ffc0533)
1 parent c657e93 commit 0917144

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static const char *g_get_dynamic_class_info2_body = R"(
172172
extern "C" {
173173
int printf(const char * format, ...);
174174
void free(void *ptr);
175-
Class* objc_copyRealizedClassList(unsigned int *outCount);
175+
Class* objc_copyRealizedClassList_nolock(unsigned int *outCount);
176176
const char* objc_debug_class_getNameRaw(Class cls);
177177
}
178178
@@ -199,7 +199,7 @@ __lldb_apple_objc_v2_get_dynamic_class_info2(void *gdb_objc_realized_classes_ptr
199199
ClassInfo *class_infos = (ClassInfo *)class_infos_ptr;
200200
201201
uint32_t count = 0;
202-
Class* realized_class_list = objc_copyRealizedClassList(&count);
202+
Class* realized_class_list = objc_copyRealizedClassList_nolock(&count);
203203
DEBUG_PRINTF ("count = %u\n", count);
204204
205205
uint32_t idx = 0;
@@ -499,7 +499,7 @@ AppleObjCRuntimeV2::AppleObjCRuntimeV2(Process *process,
499499
static const ConstString g_gdb_object_getClass("gdb_object_getClass");
500500
m_has_object_getClass = HasSymbol(g_gdb_object_getClass);
501501
static const ConstString g_objc_copyRealizedClassList(
502-
"objc_copyRealizedClassList");
502+
"objc_copyRealizedClassList_nolock");
503503
m_has_objc_copyRealizedClassList = HasSymbol(g_objc_copyRealizedClassList);
504504

505505
RegisterObjCExceptionRecognizer(process);

0 commit comments

Comments
 (0)