Skip to content

Commit 4a4a355

Browse files
author
Tom Yang
committed
parallelize dyld for attach scenario
1 parent d0f9fad commit 4a4a355

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -746,19 +746,31 @@ void DynamicLoaderPOSIXDYLD::LoadAllCurrentModules() {
746746
m_process->PrefetchModuleSpecs(
747747
module_names, m_process->GetTarget().GetArchitecture().GetTriple());
748748

749-
for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I) {
750-
ModuleSP module_sp =
751-
LoadModuleAtAddress(I->file_spec, I->link_addr, I->base_addr, true);
749+
auto load_module_fn = [this, &module_list,
750+
&log](const DYLDRendezvous::SOEntry &so_entry) {
751+
ModuleSP module_sp = LoadModuleAtAddress(
752+
so_entry.file_spec, so_entry.link_addr, so_entry.base_addr, true);
752753
if (module_sp.get()) {
753754
LLDB_LOG(log, "LoadAllCurrentModules loading module: {0}",
754-
I->file_spec.GetFilename());
755+
so_entry.file_spec.GetFilename());
755756
module_list.Append(module_sp);
756757
} else {
757758
Log *log = GetLog(LLDBLog::DynamicLoader);
758759
LLDB_LOGF(
759760
log,
760761
"DynamicLoaderPOSIXDYLD::%s failed loading module %s at 0x%" PRIx64,
761-
__FUNCTION__, I->file_spec.GetPath().c_str(), I->base_addr);
762+
__FUNCTION__, so_entry.file_spec.GetPath().c_str(),
763+
so_entry.base_addr);
764+
}
765+
};
766+
if (GetGlobalPluginProperties().GetParallelModuleLoad()) {
767+
llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool());
768+
for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I)
769+
task_group.async(load_module_fn, *I);
770+
task_group.wait();
771+
} else {
772+
for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I) {
773+
load_module_fn(*I);
762774
}
763775
}
764776

0 commit comments

Comments
 (0)