aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Debuginfod/Debuginfod.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Debuginfod/Debuginfod.cpp')
-rw-r--r--llvm/lib/Debuginfod/Debuginfod.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/llvm/lib/Debuginfod/Debuginfod.cpp b/llvm/lib/Debuginfod/Debuginfod.cpp
index 026f118bbf5b..2b0710b536ba 100644
--- a/llvm/lib/Debuginfod/Debuginfod.cpp
+++ b/llvm/lib/Debuginfod/Debuginfod.cpp
@@ -55,7 +55,11 @@ static std::string buildIDToString(BuildIDRef ID) {
return llvm::toHex(ID, /*LowerCase=*/true);
}
-Expected<SmallVector<StringRef>> getDefaultDebuginfodUrls() {
+bool canUseDebuginfod() {
+ return HTTPClient::isAvailable() && !getDefaultDebuginfodUrls().empty();
+}
+
+SmallVector<StringRef> getDefaultDebuginfodUrls() {
const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS");
if (DebuginfodUrlsEnv == nullptr)
return SmallVector<StringRef>();
@@ -126,13 +130,8 @@ Expected<std::string> getCachedOrDownloadArtifact(StringRef UniqueKey,
return CacheDirOrErr.takeError();
CacheDir = *CacheDirOrErr;
- Expected<SmallVector<StringRef>> DebuginfodUrlsOrErr =
- getDefaultDebuginfodUrls();
- if (!DebuginfodUrlsOrErr)
- return DebuginfodUrlsOrErr.takeError();
- SmallVector<StringRef> &DebuginfodUrls = *DebuginfodUrlsOrErr;
return getCachedOrDownloadArtifact(UniqueKey, UrlPath, CacheDir,
- DebuginfodUrls,
+ getDefaultDebuginfodUrls(),
getDefaultDebuginfodTimeout());
}
@@ -159,7 +158,8 @@ public:
Error StreamedHTTPResponseHandler::handleBodyChunk(StringRef BodyChunk) {
if (!FileStream) {
- if (Client.responseCode() != 200)
+ unsigned Code = Client.responseCode();
+ if (Code && Code != 200)
return Error::success();
Expected<std::unique_ptr<CachedFileStream>> FileStreamOrError =
CreateStream();
@@ -259,7 +259,8 @@ Expected<std::string> getCachedOrDownloadArtifact(
if (Err)
return std::move(Err);
- if (Client.responseCode() != 200)
+ unsigned Code = Client.responseCode();
+ if (Code && Code != 200)
continue;
// Return the path to the artifact on disk.