Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions llvm/include/llvm/Debuginfod/Debuginfod.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,11 @@ class DebuginfodCollection {
Expected<std::string> findBinaryPath(object::BuildIDRef);
};

class DebuginfodServer {
public:
struct DebuginfodServer {
HTTPServer Server;
DebuginfodLog &Log;
DebuginfodCollection &Collection;
DebuginfodServer(DebuginfodLog &Log, DebuginfodCollection &Collection);
static Expected<DebuginfodServer> create(DebuginfodLog &Log,
DebuginfodCollection &Collection);

private:
DebuginfodServer() = default;
Error init(DebuginfodLog &Log, DebuginfodCollection &Collection);
};

} // end namespace llvm
Expand Down
1 change: 0 additions & 1 deletion llvm/include/llvm/Debuginfod/HTTPServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ class HTTPServer {
public:
HTTPServer();
~HTTPServer();
HTTPServer(HTTPServer &&);

/// Returns true only if LLVM has been compiled with a working HTTPServer.
static bool isAvailable();
Expand Down
28 changes: 7 additions & 21 deletions llvm/lib/Debuginfod/Debuginfod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,10 +567,10 @@ Expected<std::string> DebuginfodCollection::findDebugBinaryPath(BuildIDRef ID) {
return getCachedOrDownloadDebuginfo(ID);
}

Error DebuginfodServer::init(DebuginfodLog &Log,
DebuginfodCollection &Collection) {

Error Err =
DebuginfodServer::DebuginfodServer(DebuginfodLog &Log,
DebuginfodCollection &Collection)
: Log(Log), Collection(Collection) {
cantFail(
Server.get(R"(/buildid/(.*)/debuginfo)", [&](HTTPServerRequest Request) {
Log.push("GET " + Request.UrlPath);
std::string IDString;
Expand All @@ -587,11 +587,8 @@ Error DebuginfodServer::init(DebuginfodLog &Log,
return;
}
streamFile(Request, *PathOrErr);
});
if (Err)
return Err;

Err =
}));
cantFail(
Server.get(R"(/buildid/(.*)/executable)", [&](HTTPServerRequest Request) {
Log.push("GET " + Request.UrlPath);
std::string IDString;
Expand All @@ -608,18 +605,7 @@ Error DebuginfodServer::init(DebuginfodLog &Log,
return;
}
streamFile(Request, *PathOrErr);
});
if (Err)
return Err;
return Error::success();
}

Expected<DebuginfodServer>
DebuginfodServer::create(DebuginfodLog &Log, DebuginfodCollection &Collection) {
DebuginfodServer Serverd;
if (llvm::Error Err = Serverd.init(Log, Collection))
return std::move(Err);
return std::move(Serverd);
}));
}

} // namespace llvm
2 changes: 0 additions & 2 deletions llvm/lib/Debuginfod/HTTPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ bool llvm::streamFile(HTTPServerRequest &Request, StringRef FilePath) {
return true;
}

HTTPServer::HTTPServer(HTTPServer &&) = default;

#ifdef LLVM_ENABLE_HTTPLIB

bool HTTPServer::isAvailable() { return true; }
Expand Down
4 changes: 2 additions & 2 deletions llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ int llvm_debuginfod_main(int argc, char **argv, const llvm::ToolContext &) {
DefaultThreadPool Pool(hardware_concurrency(MaxConcurrency));
DebuginfodLog Log;
DebuginfodCollection Collection(Paths, Log, Pool, MinInterval);
DebuginfodServer Server =
ExitOnErr(DebuginfodServer::create(Log, Collection));
DebuginfodServer Server(Log, Collection);

if (!Port)
Port = ExitOnErr(Server.Server.bind(HostInterface.c_str()));
else
Expand Down
Loading