diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index ed733f2645c3..d6ad333957e1 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -62,6 +62,7 @@ #include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/SetVector.h" +#include "llvm/Support/ThreadPool.h" #include #include @@ -1623,6 +1624,17 @@ void Target::NotifyModulesRemoved(lldb_private::ModuleList &module_list) { void Target::ModulesDidLoad(ModuleList &module_list) { const size_t num_images = module_list.GetSize(); if (m_valid && num_images) { + if (GetPreloadSymbols()) { + // Try to preload symbols in parallel. + llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool()); + auto preload_symbols_fn = [&](size_t idx) { + ModuleSP module_sp(module_list.GetModuleAtIndex(idx)); + module_sp->PreloadSymbols(); + }; + for (size_t idx = 0; idx < num_images; ++idx) + task_group.async(preload_symbols_fn, idx); + task_group.wait(); + } for (size_t idx = 0; idx < num_images; ++idx) { ModuleSP module_sp(module_list.GetModuleAtIndex(idx)); LoadScriptingResourceForModule(module_sp, this); @@ -2170,11 +2182,6 @@ ModuleSP Target::GetOrCreateModule(const ModuleSpec &module_spec, bool notify, }); } - // Preload symbols outside of any lock, so hopefully we can do this for - // each library in parallel. - if (GetPreloadSymbols()) - module_sp->PreloadSymbols(); - llvm::SmallVector replaced_modules; for (ModuleSP &old_module_sp : old_modules) { if (m_images.GetIndexForModule(old_module_sp.get()) !=