[Lldb-commits] [lldb] [llvm] [lldb] Bring Debuginfod's StreamedHTTPResponseHandler to SymbolLocatorSymStore (PR #187687)
Stefan Gränitz via lldb-commits
lldb-commits at lists.llvm.org
Fri Mar 27 02:25:13 PDT 2026
https://github.com/weliveindetail updated https://github.com/llvm/llvm-project/pull/187687
>From ec60e43a6b568c6437d685b1d22487d32721abc8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <stefan.graenitz at gmail.com>
Date: Fri, 20 Mar 2026 11:48:05 +0100
Subject: [PATCH 1/4] [lldb] Hoist StreamedHTTPResponseHandler to SupportHTTP
and use it in SymbolLocatorSymStore
---
.../SymStore/SymbolLocatorSymStore.cpp | 48 ++++++++----------
.../HTTP/StreamedHTTPResponseHandler.h | 49 +++++++++++++++++++
llvm/lib/Debuginfod/Debuginfod.cpp | 48 +-----------------
llvm/lib/Support/HTTP/CMakeLists.txt | 1 +
.../HTTP/StreamedHTTPResponseHandler.cpp | 34 +++++++++++++
5 files changed, 106 insertions(+), 74 deletions(-)
create mode 100644 llvm/include/llvm/Support/HTTP/StreamedHTTPResponseHandler.h
create mode 100644 llvm/lib/Support/HTTP/StreamedHTTPResponseHandler.cpp
diff --git a/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp b/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp
index 884519b54acfd..f1b931d894aa7 100644
--- a/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp
+++ b/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp
@@ -18,11 +18,14 @@
#include "lldb/Utility/UUID.h"
#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Caching.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/HTTP/HTTPClient.h"
+#include "llvm/Support/HTTP/StreamedHTTPResponseHandler.h"
#include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
using namespace lldb;
using namespace lldb_private;
@@ -114,36 +117,11 @@ std::string formatSymStoreKey(const UUID &uuid) {
return llvm::toHex(bytes.slice(0, 16), LowerCase) + std::to_string(age);
}
-// This is a simple version of Debuginfod's StreamedHTTPResponseHandler. We
-// should consider reusing that once we introduce caching.
-class FileDownloadHandler : public llvm::HTTPResponseHandler {
-private:
- std::error_code m_ec;
- llvm::raw_fd_ostream m_stream;
-
-public:
- FileDownloadHandler(llvm::StringRef file) : m_stream(file.str(), m_ec) {}
- virtual ~FileDownloadHandler() = default;
-
- llvm::Error handleBodyChunk(llvm::StringRef data) override {
- // Propagate error from ctor.
- if (m_ec)
- return llvm::createStringError(m_ec, "Failed to open file for writing");
- m_stream.write(data.data(), data.size());
- if (std::error_code ec = m_stream.error())
- return llvm::createStringError(ec, "Error writing to file");
-
- return llvm::Error::success();
- }
-};
-
-llvm::Error downloadFileHTTP(llvm::StringRef url, FileDownloadHandler dest) {
+llvm::Error downloadFileHTTP(llvm::StringRef url, llvm::StringRef destPath) {
if (!llvm::HTTPClient::isAvailable())
return llvm::createStringError(
std::make_error_code(std::errc::not_supported),
"HTTP client is not available");
- llvm::HTTPRequest Request(url);
- Request.FollowRedirects = true;
llvm::HTTPClient Client;
@@ -151,7 +129,23 @@ llvm::Error downloadFileHTTP(llvm::StringRef url, FileDownloadHandler dest) {
// connect, send and receive.
Client.setTimeout(std::chrono::seconds(60));
- if (llvm::Error Err = Client.perform(Request, dest))
+ llvm::StreamedHTTPResponseHandler Handler(
+ [&]() -> llvm::Expected<std::unique_ptr<llvm::CachedFileStream>> {
+ std::error_code EC;
+ auto FDStream = std::make_unique<llvm::raw_fd_ostream>(destPath, EC);
+ if (EC)
+ return llvm::createStringError(EC, "Failed to open file for writing");
+ return std::make_unique<llvm::CachedFileStream>(std::move(FDStream),
+ destPath.str());
+ },
+ Client);
+
+ llvm::HTTPRequest Request(url);
+ Request.FollowRedirects = true;
+
+ if (llvm::Error Err = Client.perform(Request, Handler))
+ return Err;
+ if (llvm::Error Err = Handler.commit())
return Err;
unsigned ResponseCode = Client.responseCode();
diff --git a/llvm/include/llvm/Support/HTTP/StreamedHTTPResponseHandler.h b/llvm/include/llvm/Support/HTTP/StreamedHTTPResponseHandler.h
new file mode 100644
index 0000000000000..14ffab8aa1be3
--- /dev/null
+++ b/llvm/include/llvm/Support/HTTP/StreamedHTTPResponseHandler.h
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+/// An HTTPResponseHandler that streams the response body to a CachedFileStream.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_HTTP_STREAMEDHTTPRESPONSEHANDLER_H
+#define LLVM_SUPPORT_HTTP_STREAMEDHTTPRESPONSEHANDLER_H
+
+#include "llvm/Support/Caching.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/HTTP/HTTPClient.h"
+#include <functional>
+#include <memory>
+
+namespace llvm {
+
+/// A handler which streams the returned data to a CachedFileStream. The cache
+/// file is only created if a 200 OK status is observed.
+class StreamedHTTPResponseHandler : public HTTPResponseHandler {
+ using CreateStreamFn =
+ std::function<Expected<std::unique_ptr<CachedFileStream>>()>;
+ CreateStreamFn CreateStream;
+ HTTPClient &Client;
+ std::unique_ptr<CachedFileStream> FileStream;
+
+public:
+ StreamedHTTPResponseHandler(CreateStreamFn CreateStream, HTTPClient &Client)
+ : CreateStream(std::move(CreateStream)), Client(Client) {}
+
+ /// Must be called exactly once after the writes have been completed
+ /// but before the StreamedHTTPResponseHandler object is destroyed.
+ Error commit();
+
+ virtual ~StreamedHTTPResponseHandler() = default;
+
+ Error handleBodyChunk(StringRef BodyChunk) override;
+};
+
+} // end namespace llvm
+
+#endif // LLVM_SUPPORT_HTTP_STREAMEDHTTPRESPONSEHANDLER_H
diff --git a/llvm/lib/Debuginfod/Debuginfod.cpp b/llvm/lib/Debuginfod/Debuginfod.cpp
index 6847dc092dfdb..77de51d90a4eb 100644
--- a/llvm/lib/Debuginfod/Debuginfod.cpp
+++ b/llvm/lib/Debuginfod/Debuginfod.cpp
@@ -35,6 +35,7 @@
#include "llvm/Support/Error.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/HTTP/HTTPClient.h"
+#include "llvm/Support/HTTP/StreamedHTTPResponseHandler.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/ThreadPool.h"
@@ -174,53 +175,6 @@ Expected<std::string> getCachedOrDownloadArtifact(StringRef UniqueKey,
getDefaultDebuginfodTimeout());
}
-namespace {
-
-/// A simple handler which streams the returned data to a cache file. The cache
-/// file is only created if a 200 OK status is observed.
-class StreamedHTTPResponseHandler : public HTTPResponseHandler {
- using CreateStreamFn =
- std::function<Expected<std::unique_ptr<CachedFileStream>>()>;
- CreateStreamFn CreateStream;
- HTTPClient &Client;
- std::unique_ptr<CachedFileStream> FileStream;
-
-public:
- StreamedHTTPResponseHandler(CreateStreamFn CreateStream, HTTPClient &Client)
- : CreateStream(CreateStream), Client(Client) {}
-
- /// Must be called exactly once after the writes have been completed
- /// but before the StreamedHTTPResponseHandler object is destroyed.
- Error commit();
-
- virtual ~StreamedHTTPResponseHandler() = default;
-
- Error handleBodyChunk(StringRef BodyChunk) override;
-};
-
-} // namespace
-
-Error StreamedHTTPResponseHandler::handleBodyChunk(StringRef BodyChunk) {
- if (!FileStream) {
- unsigned Code = Client.responseCode();
- if (Code && Code != 200)
- return Error::success();
- Expected<std::unique_ptr<CachedFileStream>> FileStreamOrError =
- CreateStream();
- if (!FileStreamOrError)
- return FileStreamOrError.takeError();
- FileStream = std::move(*FileStreamOrError);
- }
- *FileStream->OS << BodyChunk;
- return Error::success();
-}
-
-Error StreamedHTTPResponseHandler::commit() {
- if (FileStream)
- return FileStream->commit();
- return Error::success();
-}
-
// An over-accepting simplification of the HTTP RFC 7230 spec.
static bool isHeader(StringRef S) {
StringRef Name;
diff --git a/llvm/lib/Support/HTTP/CMakeLists.txt b/llvm/lib/Support/HTTP/CMakeLists.txt
index e7a0e6fe34110..f8e4b87539931 100644
--- a/llvm/lib/Support/HTTP/CMakeLists.txt
+++ b/llvm/lib/Support/HTTP/CMakeLists.txt
@@ -16,6 +16,7 @@ endif()
add_llvm_component_library(LLVMSupportHTTP
HTTPClient.cpp
HTTPServer.cpp
+ StreamedHTTPResponseHandler.cpp
LINK_LIBS
${imported_libs}
diff --git a/llvm/lib/Support/HTTP/StreamedHTTPResponseHandler.cpp b/llvm/lib/Support/HTTP/StreamedHTTPResponseHandler.cpp
new file mode 100644
index 0000000000000..5a0e0e6355684
--- /dev/null
+++ b/llvm/lib/Support/HTTP/StreamedHTTPResponseHandler.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Support/HTTP/StreamedHTTPResponseHandler.h"
+
+namespace llvm {
+
+Error StreamedHTTPResponseHandler::handleBodyChunk(StringRef BodyChunk) {
+ if (!FileStream) {
+ unsigned Code = Client.responseCode();
+ if (Code && Code != 200)
+ return Error::success();
+ Expected<std::unique_ptr<CachedFileStream>> FileStreamOrError =
+ CreateStream();
+ if (!FileStreamOrError)
+ return FileStreamOrError.takeError();
+ FileStream = std::move(*FileStreamOrError);
+ }
+ *FileStream->OS << BodyChunk;
+ return Error::success();
+}
+
+Error StreamedHTTPResponseHandler::commit() {
+ if (FileStream)
+ return FileStream->commit();
+ return Error::success();
+}
+
+} // namespace llvm
>From c3d5adb2572143516ec4824d037c3f2f1722f017 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <stefan.graenitz at gmail.com>
Date: Fri, 20 Mar 2026 12:20:23 +0100
Subject: [PATCH 2/4] Handle file not found separately and print warnings for
failures
---
.../SymStore/SymbolLocatorSymStore.cpp | 93 ++++++++++---------
lldb/test/API/symstore/TestSymStore.py | 11 +++
2 files changed, 59 insertions(+), 45 deletions(-)
diff --git a/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp b/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp
index f1b931d894aa7..02c568816f706 100644
--- a/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp
+++ b/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp
@@ -117,47 +117,6 @@ std::string formatSymStoreKey(const UUID &uuid) {
return llvm::toHex(bytes.slice(0, 16), LowerCase) + std::to_string(age);
}
-llvm::Error downloadFileHTTP(llvm::StringRef url, llvm::StringRef destPath) {
- if (!llvm::HTTPClient::isAvailable())
- return llvm::createStringError(
- std::make_error_code(std::errc::not_supported),
- "HTTP client is not available");
-
- llvm::HTTPClient Client;
-
- // TODO: Since PDBs can be huge, we should distinguish between resolve,
- // connect, send and receive.
- Client.setTimeout(std::chrono::seconds(60));
-
- llvm::StreamedHTTPResponseHandler Handler(
- [&]() -> llvm::Expected<std::unique_ptr<llvm::CachedFileStream>> {
- std::error_code EC;
- auto FDStream = std::make_unique<llvm::raw_fd_ostream>(destPath, EC);
- if (EC)
- return llvm::createStringError(EC, "Failed to open file for writing");
- return std::make_unique<llvm::CachedFileStream>(std::move(FDStream),
- destPath.str());
- },
- Client);
-
- llvm::HTTPRequest Request(url);
- Request.FollowRedirects = true;
-
- if (llvm::Error Err = Client.perform(Request, Handler))
- return Err;
- if (llvm::Error Err = Handler.commit())
- return Err;
-
- unsigned ResponseCode = Client.responseCode();
- if (ResponseCode != 200) {
- return llvm::createStringError(std::make_error_code(std::errc::io_error),
- "HTTP request failed with status code " +
- std::to_string(ResponseCode));
- }
-
- return llvm::Error::success();
-}
-
bool has_unsafe_characters(llvm::StringRef s) {
for (unsigned char c : s) {
// RFC 3986 unreserved characters are safe for file names and URLs.
@@ -210,13 +169,57 @@ requestFileFromSymStoreServerHTTP(llvm::StringRef base_url, llvm::StringRef key,
// Server has same directory structure with forward slashes as separators.
std::string source_url =
llvm::formatv("{0}/{1}/{2}/{1}", base_url, pdb_name, key);
- if (llvm::Error err = downloadFileHTTP(source_url, cache_file.str())) {
- LLDB_LOG_ERROR(log, std::move(err),
- "Failed to download from SymStore '{1}': {0}", source_url);
+
+ if (!llvm::HTTPClient::isAvailable()) {
+ Debugger::ReportWarning("HTTP client is not available");
+ return {};
+ }
+
+ llvm::HTTPClient Client;
+ // TODO: Since PDBs can be huge, we should distinguish between resolve,
+ // connect, send and receive.
+ Client.setTimeout(std::chrono::seconds(60));
+
+ llvm::StreamedHTTPResponseHandler Handler(
+ [dest = cache_file.str().str()]()
+ -> llvm::Expected<std::unique_ptr<llvm::CachedFileStream>> {
+ std::error_code EC;
+ auto FDStream = std::make_unique<llvm::raw_fd_ostream>(dest, EC);
+ if (EC)
+ return llvm::createStringError(EC, "Failed to open file for writing");
+ return std::make_unique<llvm::CachedFileStream>(std::move(FDStream),
+ dest);
+ },
+ Client);
+
+ llvm::HTTPRequest Request(source_url);
+ Request.FollowRedirects = true;
+
+ if (llvm::Error Err = Client.perform(Request, Handler)) {
+ Debugger::ReportWarning(
+ llvm::formatv("Failed to download from SymStore '{0}': {1}", source_url,
+ llvm::toString(std::move(Err))));
+ return {};
+ }
+ if (llvm::Error Err = Handler.commit()) {
+ Debugger::ReportWarning(
+ llvm::formatv("Failed to download from SymStore '{0}': {1}", source_url,
+ llvm::toString(std::move(Err))));
return {};
}
- return FileSpec(cache_file.str());
+ unsigned ResponseCode = Client.responseCode();
+ switch (ResponseCode) {
+ case 404:
+ return {}; // file not found
+ case 200:
+ return FileSpec(cache_file.str()); // success
+ default:
+ Debugger::ReportWarning(llvm::formatv(
+ "Failed to download from SymStore '{0}': response code {1}", source_url,
+ ResponseCode));
+ return {};
+ }
}
std::optional<FileSpec> findFileInLocalSymStore(llvm::StringRef root_dir,
diff --git a/lldb/test/API/symstore/TestSymStore.py b/lldb/test/API/symstore/TestSymStore.py
index 13d0cc1666c84..63f7f10a13de7 100644
--- a/lldb/test/API/symstore/TestSymStore.py
+++ b/lldb/test/API/symstore/TestSymStore.py
@@ -140,6 +140,17 @@ def test_local_dir(self):
self.runCmd(f"settings set plugin.symbol-locator.symstore.urls {dir}")
self.try_breakpoint(exe, should_have_loc=True)
+ def test_http_not_found(self):
+ """
+ Check that a 404 response from an HTTP SymStore is handled gracefully.
+ """
+ exe, sym = self.build_inferior()
+ with MockedSymStore(self, exe, sym) as symstore_dir:
+ os.makedirs(f"{symstore_dir}_empty", exist_ok=False)
+ with HTTPServer(f"{symstore_dir}_empty") as url:
+ self.runCmd(f"settings set plugin.symbol-locator.symstore.urls {url}")
+ self.try_breakpoint(exe, should_have_loc=False)
+
# TODO: Add test coverage for common HTTPS security scenarios, e.g. self-signed
# certs, non-HTTPS redirects, etc.
def test_http(self):
>From 8fb6b57cf02617200b28beea2cc0f765ee8bc617 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <stefan.graenitz at gmail.com>
Date: Fri, 20 Mar 2026 15:56:16 +0100
Subject: [PATCH 3/4] Minor fixes
---
.../SymbolLocator/SymStore/SymbolLocatorSymStore.cpp | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp b/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp
index 02c568816f706..7c2b4459ffcb7 100644
--- a/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp
+++ b/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp
@@ -133,14 +133,12 @@ bool has_unsafe_characters(llvm::StringRef s) {
return s == "." || s == "..";
}
-// TODO: This is a dump initial implementation: It always downloads the file, it
-// doesn't validate the result, it doesn't employ proper buffering for large
-// files.
+// TODO: This is a dump initial implementation: It always downloads the file and
+// doesn't validate the result.
std::optional<FileSpec>
requestFileFromSymStoreServerHTTP(llvm::StringRef base_url, llvm::StringRef key,
llvm::StringRef pdb_name) {
using namespace llvm::sys;
- Log *log = GetLog(LLDBLog::Symbols);
// Make sure URL will be valid, portable, and compatible with symbol servers.
if (has_unsafe_characters(pdb_name)) {
@@ -193,8 +191,6 @@ requestFileFromSymStoreServerHTTP(llvm::StringRef base_url, llvm::StringRef key,
Client);
llvm::HTTPRequest Request(source_url);
- Request.FollowRedirects = true;
-
if (llvm::Error Err = Client.perform(Request, Handler)) {
Debugger::ReportWarning(
llvm::formatv("Failed to download from SymStore '{0}': {1}", source_url,
>From 39ae9a78d61ebfb387fe26918990bea10ab2f0c6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <stefan.graenitz at gmail.com>
Date: Fri, 27 Mar 2026 09:54:12 +0100
Subject: [PATCH 4/4] Style fixes
---
.../SymStore/SymbolLocatorSymStore.cpp | 65 +++++++++----------
1 file changed, 32 insertions(+), 33 deletions(-)
diff --git a/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp b/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp
index 7c2b4459ffcb7..394589b0394fc 100644
--- a/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp
+++ b/lldb/source/Plugins/SymbolLocator/SymStore/SymbolLocatorSymStore.cpp
@@ -110,14 +110,14 @@ namespace {
// SymStore key is a string with no separators and age as decimal:
// 12345678123456789ABCDEF0123456781
//
-std::string formatSymStoreKey(const UUID &uuid) {
+std::string FormatSymStoreKey(const UUID &uuid) {
llvm::ArrayRef<uint8_t> bytes = uuid.GetBytes();
uint32_t age = llvm::support::endian::read32be(bytes.data() + 16);
- constexpr bool LowerCase = false;
- return llvm::toHex(bytes.slice(0, 16), LowerCase) + std::to_string(age);
+ constexpr bool lower_case = false;
+ return llvm::toHex(bytes.slice(0, 16), lower_case) + std::to_string(age);
}
-bool has_unsafe_characters(llvm::StringRef s) {
+bool HasUnsafeCharacters(llvm::StringRef s) {
for (unsigned char c : s) {
// RFC 3986 unreserved characters are safe for file names and URLs.
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') ||
@@ -133,17 +133,17 @@ bool has_unsafe_characters(llvm::StringRef s) {
return s == "." || s == "..";
}
-// TODO: This is a dump initial implementation: It always downloads the file and
+// TODO: This is a dumb initial implementation: It always downloads the file and
// doesn't validate the result.
std::optional<FileSpec>
-requestFileFromSymStoreServerHTTP(llvm::StringRef base_url, llvm::StringRef key,
+RequestFileFromSymStoreServerHTTP(llvm::StringRef base_url, llvm::StringRef key,
llvm::StringRef pdb_name) {
using namespace llvm::sys;
// Make sure URL will be valid, portable, and compatible with symbol servers.
- if (has_unsafe_characters(pdb_name)) {
+ if (HasUnsafeCharacters(pdb_name)) {
Debugger::ReportWarning(llvm::formatv(
- "Rejecting HTTP lookup for PDB file due to unsafe characters in "
+ "rejecting HTTP lookup for PDB file due to unsafe characters in "
"name: {0}",
pdb_name));
return {};
@@ -152,13 +152,13 @@ requestFileFromSymStoreServerHTTP(llvm::StringRef base_url, llvm::StringRef key,
// Construct the path for local storage. Configurable cache coming soon.
llvm::SmallString<128> cache_file;
if (!path::cache_directory(cache_file)) {
- Debugger::ReportWarning("Failed to determine cache directory for SymStore");
+ Debugger::ReportWarning("failed to determine cache directory for SymStore");
return {};
}
path::append(cache_file, "lldb", "SymStore", pdb_name, key);
if (std::error_code ec = fs::create_directories(cache_file)) {
Debugger::ReportWarning(
- llvm::formatv("Failed to create cache directory '{0}': {1}", cache_file,
+ llvm::formatv("failed to create cache directory '{0}': {1}", cache_file,
ec.message()));
return {};
}
@@ -173,52 +173,51 @@ requestFileFromSymStoreServerHTTP(llvm::StringRef base_url, llvm::StringRef key,
return {};
}
- llvm::HTTPClient Client;
+ llvm::HTTPClient client;
// TODO: Since PDBs can be huge, we should distinguish between resolve,
// connect, send and receive.
- Client.setTimeout(std::chrono::seconds(60));
+ client.setTimeout(std::chrono::seconds(60));
llvm::StreamedHTTPResponseHandler Handler(
[dest = cache_file.str().str()]()
-> llvm::Expected<std::unique_ptr<llvm::CachedFileStream>> {
- std::error_code EC;
- auto FDStream = std::make_unique<llvm::raw_fd_ostream>(dest, EC);
- if (EC)
- return llvm::createStringError(EC, "Failed to open file for writing");
- return std::make_unique<llvm::CachedFileStream>(std::move(FDStream),
- dest);
+ std::error_code ec;
+ auto os = std::make_unique<llvm::raw_fd_ostream>(dest, ec);
+ if (ec)
+ return llvm::createStringError(ec, "Failed to open file for writing");
+ return std::make_unique<llvm::CachedFileStream>(std::move(os), dest);
},
- Client);
+ client);
- llvm::HTTPRequest Request(source_url);
- if (llvm::Error Err = Client.perform(Request, Handler)) {
+ llvm::HTTPRequest request(source_url);
+ if (llvm::Error Err = client.perform(request, Handler)) {
Debugger::ReportWarning(
- llvm::formatv("Failed to download from SymStore '{0}': {1}", source_url,
+ llvm::formatv("failed to download from SymStore '{0}': {1}", source_url,
llvm::toString(std::move(Err))));
return {};
}
if (llvm::Error Err = Handler.commit()) {
Debugger::ReportWarning(
- llvm::formatv("Failed to download from SymStore '{0}': {1}", source_url,
+ llvm::formatv("failed to download from SymStore '{0}': {1}", source_url,
llvm::toString(std::move(Err))));
return {};
}
- unsigned ResponseCode = Client.responseCode();
- switch (ResponseCode) {
+ unsigned responseCode = client.responseCode();
+ switch (responseCode) {
case 404:
return {}; // file not found
case 200:
return FileSpec(cache_file.str()); // success
default:
Debugger::ReportWarning(llvm::formatv(
- "Failed to download from SymStore '{0}': response code {1}", source_url,
- ResponseCode));
+ "failed to download from SymStore '{0}': response code {1}", source_url,
+ responseCode));
return {};
}
}
-std::optional<FileSpec> findFileInLocalSymStore(llvm::StringRef root_dir,
+std::optional<FileSpec> FindFileInLocalSymStore(llvm::StringRef root_dir,
llvm::StringRef key,
llvm::StringRef pdb_name) {
llvm::SmallString<256> path;
@@ -230,16 +229,16 @@ std::optional<FileSpec> findFileInLocalSymStore(llvm::StringRef root_dir,
return spec;
}
-std::optional<FileSpec> locateSymStoreEntry(llvm::StringRef base_url,
+std::optional<FileSpec> LocateSymStoreEntry(llvm::StringRef base_url,
llvm::StringRef key,
llvm::StringRef pdb_name) {
if (base_url.starts_with("http://") || base_url.starts_with("https://"))
- return requestFileFromSymStoreServerHTTP(base_url, key, pdb_name);
+ return RequestFileFromSymStoreServerHTTP(base_url, key, pdb_name);
if (base_url.starts_with("file://"))
base_url = base_url.drop_front(7);
- return findFileInLocalSymStore(base_url, key, pdb_name);
+ return FindFileInLocalSymStore(base_url, key, pdb_name);
}
} // namespace
@@ -267,10 +266,10 @@ std::optional<FileSpec> SymbolLocatorSymStore::LocateExecutableSymbolFile(
return {};
}
- std::string key = formatSymStoreKey(uuid);
+ std::string key = FormatSymStoreKey(uuid);
Args sym_store_urls = GetGlobalPluginProperties().GetURLs();
for (const Args::ArgEntry &url : sym_store_urls) {
- if (auto spec = locateSymStoreEntry(url.ref(), key, pdb_name)) {
+ if (auto spec = LocateSymStoreEntry(url.ref(), key, pdb_name)) {
LLDB_LOG_VERBOSE(log, "Found {0} in SymStore {1}", pdb_name, url.ref());
return *spec;
}
More information about the lldb-commits
mailing list