1 //===-- symbolLocator.cpp -------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "lldb/Symbol/SymbolLocator.h" 10 11 #include "lldb/Core/Debugger.h" 12 #include "lldb/Core/PluginManager.h" 13 14 #include "llvm/ADT/SmallSet.h" 15 #include "llvm/Support/ThreadPool.h" 16 17 using namespace lldb; 18 using namespace lldb_private; 19 20 void SymbolLocator::DownloadSymbolFileAsync(const UUID &uuid) { 21 if (!ModuleList::GetGlobalModuleListProperties().GetEnableBackgroundLookup()) 22 return; 23 24 static llvm::SmallSet<UUID, 8> g_seen_uuids; 25 static std::mutex g_mutex; 26 Debugger::GetThreadPool().async([=]() { 27 { 28 std::lock_guard<std::mutex> guard(g_mutex); 29 if (g_seen_uuids.count(uuid)) 30 return; 31 g_seen_uuids.insert(uuid); 32 } 33 34 Status error; 35 ModuleSpec module_spec; 36 module_spec.GetUUID() = uuid; 37 if (!PluginManager::DownloadObjectAndSymbolFile(module_spec, error, 38 /*force_lookup=*/true, 39 /*copy_executable=*/false)) 40 return; 41 42 if (error.Fail()) 43 return; 44 45 Debugger::ReportSymbolChange(module_spec); 46 }); 47 } 48