diff --git a/llvm/test/CMakeLists.txt b/llvm/test/CMakeLists.txt --- a/llvm/test/CMakeLists.txt +++ b/llvm/test/CMakeLists.txt @@ -6,6 +6,7 @@ LLVM_ENABLE_FFI LLVM_ENABLE_THREADS LLVM_ENABLE_CURL + LLVM_ENABLE_HTTPLIB LLVM_ENABLE_ZLIB LLVM_ENABLE_LIBXML2 LLVM_INCLUDE_GO_TESTS diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py --- a/llvm/test/lit.cfg.py +++ b/llvm/test/lit.cfg.py @@ -159,7 +159,7 @@ tools.extend([ 'dsymutil', 'lli', 'lli-child-target', 'llvm-ar', 'llvm-as', 'llvm-addr2line', 'llvm-bcanalyzer', 'llvm-bitcode-strip', 'llvm-config', - 'llvm-cov', 'llvm-cxxdump', 'llvm-cvtres', 'llvm-debuginfod-find', + 'llvm-cov', 'llvm-cxxdump', 'llvm-cvtres', 'llvm-debuginfod-find', 'llvm-debuginfod', 'llvm-diff', 'llvm-dis', 'llvm-dwarfdump', 'llvm-dlltool', 'llvm-exegesis', 'llvm-extract', 'llvm-isel-fuzzer', 'llvm-ifs', 'llvm-install-name-tool', 'llvm-jitlink', 'llvm-opt-fuzzer', 'llvm-lib', @@ -478,4 +478,3 @@ if 'aix' in config.target_triple: for directory in ('/CodeGen/X86', '/DebugInfo', '/DebugInfo/X86', '/DebugInfo/Generic', '/LTO/X86', '/Linker'): exclude_unsupported_files_for_aix(config.test_source_root + directory) - diff --git a/llvm/test/lit.site.cfg.py.in b/llvm/test/lit.site.cfg.py.in --- a/llvm/test/lit.site.cfg.py.in +++ b/llvm/test/lit.site.cfg.py.in @@ -40,6 +40,7 @@ config.have_libxar = @LLVM_HAVE_LIBXAR@ config.have_libxml2 = @LLVM_ENABLE_LIBXML2@ config.have_curl = @LLVM_ENABLE_CURL@ +config.have_httplib = @LLVM_ENABLE_HTTPLIB@ config.have_dia_sdk = @LLVM_ENABLE_DIA_SDK@ config.enable_ffi = @LLVM_ENABLE_FFI@ config.build_examples = @LLVM_BUILD_EXAMPLES@ diff --git a/llvm/test/tools/llvm-debuginfod/Inputs/main-debug.exe b/llvm/test/tools/llvm-debuginfod/Inputs/main-debug.exe new file mode 100755 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@ ScanPaths(cl::Positional, + cl::desc(""), + cl::cat(DebuginfodCategory)); + +static cl::opt + 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 + HostInterface("i", cl::init("0.0.0.0"), + cl::desc("Host interface to bind to."), + cl::cat(DebuginfodCategory)); + +static cl::opt + ScanInterval("t", cl::init(300), + cl::desc("Number of seconds to wait between subsequent " + "automated scans of the filesystem."), + cl::cat(DebuginfodCategory)); + +static cl::opt MinInterval( + "m", cl::init(10), + cl::desc( + "Minimum number of seconds to wait before an on-demand update can be " + "triggered by a request for a buildid which is not in the collection."), + cl::cat(DebuginfodCategory)); + +static cl::opt + MaxConcurrency("c", cl::init(0), + cl::desc("Maximum number of files to scan concurrently. If " + "0, use the hardware concurrency."), + cl::cat(DebuginfodCategory)); + +static cl::opt VerboseLogging("v", cl::init(false), + cl::desc("Enable verbose logging."), + 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 Paths; + for (const std::string &Path : ScanPaths) + Paths.push_back(Path); + + ThreadPool Pool(hardware_concurrency(MaxConcurrency)); + DebuginfodLog Log; + DebuginfodCollection Collection(Paths, Log, Pool, MinInterval); + DebuginfodServer Server(Log, Collection); + + if (!Port) + Port = ExitOnErr(Server.Server.bind(HostInterface.c_str())); + else + ExitOnErr(Server.Server.bind(Port, HostInterface.c_str())); + + Log.push("Listening on port " + Twine(Port).str()); + + Pool.async([&]() { ExitOnErr(Server.Server.listen()); }); + Pool.async([&]() { + while (1) { + DebuginfodLogEntry Entry = Log.pop(); + if (VerboseLogging) { + outs() << Entry.Message << "\n"; + outs().flush(); + } + } + }); + if (Paths.size()) + ExitOnErr(Collection.updateForever(std::chrono::seconds(ScanInterval))); + Pool.wait(); + llvm_unreachable("The ThreadPool should never finish running its tasks."); +}