[PATCH] D114846: [llvm] [DebugInfo] LLVM debuginfod server. (WIP)
Noah Shutty via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 25 18:16:23 PST 2022
noajshu updated this revision to Diff 403097.
noajshu added a comment.
Set `llvm-debuginfod` to use the hardware concurrency by default or if `-c 0` is passed.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114846/new/
https://reviews.llvm.org/D114846
Files:
llvm/tools/llvm-debuginfod/CMakeLists.txt
llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp
Index: llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp
===================================================================
--- /dev/null
+++ llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp
@@ -0,0 +1,78 @@
+//===-- llvm-debuginfod-find.cpp - Simple CLI for libdebuginfod-client ----===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the llvm-debuginfod-find tool. This tool
+/// queries the debuginfod servers in the DEBUGINFOD_URLS environment
+/// variable (delimited by space (" ")) for the executable,
+/// debuginfo, or specified source file of the binary matching the
+/// given build-id.
+///
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Debuginfod/Debuginfod.h"
+#include "llvm/Debuginfod/HTTPClient.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/ThreadPool.h"
+
+using namespace llvm;
+
+cl::OptionCategory DebuginfodCategory("llvm-debuginfod Options");
+
+static cl::list<std::string> ScanPaths(cl::Positional,
+ cl::desc("<Directories to scan>"),
+ cl::OneOrMore,
+ cl::cat(DebuginfodCategory));
+
+static cl::opt<unsigned>
+ Port("p", cl::init(0),
+ cl::desc("Port to listen on. Set to 0 to bind to any available port."),
+ cl::cat(DebuginfodCategory));
+
+static cl::opt<double>
+ ScanInterval("t", cl::init(10000),
+ cl::desc("Number of seconds to wait between subsequent scans "
+ "of the filesystem."),
+ cl::cat(DebuginfodCategory));
+
+static cl::opt<size_t>
+ MaxConcurrency("c", cl::init(0),
+ cl::desc("Maximum number of files to scan concurrently. If "
+ "0, use the hardware concurrency."),
+ cl::cat(DebuginfodCategory));
+
+ExitOnError ExitOnErr;
+
+int main(int argc, char **argv) {
+ InitLLVM X(argc, argv);
+ HTTPClient::initialize();
+ cl::HideUnrelatedOptions({&DebuginfodCategory});
+ cl::ParseCommandLineOptions(argc, argv);
+
+ SmallVector<StringRef, 1> Paths;
+ for (const std::string &Path : ScanPaths)
+ Paths.push_back(Path);
+
+ ThreadPool Pool(hardware_concurrency());
+ if (MaxConcurrency == 0)
+ MaxConcurrency = hardware_concurrency().compute_thread_count();
+
+ DebuginfodCollection Collection(Paths, Pool, MaxConcurrency);
+ DebuginfodServer Server(Collection);
+
+ if (!Port)
+ Port = ExitOnErr(Server.Server.bind());
+ else
+ ExitOnErr(Server.Server.bind(Port));
+ outs() << "Listening on port " << Port << "\n";
+ Pool.async([&]() { ExitOnErr(Server.Server.listen()); });
+ ExitOnErr(Collection.updateForever(
+ std::chrono::milliseconds(static_cast<int>(ScanInterval * 1000))));
+ Pool.wait();
+}
Index: llvm/tools/llvm-debuginfod/CMakeLists.txt
===================================================================
--- /dev/null
+++ llvm/tools/llvm-debuginfod/CMakeLists.txt
@@ -0,0 +1,10 @@
+set(LLVM_LINK_COMPONENTS
+ Debuginfod
+ Support
+ )
+add_llvm_tool(llvm-debuginfod
+ llvm-debuginfod.cpp
+ )
+if(LLVM_INSTALL_BINUTILS_SYMLINKS)
+ add_llvm_tool_symlink(debuginfod llvm-debuginfod)
+endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114846.403097.patch
Type: text/x-patch
Size: 3541 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220126/5ed39a4d/attachment.bin>
More information about the llvm-commits
mailing list