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#include "lldb/Host/Host.h"
14
15#include "llvm/ADT/SmallSet.h"
16#include "llvm/Support/ThreadPool.h"
17
18using namespace lldb;
19using namespace lldb_private;
20
21void SymbolLocator::DownloadSymbolFileAsync(const UUID &uuid) {
22 static llvm::SmallSet<UUID, 8> g_seen_uuids;
23 static std::mutex g_mutex;
24
25 auto lookup = [=]() {
26 {
27 std::lock_guard<std::mutex> guard(g_mutex);
28 if (g_seen_uuids.count(V: uuid))
29 return;
30 g_seen_uuids.insert(V: uuid);
31 }
32
33 Status error;
34 ModuleSpec module_spec;
35 module_spec.GetUUID() = uuid;
36 if (!PluginManager::DownloadObjectAndSymbolFile(module_spec, error,
37 /*force_lookup=*/true,
38 /*copy_executable=*/true))
39 return;
40
41 if (error.Fail())
42 return;
43
44 Debugger::ReportSymbolChange(module_spec);
45 };
46
47 switch (ModuleList::GetGlobalModuleListProperties().GetSymbolAutoDownload()) {
48 case eSymbolDownloadOff:
49 break;
50 case eSymbolDownloadBackground:
51 Debugger::GetThreadPool().async(F&: lookup);
52 break;
53 case eSymbolDownloadForeground:
54 lookup();
55 break;
56 };
57}
58

source code of lldb/source/Symbol/SymbolLocator.cpp