Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h @@ -38,6 +38,9 @@ Insert (const lldb_private::ConstString& name, const DIERef& die_ref); void + Append (const NameToDIE& other); + + void Finalize(); size_t Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp @@ -83,3 +83,14 @@ break; } } + +void +NameToDIE::Append (const NameToDIE& other) +{ + const uint32_t size = other.m_map.GetSize(); + for (uint32_t i = 0; i < size; ++i) + { + m_map.Append(other.m_map.GetCStringAtIndexUnchecked (i), + other.m_map.GetValueAtIndexUnchecked (i)); + } +} Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -50,6 +50,8 @@ #include "lldb/Target/Language.h" +#include "lldb/Utility/TaskPool.h" + #include "DWARFASTParser.h" #include "DWARFCompileUnit.h" #include "DWARFDebugAbbrev.h" @@ -2035,40 +2037,72 @@ "SymbolFileDWARF::Index (%s)", GetObjectFile()->GetFileSpec().GetFilename().AsCString("")); + + DWARFDebugInfo* debug_info = DebugInfo(); if (debug_info) { - uint32_t cu_idx = 0; const uint32_t num_compile_units = GetNumCompileUnits(); - for (cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) + std::vector function_basename_index(num_compile_units); + std::vector function_fullname_index(num_compile_units); + std::vector function_method_index(num_compile_units); + std::vector function_selector_index(num_compile_units); + std::vector objc_class_selectors_index(num_compile_units); + std::vector global_index(num_compile_units); + std::vector type_index(num_compile_units); + std::vector namespace_index(num_compile_units); + + auto parser_fn = [this, + debug_info, + &function_basename_index, + &function_fullname_index, + &function_method_index, + &function_selector_index, + &objc_class_selectors_index, + &global_index, + &type_index, + &namespace_index](uint32_t cu_idx) { DWARFCompileUnit* dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx); + bool clear_dies = dwarf_cu->ExtractDIEsIfNeeded(false) > 1; - bool clear_dies = dwarf_cu->ExtractDIEsIfNeeded (false) > 1; + dwarf_cu->Index(function_basename_index[cu_idx], + function_fullname_index[cu_idx], + function_method_index[cu_idx], + function_selector_index[cu_idx], + objc_class_selectors_index[cu_idx], + global_index[cu_idx], + type_index[cu_idx], + namespace_index[cu_idx]); - dwarf_cu->Index (m_function_basename_index, - m_function_fullname_index, - m_function_method_index, - m_function_selector_index, - m_objc_class_selectors_index, - m_global_index, - m_type_index, - m_namespace_index); - // Keep memory down by clearing DIEs if this generate function // caused them to be parsed if (clear_dies) - dwarf_cu->ClearDIEs (true); - } - - m_function_basename_index.Finalize(); - m_function_fullname_index.Finalize(); - m_function_method_index.Finalize(); - m_function_selector_index.Finalize(); - m_objc_class_selectors_index.Finalize(); - m_global_index.Finalize(); - m_type_index.Finalize(); - m_namespace_index.Finalize(); + dwarf_cu->ClearDIEs(true); + }; + + std::vector> results; + for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) + results.emplace_back(TaskPool::AddTask(parser_fn, cu_idx)); + for (auto& f : results) + f.wait(); + + auto merge_fn = [](NameToDIE& target, const std::vector& sources) + { + for (const auto& src : sources) + target.Append(src); + target.Finalize(); + }; + + TaskPool::RunTasks( + [&]() { merge_fn(m_function_basename_index, function_basename_index); }, + [&]() { merge_fn(m_function_fullname_index, function_fullname_index); }, + [&]() { merge_fn(m_function_method_index, function_method_index); }, + [&]() { merge_fn(m_function_selector_index, function_selector_index); }, + [&]() { merge_fn(m_objc_class_selectors_index, objc_class_selectors_index); }, + [&]() { merge_fn(m_global_index, global_index); }, + [&]() { merge_fn(m_type_index, type_index); }, + [&]() { merge_fn(m_namespace_index, namespace_index); }); #if defined (ENABLE_DEBUG_PRINTF) StreamFile s(stdout, false);