Index: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp =================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp @@ -890,24 +890,6 @@ if (loaded_module_list.GetSize() > 0) { - // FIXME: This should really be in the Runtime handlers class, which should get - // called by the target's ModulesDidLoad, but we're doing it all locally for now - // to save time. - // Also, I'm assuming there can be only one libobjc dylib loaded... - - ObjCLanguageRuntime *objc_runtime = m_process->GetObjCLanguageRuntime(true); - if (objc_runtime != NULL && !objc_runtime->HasReadObjCLibrary()) - { - size_t num_modules = loaded_module_list.GetSize(); - for (size_t i = 0; i < num_modules; i++) - { - if (objc_runtime->IsModuleObjCLibrary (loaded_module_list.GetModuleAtIndex (i))) - { - objc_runtime->ReadObjCLibrary (loaded_module_list.GetModuleAtIndex (i)); - break; - } - } - } if (log) loaded_module_list.LogUUIDAndPaths (log, "DynamicLoaderMacOSXDYLD::ModulesDidLoad"); m_process->GetTarget().ModulesDidLoad (loaded_module_list); Index: lldb/trunk/source/Target/Target.cpp =================================================================== --- lldb/trunk/source/Target/Target.cpp +++ lldb/trunk/source/Target/Target.cpp @@ -1259,6 +1259,24 @@ if (m_process_sp) { m_process_sp->ModulesDidLoad (module_list); + + // This assumes there can only be one libobjc loaded. + ObjCLanguageRuntime *objc_runtime = m_process_sp->GetObjCLanguageRuntime (); + if (objc_runtime && !objc_runtime->HasReadObjCLibrary ()) + { + Mutex::Locker locker (module_list.GetMutex ()); + + size_t num_modules = module_list.GetSize(); + for (size_t i = 0; i < num_modules; i++) + { + auto mod = module_list.GetModuleAtIndex (i); + if (objc_runtime->IsModuleObjCLibrary (mod)) + { + objc_runtime->ReadObjCLibrary (mod); + break; + } + } + } } BroadcastEvent (eBroadcastBitModulesLoaded, new TargetEventData (this->shared_from_this(), module_list)); }