LLVM  16.0.0git
Debuginfod.cpp
Go to the documentation of this file.
1 //===-- llvm/Debuginfod/Debuginfod.cpp - Debuginfod client library --------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 ///
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,
13 /// this file defines the DebuginfodLogEntry and DebuginfodServer structs, as
14 /// well as the DebuginfodLog, DebuginfodCollection classes. The fetchInfo
15 /// function retrieves any of the three supported artifact types: (executable,
16 /// debuginfo, source file) associated with a build-id from debuginfod servers.
17 /// If a source file is to be fetched, its absolute path must be specified in
18 /// the Description argument to fetchInfo. The DebuginfodLogEntry,
19 /// DebuginfodLog, and DebuginfodCollection are used by the DebuginfodServer to
20 /// scan the local filesystem for binaries and serve the debuginfod protocol.
21 ///
22 //===----------------------------------------------------------------------===//
23 
25 #include "llvm/ADT/StringRef.h"
30 #include "llvm/Object/BuildID.h"
33 #include "llvm/Support/Caching.h"
34 #include "llvm/Support/Errc.h"
35 #include "llvm/Support/Error.h"
37 #include "llvm/Support/Path.h"
39 #include "llvm/Support/xxhash.h"
40 
41 #include <atomic>
42 #include <thread>
43 
44 namespace llvm {
45 
47 
48 static std::string uniqueKey(llvm::StringRef S) { return utostr(xxHash64(S)); }
49 
50 // Returns a binary BuildID as a normalized hex string.
51 // Uses lowercase for compatibility with common debuginfod servers.
52 static std::string buildIDToString(BuildIDRef ID) {
53  return llvm::toHex(ID, /*LowerCase=*/true);
54 }
55 
57  const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS");
58  if (DebuginfodUrlsEnv == nullptr)
59  return SmallVector<StringRef>();
60 
61  SmallVector<StringRef> DebuginfodUrls;
62  StringRef(DebuginfodUrlsEnv).split(DebuginfodUrls, " ");
63  return DebuginfodUrls;
64 }
65 
66 /// Finds a default local file caching directory for the debuginfod client,
67 /// first checking DEBUGINFOD_CACHE_PATH.
69  if (const char *CacheDirectoryEnv = std::getenv("DEBUGINFOD_CACHE_PATH"))
70  return CacheDirectoryEnv;
71 
72  SmallString<64> CacheDirectory;
73  if (!sys::path::cache_directory(CacheDirectory))
74  return createStringError(
75  errc::io_error, "Unable to determine appropriate cache directory.");
76  sys::path::append(CacheDirectory, "llvm-debuginfod", "client");
77  return std::string(CacheDirectory);
78 }
79 
80 std::chrono::milliseconds getDefaultDebuginfodTimeout() {
81  long Timeout;
82  const char *DebuginfodTimeoutEnv = std::getenv("DEBUGINFOD_TIMEOUT");
83  if (DebuginfodTimeoutEnv &&
84  to_integer(StringRef(DebuginfodTimeoutEnv).trim(), Timeout, 10))
85  return std::chrono::milliseconds(Timeout * 1000);
86 
87  return std::chrono::milliseconds(90 * 1000);
88 }
89 
90 /// The following functions fetch a debuginfod artifact to a file in a local
91 /// cache and return the cached file path. They first search the local cache,
92 /// followed by the debuginfod servers.
93 
95  StringRef SourceFilePath) {
96  SmallString<64> UrlPath;
97  sys::path::append(UrlPath, sys::path::Style::posix, "buildid",
98  buildIDToString(ID), "source",
99  sys::path::convert_to_slash(SourceFilePath));
100  return getCachedOrDownloadArtifact(uniqueKey(UrlPath), UrlPath);
101 }
102 
104  SmallString<64> UrlPath;
105  sys::path::append(UrlPath, sys::path::Style::posix, "buildid",
106  buildIDToString(ID), "executable");
107  return getCachedOrDownloadArtifact(uniqueKey(UrlPath), UrlPath);
108 }
109 
111  SmallString<64> UrlPath;
112  sys::path::append(UrlPath, sys::path::Style::posix, "buildid",
113  buildIDToString(ID), "debuginfo");
114  return getCachedOrDownloadArtifact(uniqueKey(UrlPath), UrlPath);
115 }
116 
117 // General fetching function.
119  StringRef UrlPath) {
120  SmallString<10> CacheDir;
121 
123  if (!CacheDirOrErr)
124  return CacheDirOrErr.takeError();
125  CacheDir = *CacheDirOrErr;
126 
127  Expected<SmallVector<StringRef>> DebuginfodUrlsOrErr =
129  if (!DebuginfodUrlsOrErr)
130  return DebuginfodUrlsOrErr.takeError();
131  SmallVector<StringRef> &DebuginfodUrls = *DebuginfodUrlsOrErr;
132  return getCachedOrDownloadArtifact(UniqueKey, UrlPath, CacheDir,
133  DebuginfodUrls,
135 }
136 
137 namespace {
138 
139 /// A simple handler which streams the returned data to a cache file. The cache
140 /// file is only created if a 200 OK status is observed.
141 class StreamedHTTPResponseHandler : public HTTPResponseHandler {
142  using CreateStreamFn =
143  std::function<Expected<std::unique_ptr<CachedFileStream>>()>;
144  CreateStreamFn CreateStream;
145  HTTPClient &Client;
146  std::unique_ptr<CachedFileStream> FileStream;
147 
148 public:
149  StreamedHTTPResponseHandler(CreateStreamFn CreateStream, HTTPClient &Client)
150  : CreateStream(CreateStream), Client(Client) {}
151  virtual ~StreamedHTTPResponseHandler() = default;
152 
153  Error handleBodyChunk(StringRef BodyChunk) override;
154 };
155 
156 } // namespace
157 
158 Error StreamedHTTPResponseHandler::handleBodyChunk(StringRef BodyChunk) {
159  if (!FileStream) {
160  if (Client.responseCode() != 200)
161  return Error::success();
162  Expected<std::unique_ptr<CachedFileStream>> FileStreamOrError =
163  CreateStream();
164  if (!FileStreamOrError)
165  return FileStreamOrError.takeError();
166  FileStream = std::move(*FileStreamOrError);
167  }
168  *FileStream->OS << BodyChunk;
169  return Error::success();
170 }
171 
173  StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
174  ArrayRef<StringRef> DebuginfodUrls, std::chrono::milliseconds Timeout) {
175  SmallString<64> AbsCachedArtifactPath;
176  sys::path::append(AbsCachedArtifactPath, CacheDirectoryPath,
177  "llvmcache-" + UniqueKey);
178 
179  Expected<FileCache> CacheOrErr =
180  localCache("Debuginfod-client", ".debuginfod-client", CacheDirectoryPath);
181  if (!CacheOrErr)
182  return CacheOrErr.takeError();
183 
184  FileCache Cache = *CacheOrErr;
185  // We choose an arbitrary Task parameter as we do not make use of it.
186  unsigned Task = 0;
187  Expected<AddStreamFn> CacheAddStreamOrErr = Cache(Task, UniqueKey);
188  if (!CacheAddStreamOrErr)
189  return CacheAddStreamOrErr.takeError();
190  AddStreamFn &CacheAddStream = *CacheAddStreamOrErr;
191  if (!CacheAddStream)
192  return std::string(AbsCachedArtifactPath);
193  // The artifact was not found in the local cache, query the debuginfod
194  // servers.
197  "No working HTTP client is available.");
198 
200  return createStringError(
202  "A working HTTP client is available, but it is not initialized. To "
203  "allow Debuginfod to make HTTP requests, call HTTPClient::initialize() "
204  "at the beginning of main.");
205 
206  HTTPClient Client;
207  Client.setTimeout(Timeout);
208  for (StringRef ServerUrl : DebuginfodUrls) {
209  SmallString<64> ArtifactUrl;
210  sys::path::append(ArtifactUrl, sys::path::Style::posix, ServerUrl, UrlPath);
211 
212  // Perform the HTTP request and if successful, write the response body to
213  // the cache.
214  StreamedHTTPResponseHandler Handler([&]() { return CacheAddStream(Task); },
215  Client);
216  HTTPRequest Request(ArtifactUrl);
217  Error Err = Client.perform(Request, Handler);
218  if (Err)
219  return std::move(Err);
220 
221  if (Client.responseCode() != 200)
222  continue;
223 
224  // Return the path to the artifact on disk.
225  return std::string(AbsCachedArtifactPath);
226  }
227 
228  return createStringError(errc::argument_out_of_domain, "build id not found");
229 }
230 
232  : Message(Message.str()) {}
233 
234 void DebuginfodLog::push(const Twine &Message) {
235  push(DebuginfodLogEntry(Message));
236 }
237 
239  {
240  std::lock_guard<std::mutex> Guard(QueueMutex);
241  LogEntryQueue.push(Entry);
242  }
243  QueueCondition.notify_one();
244 }
245 
247  {
248  std::unique_lock<std::mutex> Guard(QueueMutex);
249  // Wait for messages to be pushed into the queue.
250  QueueCondition.wait(Guard, [&] { return !LogEntryQueue.empty(); });
251  }
252  std::lock_guard<std::mutex> Guard(QueueMutex);
253  if (!LogEntryQueue.size())
254  llvm_unreachable("Expected message in the queue.");
255 
256  DebuginfodLogEntry Entry = LogEntryQueue.front();
257  LogEntryQueue.pop();
258  return Entry;
259 }
260 
262  DebuginfodLog &Log, ThreadPool &Pool,
263  double MinInterval)
264  : Log(Log), Pool(Pool), MinInterval(MinInterval) {
265  for (StringRef Path : PathsRef)
266  Paths.push_back(Path.str());
267 }
268 
270  std::lock_guard<sys::Mutex> Guard(UpdateMutex);
271  if (UpdateTimer.isRunning())
272  UpdateTimer.stopTimer();
273  UpdateTimer.clear();
274  for (const std::string &Path : Paths) {
275  Log.push("Updating binaries at path " + Path);
276  if (Error Err = findBinaries(Path))
277  return Err;
278  }
279  Log.push("Updated collection");
280  UpdateTimer.startTimer();
281  return Error::success();
282 }
283 
284 Expected<bool> DebuginfodCollection::updateIfStale() {
285  if (!UpdateTimer.isRunning())
286  return false;
287  UpdateTimer.stopTimer();
288  double Time = UpdateTimer.getTotalTime().getWallTime();
289  UpdateTimer.startTimer();
290  if (Time < MinInterval)
291  return false;
292  if (Error Err = update())
293  return std::move(Err);
294  return true;
295 }
296 
298  while (true) {
299  if (Error Err = update())
300  return Err;
301  std::this_thread::sleep_for(Interval);
302  }
303  llvm_unreachable("updateForever loop should never end");
304 }
305 
306 static bool hasELFMagic(StringRef FilePath) {
308  std::error_code EC = identify_magic(FilePath, Type);
309  if (EC)
310  return false;
311  switch (Type) {
312  case file_magic::elf:
317  return true;
318  default:
319  return false;
320  }
321 }
322 
323 Error DebuginfodCollection::findBinaries(StringRef Path) {
324  std::error_code EC;
325  sys::fs::recursive_directory_iterator I(Twine(Path), EC), E;
326  std::mutex IteratorMutex;
327  ThreadPoolTaskGroup IteratorGroup(Pool);
328  for (unsigned WorkerIndex = 0; WorkerIndex < Pool.getThreadCount();
329  WorkerIndex++) {
330  IteratorGroup.async([&, this]() -> void {
331  std::string FilePath;
332  while (true) {
333  {
334  // Check if iteration is over or there is an error during iteration
335  std::lock_guard<std::mutex> Guard(IteratorMutex);
336  if (I == E || EC)
337  return;
338  // Grab a file path from the directory iterator and advance the
339  // iterator.
340  FilePath = I->path();
341  I.increment(EC);
342  }
343 
344  // Inspect the file at this path to determine if it is debuginfo.
345  if (!hasELFMagic(FilePath))
346  continue;
347 
348  Expected<object::OwningBinary<object::Binary>> BinOrErr =
349  object::createBinary(FilePath);
350 
351  if (!BinOrErr) {
352  consumeError(BinOrErr.takeError());
353  continue;
354  }
355  object::Binary *Bin = std::move(BinOrErr.get().getBinary());
356  if (!Bin->isObject())
357  continue;
358 
359  // TODO: Support non-ELF binaries
360  object::ELFObjectFileBase *Object =
361  dyn_cast<object::ELFObjectFileBase>(Bin);
362  if (!Object)
363  continue;
364 
365  Optional<BuildIDRef> ID = getBuildID(Object);
366  if (!ID)
367  continue;
368 
369  std::string IDString = buildIDToString(ID.value());
370  if (Object->hasDebugInfo()) {
371  std::lock_guard<sys::RWMutex> DebugBinariesGuard(DebugBinariesMutex);
372  DebugBinaries[IDString] = FilePath;
373  } else {
374  std::lock_guard<sys::RWMutex> BinariesGuard(BinariesMutex);
375  Binaries[IDString] = FilePath;
376  }
377  }
378  });
379  }
380  IteratorGroup.wait();
381  std::unique_lock<std::mutex> Guard(IteratorMutex);
382  if (EC)
383  return errorCodeToError(EC);
384  return Error::success();
385 }
386 
387 Expected<Optional<std::string>>
388 DebuginfodCollection::getBinaryPath(BuildIDRef ID) {
389  Log.push("getting binary path of ID " + buildIDToString(ID));
390  std::shared_lock<sys::RWMutex> Guard(BinariesMutex);
391  auto Loc = Binaries.find(buildIDToString(ID));
392  if (Loc != Binaries.end()) {
393  std::string Path = Loc->getValue();
394  return Path;
395  }
396  return None;
397 }
398 
399 Expected<Optional<std::string>>
400 DebuginfodCollection::getDebugBinaryPath(BuildIDRef ID) {
401  Log.push("getting debug binary path of ID " + buildIDToString(ID));
402  std::shared_lock<sys::RWMutex> Guard(DebugBinariesMutex);
403  auto Loc = DebugBinaries.find(buildIDToString(ID));
404  if (Loc != DebugBinaries.end()) {
405  std::string Path = Loc->getValue();
406  return Path;
407  }
408  return None;
409 }
410 
412  {
413  // Check collection; perform on-demand update if stale.
414  Expected<Optional<std::string>> PathOrErr = getBinaryPath(ID);
415  if (!PathOrErr)
416  return PathOrErr.takeError();
417  Optional<std::string> Path = *PathOrErr;
418  if (!Path) {
419  Expected<bool> UpdatedOrErr = updateIfStale();
420  if (!UpdatedOrErr)
421  return UpdatedOrErr.takeError();
422  if (*UpdatedOrErr) {
423  // Try once more.
424  PathOrErr = getBinaryPath(ID);
425  if (!PathOrErr)
426  return PathOrErr.takeError();
427  Path = *PathOrErr;
428  }
429  }
430  if (Path)
431  return Path.value();
432  }
433 
434  // Try federation.
436  if (!PathOrErr)
437  consumeError(PathOrErr.takeError());
438 
439  // Fall back to debug binary.
440  return findDebugBinaryPath(ID);
441 }
442 
444  // Check collection; perform on-demand update if stale.
445  Expected<Optional<std::string>> PathOrErr = getDebugBinaryPath(ID);
446  if (!PathOrErr)
447  return PathOrErr.takeError();
448  Optional<std::string> Path = *PathOrErr;
449  if (!Path) {
450  Expected<bool> UpdatedOrErr = updateIfStale();
451  if (!UpdatedOrErr)
452  return UpdatedOrErr.takeError();
453  if (*UpdatedOrErr) {
454  // Try once more.
455  PathOrErr = getBinaryPath(ID);
456  if (!PathOrErr)
457  return PathOrErr.takeError();
458  Path = *PathOrErr;
459  }
460  }
461  if (Path)
462  return Path.value();
463 
464  // Try federation.
466 }
467 
469  DebuginfodCollection &Collection)
470  : Log(Log), Collection(Collection) {
471  cantFail(
472  Server.get(R"(/buildid/(.*)/debuginfo)", [&](HTTPServerRequest Request) {
473  Log.push("GET " + Request.UrlPath);
474  std::string IDString;
475  if (!tryGetFromHex(Request.UrlPathMatches[0], IDString)) {
476  Request.setResponse(
477  {404, "text/plain", "Build ID is not a hex string\n"});
478  return;
479  }
480  object::BuildID ID(IDString.begin(), IDString.end());
482  if (Error Err = PathOrErr.takeError()) {
483  consumeError(std::move(Err));
484  Request.setResponse({404, "text/plain", "Build ID not found\n"});
485  return;
486  }
487  streamFile(Request, *PathOrErr);
488  }));
489  cantFail(
490  Server.get(R"(/buildid/(.*)/executable)", [&](HTTPServerRequest Request) {
491  Log.push("GET " + Request.UrlPath);
492  std::string IDString;
493  if (!tryGetFromHex(Request.UrlPathMatches[0], IDString)) {
494  Request.setResponse(
495  {404, "text/plain", "Build ID is not a hex string\n"});
496  return;
497  }
498  object::BuildID ID(IDString.begin(), IDString.end());
499  Expected<std::string> PathOrErr = Collection.findBinaryPath(ID);
500  if (Error Err = PathOrErr.takeError()) {
501  consumeError(std::move(Err));
502  Request.setResponse({404, "text/plain", "Build ID not found\n"});
503  return;
504  }
505  streamFile(Request, *PathOrErr);
506  }));
507 }
508 
509 } // namespace llvm
llvm::DebuginfodLog::pop
DebuginfodLogEntry pop()
Definition: Debuginfod.cpp:246
llvm::FileCache
std::function< Expected< AddStreamFn >(unsigned Task, StringRef Key)> FileCache
This is the type of a file cache.
Definition: Caching.h:56
llvm::HTTPClient
A reusable client that can perform HTTPRequests through a network socket.
Definition: HTTPClient.h:50
llvm::Timer::clear
void clear()
Clear the timer state.
Definition: Timer.cpp:205
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::buildIDToString
static std::string buildIDToString(BuildIDRef ID)
Definition: Debuginfod.cpp:52
llvm::DebuginfodLogEntry::DebuginfodLogEntry
DebuginfodLogEntry()=default
llvm::DebuginfodCollection::DebuginfodCollection
DebuginfodCollection(ArrayRef< StringRef > Paths, DebuginfodLog &Log, ThreadPool &Pool, double MinInterval)
Definition: Debuginfod.cpp:261
llvm::lltok::Error
@ Error
Definition: LLToken.h:21
llvm::file_magic
file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...
Definition: Magic.h:20
llvm::object::BuildIDRef
ArrayRef< uint8_t > BuildIDRef
A reference to a BuildID in binary form.
Definition: BuildID.h:28
llvm::sys::path::Style::posix
@ posix
llvm::ThreadPool
A ThreadPool for asynchronous parallel execution on a defined number of threads.
Definition: ThreadPool.h:52
StringRef.h
llvm::file_magic::elf_core
@ elf_core
ELF core image.
Definition: Magic.h:29
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1181
llvm::HTTPClient::IsInitialized
static bool IsInitialized
Definition: HTTPClient.h:59
Path.h
llvm::getCachedOrDownloadExecutable
Expected< std::string > getCachedOrDownloadExecutable(object::BuildIDRef ID)
Fetches an executable by searching the default local cache directory and server URLs.
llvm::sys::path::convert_to_slash
std::string convert_to_slash(StringRef path, Style style=Style::native)
Replaces backslashes with slashes if Windows.
Definition: Path.cpp:568
llvm::AddStreamFn
std::function< Expected< std::unique_ptr< CachedFileStream > >(unsigned Task)> AddStreamFn
This type defines the callback to add a file that is generated on the fly.
Definition: Caching.h:42
llvm::object::getBuildID
Optional< BuildIDRef > getBuildID(const ObjectFile *Obj)
Returns the build ID, if any, contained in the given object file.
Definition: BuildID.cpp:48
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:329
llvm::file_magic::elf_shared_object
@ elf_shared_object
ELF dynamically linked shared lib.
Definition: Magic.h:28
DWARFContext.h
Error.h
Errc.h
llvm::StringMap::end
iterator end()
Definition: StringMap.h:204
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::Optional< std::string >
HTTPClient.h
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:41
llvm::getDefaultDebuginfodTimeout
std::chrono::milliseconds getDefaultDebuginfodTimeout()
Finds a default timeout for debuginfod HTTP requests.
Definition: Debuginfod.cpp:80
llvm::streamFile
bool streamFile(HTTPServerRequest &Request, StringRef FilePath)
Sets the response to stream the file at FilePath, if available, and otherwise an HTTP 404 error respo...
Definition: HTTPServer.cpp:31
llvm::StringMap::find
iterator find(StringRef Key)
Definition: StringMap.h:217
llvm::Timer::startTimer
void startTimer()
Start the timer running.
Definition: Timer.cpp:190
llvm::consumeError
void consumeError(Error Err)
Consume a Error without doing anything.
Definition: Error.h:1043
llvm::sys::path::cache_directory
bool cache_directory(SmallVectorImpl< char > &result)
Get the directory where installed packages should put their machine-local cache, e....
llvm::DebuginfodCollection::findBinaryPath
Expected< std::string > findBinaryPath(object::BuildIDRef)
Definition: Debuginfod.cpp:411
llvm::object::BuildID
SmallVector< uint8_t, 10 > BuildID
A build ID in binary form.
Definition: BuildID.h:25
llvm::SubDirectoryType::Bin
@ Bin
llvm::sys::path::append
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
Definition: Path.cpp:456
llvm::Timer::isRunning
bool isRunning() const
Check if the timer is currently running.
Definition: Timer.h:118
llvm::DebuginfodCollection::update
Error update()
Definition: Debuginfod.cpp:269
Caching.h
CachePruning.h
llvm::uniqueKey
static std::string uniqueKey(llvm::StringRef S)
Definition: Debuginfod.cpp:48
llvm::errc::argument_out_of_domain
@ argument_out_of_domain
Magic.h
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::errorCodeToError
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
Definition: Error.cpp:92
llvm::getCachedOrDownloadArtifact
Expected< std::string > getCachedOrDownloadArtifact(StringRef UniqueKey, StringRef UrlPath)
Fetches any debuginfod artifact using the default local cache directory and server URLs.
Definition: Debuginfod.cpp:118
llvm::HTTPClient::perform
Error perform(const HTTPRequest &Request, HTTPResponseHandler &Handler)
Performs the Request, passing response data to the Handler.
Definition: HTTPClient.cpp:145
llvm::pdb::PDB_ColorItem::Path
@ Path
llvm::DebuginfodServer::Server
HTTPServer Server
Definition: Debuginfod.h:134
llvm::None
const NoneType None
Definition: None.h:24
llvm::localCache
Expected< FileCache > localCache(Twine CacheNameRef, Twine TempFilePrefixRef, Twine CacheDirectoryPathRef, AddBufferFn AddBuffer=[](size_t Task, std::unique_ptr< MemoryBuffer > MB) { })
Create a local file system cache which uses the given cache name, temporary file prefix,...
Definition: Caching.cpp:29
llvm::file_magic::elf_relocatable
@ elf_relocatable
ELF Relocatable object file.
Definition: Magic.h:26
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
llvm::DebuginfodLog
Definition: Debuginfod.h:86
llvm::ThreadPool::getThreadCount
unsigned getThreadCount() const
Definition: ThreadPool.h:110
llvm::SmallString< 64 >
BuildID.h
llvm::OutputFileType::Object
@ Object
ThreadPool.h
Debuginfod.h
llvm::HTTPServer::get
Error get(StringRef UrlPathPattern, HTTPRequestHandler Handler)
Registers a URL pattern routing rule.
Definition: HTTPServer.cpp:169
llvm::Interval
Interval Class - An Interval is a set of nodes defined such that every node in the interval has all o...
Definition: Interval.h:36
llvm::HTTPClient::responseCode
unsigned responseCode()
Returns the last received response code or zero if none.
Definition: HTTPClient.cpp:150
llvm::symbolize::toHex
static std::string toHex(uint64_t V)
Definition: DIPrinter.cpp:278
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::HTTPClient::isAvailable
static bool isAvailable()
Returns true only if LLVM has been compiled with a working HTTPClient.
Definition: HTTPClient.cpp:137
llvm::HTTPClient::setTimeout
void setTimeout(std::chrono::milliseconds Timeout)
Sets the timeout for the entire request, in milliseconds.
Definition: HTTPClient.cpp:143
llvm::getDefaultDebuginfodCacheDirectory
Expected< std::string > getDefaultDebuginfodCacheDirectory()
Finds a default local file caching directory for the debuginfod client, first checking DEBUGINFOD_CAC...
Definition: Debuginfod.cpp:68
llvm::DebuginfodServer::DebuginfodServer
DebuginfodServer(DebuginfodLog &Log, DebuginfodCollection &Collection)
Definition: Debuginfod.cpp:468
llvm::Timer::stopTimer
void stopTimer()
Stop the timer.
Definition: Timer.cpp:197
llvm::Timer::getTotalTime
TimeRecord getTotalTime() const
Return the duration for which this timer has been running.
Definition: Timer.h:135
xxhash.h
llvm::getCachedOrDownloadDebuginfo
Expected< std::string > getCachedOrDownloadDebuginfo(object::BuildIDRef ID)
Fetches a debug binary by searching the default local cache directory and server URLs.
llvm::TimeRecord::getWallTime
double getWallTime() const
Definition: Timer.h:45
FileUtilities.h
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
Symbolize.h
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
if
if(llvm_vc STREQUAL "") set(fake_version_inc "$
Definition: CMakeLists.txt:14
llvm::cantFail
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition: Error.h:745
llvm::HTTPServerRequest
Definition: HTTPServer.h:37
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::DebuginfodCollection::updateForever
Error updateForever(std::chrono::milliseconds Interval)
Definition: Debuginfod.cpp:297
ELFObjectFile.h
llvm::DebuginfodLog::push
void push(DebuginfodLogEntry Entry)
Definition: Debuginfod.cpp:238
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
llvm::createStringError
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition: Error.h:1239
llvm::HTTPRequest
A stateless description of an outbound HTTP request.
Definition: HTTPClient.h:28
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
llvm::file_magic::elf
@ elf
ELF Unknown type.
Definition: Magic.h:25
llvm::getDefaultDebuginfodUrls
Expected< SmallVector< StringRef > > getDefaultDebuginfodUrls()
Finds default array of Debuginfod server URLs by checking DEBUGINFOD_URLS environment variable.
Definition: Debuginfod.cpp:56
llvm::errc::io_error
@ io_error
llvm::file_magic::elf_executable
@ elf_executable
ELF Executable image.
Definition: Magic.h:27
llvm::DebuginfodCollection
Tracks a collection of debuginfod artifacts on the local filesystem.
Definition: Debuginfod.h:102
llvm::Expected::takeError
Error takeError()
Take ownership of the stored error.
Definition: Error.h:597
llvm::DebuginfodCollection::findDebugBinaryPath
Expected< std::string > findDebugBinaryPath(object::BuildIDRef)
Definition: Debuginfod.cpp:443
llvm::object::createBinary
Expected< std::unique_ptr< Binary > > createBinary(MemoryBufferRef Source, LLVMContext *Context=nullptr, bool InitContent=true)
Create a Binary from Source, autodetecting the file type.
Definition: Binary.cpp:45
llvm::getCachedOrDownloadSource
Expected< std::string > getCachedOrDownloadSource(object::BuildIDRef ID, StringRef SourceFilePath)
Fetches a specified source file by searching the default local cache directory and server URLs.
llvm::hasELFMagic
static bool hasELFMagic(StringRef FilePath)
Definition: Debuginfod.cpp:306
llvm::identify_magic
file_magic identify_magic(StringRef magic)
Identify the type of a binary file based on how magical it is.
Definition: Magic.cpp:33
llvm::StringRef::split
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Definition: StringRef.h:689
llvm::xxHash64
uint64_t xxHash64(llvm::StringRef Data)
Definition: xxhash.cpp:70
llvm::DebuginfodServer::Collection
DebuginfodCollection & Collection
Definition: Debuginfod.h:136
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38
llvm::DebuginfodLogEntry
Definition: Debuginfod.h:80