18#include "llvm/ADT/STLExtras.h"
19#include "llvm/ADT/SmallSet.h"
20#include "llvm/Support/ThreadPool.h"
28 os <<
"binary not found";
32 return std::make_error_code(std::errc::no_such_file_or_directory);
35llvm::Expected<SymbolLocator::Result>
69 return llvm::make_error<NotFound>();
75static std::optional<SymbolLocator::Result>
82 std::optional<ModuleSpec> found = request.
platform->FindModuleFiles(
91llvm::Expected<SymbolLocator::Result>
94 if (std::optional<Result> answer =
AskPlatform(request, search_paths))
95 return std::move(*answer);
99std::vector<llvm::Expected<SymbolLocator::Result>>
103 std::vector<std::optional<llvm::Expected<Result>>> slots(requests.size());
104 std::vector<size_t> remaining;
106 if (!requests.empty()) {
108 Progress progress(
"Locating binaries",
"", requests.size(),
112 for (
auto [i, request] : llvm::enumerate(requests)) {
113 if (std::optional<Result> answer =
AskPlatform(request, search_paths)) {
114 slots[i] = std::move(*answer);
115 progress.
Increment(1, request.description);
117 remaining.push_back(i);
121 auto locate = [&](
size_t i) {
123 progress.
Increment(1, requests[i].description);
127 if (parallel && remaining.size() > 1) {
129 for (
size_t i : remaining)
130 task_group.async(locate, i);
133 for (
size_t i : remaining)
138 std::vector<llvm::Expected<Result>> results;
139 results.reserve(slots.size());
140 for (std::optional<llvm::Expected<Result>> &slot : slots) {
141 assert(slot &&
"every request has a result");
142 results.emplace_back(std::move(*slot));
148 static llvm::SmallSet<UUID, 8> g_seen_uuids;
149 static std::mutex g_mutex;
151 auto lookup = [=]() {
153 std::lock_guard<std::mutex> guard(g_mutex);
154 if (g_seen_uuids.count(uuid))
156 g_seen_uuids.insert(uuid);
static llvm::raw_ostream & error(Stream &strm)
static std::optional< SymbolLocator::Result > AskPlatform(const SymbolLocator::Request &request, const FileSpecList &search_paths)
static llvm::ThreadPoolInterface & GetThreadPool()
Shared thread pool. Use only with ThreadPoolTaskGroup.
static void ReportSymbolChange(const ModuleSpec &module_spec)
bool Exists(const FileSpec &file_spec) const
Returns whether the given file exists.
static FileSystem & Instance()
static ModuleListProperties & GetGlobalModuleListProperties()
FileSpec & GetSymbolFileSpec()
static bool DownloadObjectAndSymbolFile(ModuleSpec &module_spec, Status &error, bool force_lookup=true, bool copy_executable=true)
static FileSpec LocateExecutableSymbolFile(const ModuleSpec &module_spec, const FileSpecList &default_search_paths, StatisticsMap &map)
static ModuleSpec LocateExecutableObjectFile(const ModuleSpec &module_spec, StatisticsMap &map)
A Progress indicator helper class.
void Increment(uint64_t amount=1, std::optional< std::string > updated_detail={})
Increment the progress and send a notification to the installed callback.
static constexpr std::chrono::milliseconds kDefaultHighFrequencyReportTime
The default report time for high frequency progress reports.
std::error_code convertToErrorCode() const override
void log(llvm::raw_ostream &os) const override
static void DownloadSymbolFileAsync(const UUID &uuid)
Locate the symbol file for the given UUID on a background thread.
static llvm::Expected< Result > Locate(const Request &request, const FileSpecList &search_paths)
Find a binary and, if possible, its symbols.
static llvm::Expected< Result > LocateWithPlugins(const Request &request, const FileSpecList &search_paths)
Must stay callable concurrently.
Represents UUID's of various sizes.
A class that represents a running process on the host machine.
@ eSymbolDownloadBackground
@ eSymbolDownloadForeground
One binary to search for.
lldb::PlatformSP platform
A platform that may know where the binary is.
ModuleSpec module_spec
What to look for.
bool external_lookup
Allow contacting an external symbol server when the local searches come up empty.
std::optional< llvm::Error > symbol_error
What an external symbol server had to say about the symbols, even though the binary itself was found.
StatisticsMap statistics
Where the time went, to be merged into the Module once it exists.
ModuleSpec module_spec
The binary, and its symbol file if there is one to be had.