Lines Matching +full:client +full:- +full:id
1 //===-- llvm/Debuginfod/Debuginfod.cpp - Debuginfod client library --------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 /// This file contains several definitions for the debuginfod client and server.
12 /// For the client, this file defines the fetchInfo function. For the server,
16 /// debuginfo, source file) associated with a build-id from debuginfod servers.
22 //===----------------------------------------------------------------------===//
63 static std::string buildIDToString(BuildIDRef ID) {
64 return llvm::toHex(ID, /*LowerCase=*/true);
81 .split(DebuginfodUrls.value(), " ", -1, false);
95 /// Finds a default local file caching directory for the debuginfod client,
105 sys::path::append(CacheDirectory, "llvm-debuginfod", "client");
123 std::string getDebuginfodSourceUrlPath(BuildIDRef ID,
127 buildIDToString(ID), "source",
132 Expected<std::string> getCachedOrDownloadSource(BuildIDRef ID,
134 std::string UrlPath = getDebuginfodSourceUrlPath(ID, SourceFilePath);
138 std::string getDebuginfodExecutableUrlPath(BuildIDRef ID) {
141 buildIDToString(ID), "executable");
145 Expected<std::string> getCachedOrDownloadExecutable(BuildIDRef ID) {
146 std::string UrlPath = getDebuginfodExecutableUrlPath(ID);
150 std::string getDebuginfodDebuginfoUrlPath(BuildIDRef ID) {
153 buildIDToString(ID), "debuginfo");
157 Expected<std::string> getCachedOrDownloadDebuginfo(BuildIDRef ID) {
158 std::string UrlPath = getDebuginfodDebuginfoUrlPath(ID);
185 HTTPClient &Client;
189 StreamedHTTPResponseHandler(CreateStreamFn CreateStream, HTTPClient &Client)
190 : CreateStream(CreateStream), Client(Client) {}
200 unsigned Code = Client.responseCode();
209 *FileStream->OS << BodyChunk;
213 // An over-accepting simplification of the HTTP RFC 7230 spec.
235 for (StringRef Line : llvm::split((*HeadersFile)->getBuffer(), '\n')) {
256 "llvmcache-" + UniqueKey);
259 localCache("Debuginfod-client", ".debuginfod-client", CacheDirectoryPath);
276 "No working HTTP client is available.");
281 "A working HTTP client is available, but it is not initialized. To "
285 HTTPClient Client;
286 Client.setTimeout(Timeout);
295 [&]() { return CacheAddStream(Task, ""); }, Client);
298 Error Err = Client.perform(Request, Handler);
302 unsigned Code = Client.responseCode();
317 return createStringError(errc::argument_out_of_domain, "build id not found");
420 IteratorGroup.async([&, this]() -> void {
430 FilePath = I->path();
446 if (!Bin->isObject())
449 // TODO: Support non-ELF binaries
455 BuildIDRef ID = getBuildID(Object);
456 if (ID.empty())
459 std::string IDString = buildIDToString(ID);
460 if (Object->hasDebugInfo()) {
478 DebuginfodCollection::getBinaryPath(BuildIDRef ID) {
479 Log.push("getting binary path of ID " + buildIDToString(ID));
481 auto Loc = Binaries.find(buildIDToString(ID));
483 std::string Path = Loc->getValue();
490 DebuginfodCollection::getDebugBinaryPath(BuildIDRef ID) {
491 Log.push("getting debug binary path of ID " + buildIDToString(ID));
493 auto Loc = DebugBinaries.find(buildIDToString(ID));
495 std::string Path = Loc->getValue();
501 Expected<std::string> DebuginfodCollection::findBinaryPath(BuildIDRef ID) {
503 // Check collection; perform on-demand update if stale.
504 Expected<std::optional<std::string>> PathOrErr = getBinaryPath(ID);
514 PathOrErr = getBinaryPath(ID);
525 Expected<std::string> PathOrErr = getCachedOrDownloadExecutable(ID);
530 return findDebugBinaryPath(ID);
533 Expected<std::string> DebuginfodCollection::findDebugBinaryPath(BuildIDRef ID) {
534 // Check collection; perform on-demand update if stale.
535 Expected<std::optional<std::string>> PathOrErr = getDebugBinaryPath(ID);
545 PathOrErr = getBinaryPath(ID);
555 return getCachedOrDownloadDebuginfo(ID);
567 {404, "text/plain", "Build ID is not a hex string\n"});
570 object::BuildID ID(IDString.begin(), IDString.end());
571 Expected<std::string> PathOrErr = Collection.findDebugBinaryPath(ID);
574 Request.setResponse({404, "text/plain", "Build ID not found\n"});
585 {404, "text/plain", "Build ID is not a hex string\n"});
588 object::BuildID ID(IDString.begin(), IDString.end());
589 Expected<std::string> PathOrErr = Collection.findBinaryPath(ID);
592 Request.setResponse({404, "text/plain", "Build ID not found\n"});