Index: lldb/source/Target/Process.cpp =================================================================== --- lldb/source/Target/Process.cpp +++ lldb/source/Target/Process.cpp @@ -5757,6 +5757,7 @@ } void Process::ModulesDidLoad(ModuleList &module_list) { + // Inform the system runtime of the modified modules. SystemRuntime *sys_runtime = GetSystemRuntime(); if (sys_runtime) { sys_runtime->ModulesDidLoad(module_list); @@ -5764,34 +5765,19 @@ GetJITLoaders().ModulesDidLoad(module_list); - // Give runtimes a chance to be created. + // Give the instrumentation runtimes a chance to be created before informing + // them of the modified modules. InstrumentationRuntime::ModulesDidLoad(module_list, this, m_instrumentation_runtimes); - - // Tell runtimes about new modules. - for (auto pos = m_instrumentation_runtimes.begin(); - pos != m_instrumentation_runtimes.end(); ++pos) { - InstrumentationRuntimeSP runtime = pos->second; - runtime->ModulesDidLoad(module_list); + for (auto &runtime : m_instrumentation_runtimes) { + runtime.second->ModulesDidLoad(module_list); } - // Let any language runtimes we have already created know about the modules - // that loaded. - - // Iterate over a copy of this language runtime list in case the language - // runtime ModulesDidLoad somehow causes the language runtime to be - // unloaded. - { - std::lock_guard guard(m_language_runtimes_mutex); - LanguageRuntimeCollection language_runtimes(m_language_runtimes); - for (const auto &pair : language_runtimes) { - // We must check language_runtime_sp to make sure it is not nullptr as we - // might cache the fact that we didn't have a language runtime for a - // language. - LanguageRuntimeSP language_runtime_sp = pair.second; - if (language_runtime_sp) - language_runtime_sp->ModulesDidLoad(module_list); - } + // Give the language runtimes a chance to be created before informing them of + // the modified modules. + for (const lldb::LanguageType lang_type : Language::GetSupportedLanguages()) { + if (LanguageRuntime *runtime = GetLanguageRuntime(lang_type)) + runtime->ModulesDidLoad(module_list); } // If we don't have an operating system plug-in, try to load one since @@ -5799,7 +5785,7 @@ if (!m_os_up) LoadOperatingSystemPlugin(false); - // Give structured-data plugins a chance to see the modified modules. + // Inform the structured-data plugins of the modified modules. for (auto pair : m_structured_data_plugin_map) { if (pair.second) pair.second->ModulesDidLoad(*this, module_list);