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/StringExtras.h"
26 #include "llvm/ADT/StringRef.h"
31 #include "llvm/Object/BuildID.h"
34 #include "llvm/Support/Caching.h"
35 #include "llvm/Support/Errc.h"
36 #include "llvm/Support/Error.h"
39 #include "llvm/Support/Path.h"
41 #include "llvm/Support/xxhash.h"
42 
43 #include <atomic>
44 #include <thread>
45 
46 namespace llvm {
47 
49 
50 static std::string uniqueKey(llvm::StringRef S) { return utostr(xxHash64(S)); }
51 
52 // Returns a binary BuildID as a normalized hex string.
53 // Uses lowercase for compatibility with common debuginfod servers.
54 static std::string buildIDToString(BuildIDRef ID) {
55  return llvm::toHex(ID, /*LowerCase=*/true);
56 }
57 
59  const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS");
60  if (DebuginfodUrlsEnv == nullptr)
61  return SmallVector<StringRef>();
62 
63  SmallVector<StringRef> DebuginfodUrls;
64  StringRef(DebuginfodUrlsEnv).split(DebuginfodUrls, " ");
65  return DebuginfodUrls;
66 }
67 
68 /// Finds a default local file caching directory for the debuginfod client,
69 /// first checking DEBUGINFOD_CACHE_PATH.
71  if (const char *CacheDirectoryEnv = std::getenv("DEBUGINFOD_CACHE_PATH"))
72  return CacheDirectoryEnv;
73 
74  SmallString<64> CacheDirectory;
75  if (!sys::path::cache_directory(CacheDirectory))
76  return createStringError(
77  errc::io_error, "Unable to determine appropriate cache directory.");
78  sys::path::append(CacheDirectory, "llvm-debuginfod", "client");
79  return std::string(CacheDirectory);
80 }
81 
82 std::chrono::milliseconds getDefaultDebuginfodTimeout() {
83  long Timeout;
84  const char *DebuginfodTimeoutEnv = std::getenv("DEBUGINFOD_TIMEOUT");
85  if (DebuginfodTimeoutEnv &&
86  to_integer(StringRef(DebuginfodTimeoutEnv).trim(), Timeout, 10))
87  return std::chrono::milliseconds(Timeout * 1000);
88 
89  return std::chrono::milliseconds(90 * 1000);
90 }
91 
92 /// The following functions fetch a debuginfod artifact to a file in a local
93 /// cache and return the cached file path. They first search the local cache,
94 /// followed by the debuginfod servers.
95 
97  StringRef SourceFilePath) {
98  SmallString<64> UrlPath;
99  sys::path::append(UrlPath, sys::path::Style::posix, "buildid",
100  buildIDToString(ID), "source",
101  sys::path::convert_to_slash(SourceFilePath));
102  return getCachedOrDownloadArtifact(uniqueKey(UrlPath), UrlPath);
103 }
104 
106  SmallString<64> UrlPath;
107  sys::path::append(UrlPath, sys::path::Style::posix, "buildid",
108  buildIDToString(ID), "executable");
109  return getCachedOrDownloadArtifact(uniqueKey(UrlPath), UrlPath);
110 }
111 
113  SmallString<64> UrlPath;
114  sys::path::append(UrlPath, sys::path::Style::posix, "buildid",
115  buildIDToString(ID), "debuginfo");
116  return getCachedOrDownloadArtifact(uniqueKey(UrlPath), UrlPath);
117 }
118 
119 // General fetching function.
121  StringRef UrlPath) {
122  SmallString<10> CacheDir;
123 
125  if (!CacheDirOrErr)
126  return CacheDirOrErr.takeError();
127  CacheDir = *CacheDirOrErr;
128 
129  Expected<SmallVector<StringRef>> DebuginfodUrlsOrErr =
131  if (!DebuginfodUrlsOrErr)
132  return DebuginfodUrlsOrErr.takeError();
133  SmallVector<StringRef> &DebuginfodUrls = *DebuginfodUrlsOrErr;
134  return getCachedOrDownloadArtifact(UniqueKey, UrlPath, CacheDir,
135  DebuginfodUrls,
137 }
138 
139 namespace {
140 
141 /// A simple handler which streams the returned data to a cache file. The cache
142 /// file is only created if a 200 OK status is observed.
143 class StreamedHTTPResponseHandler : public HTTPResponseHandler {
144  using CreateStreamFn =
145  std::function<Expected<std::unique_ptr<CachedFileStream>>()>;
146  CreateStreamFn CreateStream;
147  HTTPClient &Client;
148  std::unique_ptr<CachedFileStream> FileStream;
149 
150 public:
151  StreamedHTTPResponseHandler(CreateStreamFn CreateStream, HTTPClient &Client)
152  : CreateStream(CreateStream), Client(Client) {}
153  virtual ~StreamedHTTPResponseHandler() = default;
154 
155  Error handleBodyChunk(StringRef BodyChunk) override;
156 };
157 
158 } // namespace
159 
160 Error StreamedHTTPResponseHandler::handleBodyChunk(StringRef BodyChunk) {
161  if (!FileStream) {
162  if (Client.responseCode() != 200)
163  return Error::success();
164  Expected<std::unique_ptr<CachedFileStream>> FileStreamOrError =
165  CreateStream();
166  if (!FileStreamOrError)
167  return FileStreamOrError.takeError();
168  FileStream = std::move(*FileStreamOrError);
169  }
170  *FileStream->OS << BodyChunk;
171  return Error::success();
172 }
173 
174 // An over-accepting simplification of the HTTP RFC 7230 spec.
175 static bool isHeader(StringRef S) {
176  StringRef Name;
178  std::tie(Name, Value) = S.split(':');
179  if (Name.empty() || Value.empty())
180  return false;
181  return all_of(Name, [](char C) { return llvm::isPrint(C) && C != ' '; }) &&
182  all_of(Value, [](char C) { return llvm::isPrint(C) || C == '\t'; });
183 }
184 
186  const char *Filename = getenv("DEBUGINFOD_HEADERS_FILE");
187  if (!Filename)
188  return {};
190  MemoryBuffer::getFile(Filename, /*IsText=*/true);
191  if (!HeadersFile)
192  return {};
193 
195  uint64_t LineNumber = 0;
196  for (StringRef Line : llvm::split((*HeadersFile)->getBuffer(), '\n')) {
197  LineNumber++;
198  if (!Line.empty() && Line.back() == '\r')
199  Line = Line.drop_back();
200  if (!isHeader(Line)) {
201  if (!all_of(Line, llvm::isSpace))
203  << "could not parse debuginfod header: " << Filename << ':'
204  << LineNumber << '\n';
205  continue;
206  }
207  Headers.emplace_back(Line);
208  }
209  return Headers;
210 }
211 
213  StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
214  ArrayRef<StringRef> DebuginfodUrls, std::chrono::milliseconds Timeout) {
215  SmallString<64> AbsCachedArtifactPath;
216  sys::path::append(AbsCachedArtifactPath, CacheDirectoryPath,
217  "llvmcache-" + UniqueKey);
218 
219  Expected<FileCache> CacheOrErr =
220  localCache("Debuginfod-client", ".debuginfod-client", CacheDirectoryPath);
221  if (!CacheOrErr)
222  return CacheOrErr.takeError();
223 
224  FileCache Cache = *CacheOrErr;
225  // We choose an arbitrary Task parameter as we do not make use of it.
226  unsigned Task = 0;
227  Expected<AddStreamFn> CacheAddStreamOrErr = Cache(Task, UniqueKey, "");
228  if (!CacheAddStreamOrErr)
229  return CacheAddStreamOrErr.takeError();
230  AddStreamFn &CacheAddStream = *CacheAddStreamOrErr;
231  if (!CacheAddStream)
232  return std::string(AbsCachedArtifactPath);
233  // The artifact was not found in the local cache, query the debuginfod
234  // servers.
237  "No working HTTP client is available.");
238 
240  return createStringError(
242  "A working HTTP client is available, but it is not initialized. To "
243  "allow Debuginfod to make HTTP requests, call HTTPClient::initialize() "
244  "at the beginning of main.");
245 
246  HTTPClient Client;
247  Client.setTimeout(Timeout);
248  for (StringRef ServerUrl : DebuginfodUrls) {
249  SmallString<64> ArtifactUrl;
250  sys::path::append(ArtifactUrl, sys::path::Style::posix, ServerUrl, UrlPath);
251 
252  // Perform the HTTP request and if successful, write the response body to
253  // the cache.
254  StreamedHTTPResponseHandler Handler(
255  [&]() { return CacheAddStream(Task, ""); }, Client);
256  HTTPRequest Request(ArtifactUrl);
257  Request.Headers = getHeaders();
258  Error Err = Client.perform(Request, Handler);
259  if (Err)
260  return std::move(Err);
261 
262  if (Client.responseCode() != 200)
263  continue;
264 
265  // Return the path to the artifact on disk.
266  return std::string(AbsCachedArtifactPath);
267  }
268 
269  return createStringError(errc::argument_out_of_domain, "build id not found");
270 }
271 
273  : Message(Message.str()) {}
274 
275 void DebuginfodLog::push(const Twine &Message) {
276  push(DebuginfodLogEntry(Message));
277 }
278 
280  {
281  std::lock_guard<std::mutex> Guard(QueueMutex);
282  LogEntryQueue.push(Entry);
283  }
284  QueueCondition.notify_one();
285 }
286 
288  {
289  std::unique_lock<std::mutex> Guard(QueueMutex);
290  // Wait for messages to be pushed into the queue.
291  QueueCondition.wait(Guard, [&] { return !LogEntryQueue.empty(); });
292  }
293  std::lock_guard<std::mutex> Guard(QueueMutex);
294  if (!LogEntryQueue.size())
295  llvm_unreachable("Expected message in the queue.");
296 
297  DebuginfodLogEntry Entry = LogEntryQueue.front();
298  LogEntryQueue.pop();
299  return Entry;
300 }
301 
303  DebuginfodLog &Log, ThreadPool &Pool,
304  double MinInterval)
305  : Log(Log), Pool(Pool), MinInterval(MinInterval) {
306  for (StringRef Path : PathsRef)
307  Paths.push_back(Path.str());
308 }
309 
311  std::lock_guard<sys::Mutex> Guard(UpdateMutex);
312  if (UpdateTimer.isRunning())
313  UpdateTimer.stopTimer();
314  UpdateTimer.clear();
315  for (const std::string &Path : Paths) {
316  Log.push("Updating binaries at path " + Path);
317  if (Error Err = findBinaries(Path))
318  return Err;
319  }
320  Log.push("Updated collection");
321  UpdateTimer.startTimer();
322  return Error::success();
323 }
324 
325 Expected<bool> DebuginfodCollection::updateIfStale() {
326  if (!UpdateTimer.isRunning())
327  return false;
328  UpdateTimer.stopTimer();
329  double Time = UpdateTimer.getTotalTime().getWallTime();
330  UpdateTimer.startTimer();
331  if (Time < MinInterval)
332  return false;
333  if (Error Err = update())
334  return std::move(Err);
335  return true;
336 }
337 
339  while (true) {
340  if (Error Err = update())
341  return Err;
342  std::this_thread::sleep_for(Interval);
343  }
344  llvm_unreachable("updateForever loop should never end");
345 }
346 
347 static bool hasELFMagic(StringRef FilePath) {
349  std::error_code EC = identify_magic(FilePath, Type);
350  if (EC)
351  return false;
352  switch (Type) {
353  case file_magic::elf:
358  return true;
359  default:
360  return false;
361  }
362 }
363 
364 Error DebuginfodCollection::findBinaries(StringRef Path) {
365  std::error_code EC;
366  sys::fs::recursive_directory_iterator I(Twine(Path), EC), E;
367  std::mutex IteratorMutex;
368  ThreadPoolTaskGroup IteratorGroup(Pool);
369  for (unsigned WorkerIndex = 0; WorkerIndex < Pool.getThreadCount();
370  WorkerIndex++) {
371  IteratorGroup.async([&, this]() -> void {
372  std::string FilePath;
373  while (true) {
374  {
375  // Check if iteration is over or there is an error during iteration
376  std::lock_guard<std::mutex> Guard(IteratorMutex);
377  if (I == E || EC)
378  return;
379  // Grab a file path from the directory iterator and advance the
380  // iterator.
381  FilePath = I->path();
382  I.increment(EC);
383  }
384 
385  // Inspect the file at this path to determine if it is debuginfo.
386  if (!hasELFMagic(FilePath))
387  continue;
388 
389  Expected<object::OwningBinary<object::Binary>> BinOrErr =
390  object::createBinary(FilePath);
391 
392  if (!BinOrErr) {
393  consumeError(BinOrErr.takeError());
394  continue;
395  }
396  object::Binary *Bin = std::move(BinOrErr.get().getBinary());
397  if (!Bin->isObject())
398  continue;
399 
400  // TODO: Support non-ELF binaries
401  object::ELFObjectFileBase *Object =
402  dyn_cast<object::ELFObjectFileBase>(Bin);
403  if (!Object)
404  continue;
405 
406  std::optional<BuildIDRef> ID = getBuildID(Object);
407  if (!ID)
408  continue;
409 
410  std::string IDString = buildIDToString(ID.value());
411  if (Object->hasDebugInfo()) {
412  std::lock_guard<sys::RWMutex> DebugBinariesGuard(DebugBinariesMutex);
413  DebugBinaries[IDString] = FilePath;
414  } else {
415  std::lock_guard<sys::RWMutex> BinariesGuard(BinariesMutex);
416  Binaries[IDString] = FilePath;
417  }
418  }
419  });
420  }
421  IteratorGroup.wait();
422  std::unique_lock<std::mutex> Guard(IteratorMutex);
423  if (EC)
424  return errorCodeToError(EC);
425  return Error::success();
426 }
427 
428 Expected<Optional<std::string>>
429 DebuginfodCollection::getBinaryPath(BuildIDRef ID) {
430  Log.push("getting binary path of ID " + buildIDToString(ID));
431  std::shared_lock<sys::RWMutex> Guard(BinariesMutex);
432  auto Loc = Binaries.find(buildIDToString(ID));
433  if (Loc != Binaries.end()) {
434  std::string Path = Loc->getValue();
435  return Path;
436  }
437  return std::nullopt;
438 }
439 
440 Expected<Optional<std::string>>
441 DebuginfodCollection::getDebugBinaryPath(BuildIDRef ID) {
442  Log.push("getting debug binary path of ID " + buildIDToString(ID));
443  std::shared_lock<sys::RWMutex> Guard(DebugBinariesMutex);
444  auto Loc = DebugBinaries.find(buildIDToString(ID));
445  if (Loc != DebugBinaries.end()) {
446  std::string Path = Loc->getValue();
447  return Path;
448  }
449  return std::nullopt;
450 }
451 
453  {
454  // Check collection; perform on-demand update if stale.
455  Expected<Optional<std::string>> PathOrErr = getBinaryPath(ID);
456  if (!PathOrErr)
457  return PathOrErr.takeError();
458  Optional<std::string> Path = *PathOrErr;
459  if (!Path) {
460  Expected<bool> UpdatedOrErr = updateIfStale();
461  if (!UpdatedOrErr)
462  return UpdatedOrErr.takeError();
463  if (*UpdatedOrErr) {
464  // Try once more.
465  PathOrErr = getBinaryPath(ID);
466  if (!PathOrErr)
467  return PathOrErr.takeError();
468  Path = *PathOrErr;
469  }
470  }
471  if (Path)
472  return Path.value();
473  }
474 
475  // Try federation.
477  if (!PathOrErr)
478  consumeError(PathOrErr.takeError());
479 
480  // Fall back to debug binary.
481  return findDebugBinaryPath(ID);
482 }
483 
485  // Check collection; perform on-demand update if stale.
486  Expected<Optional<std::string>> PathOrErr = getDebugBinaryPath(ID);
487  if (!PathOrErr)
488  return PathOrErr.takeError();
489  Optional<std::string> Path = *PathOrErr;
490  if (!Path) {
491  Expected<bool> UpdatedOrErr = updateIfStale();
492  if (!UpdatedOrErr)
493  return UpdatedOrErr.takeError();
494  if (*UpdatedOrErr) {
495  // Try once more.
496  PathOrErr = getBinaryPath(ID);
497  if (!PathOrErr)
498  return PathOrErr.takeError();
499  Path = *PathOrErr;
500  }
501  }
502  if (Path)
503  return Path.value();
504 
505  // Try federation.
507 }
508 
510  DebuginfodCollection &Collection)
511  : Log(Log), Collection(Collection) {
512  cantFail(
513  Server.get(R"(/buildid/(.*)/debuginfo)", [&](HTTPServerRequest Request) {
514  Log.push("GET " + Request.UrlPath);
515  std::string IDString;
516  if (!tryGetFromHex(Request.UrlPathMatches[0], IDString)) {
517  Request.setResponse(
518  {404, "text/plain", "Build ID is not a hex string\n"});
519  return;
520  }
521  object::BuildID ID(IDString.begin(), IDString.end());
523  if (Error Err = PathOrErr.takeError()) {
524  consumeError(std::move(Err));
525  Request.setResponse({404, "text/plain", "Build ID not found\n"});
526  return;
527  }
528  streamFile(Request, *PathOrErr);
529  }));
530  cantFail(
531  Server.get(R"(/buildid/(.*)/executable)", [&](HTTPServerRequest Request) {
532  Log.push("GET " + Request.UrlPath);
533  std::string IDString;
534  if (!tryGetFromHex(Request.UrlPathMatches[0], IDString)) {
535  Request.setResponse(
536  {404, "text/plain", "Build ID is not a hex string\n"});
537  return;
538  }
539  object::BuildID ID(IDString.begin(), IDString.end());
540  Expected<std::string> PathOrErr = Collection.findBinaryPath(ID);
541  if (Error Err = PathOrErr.takeError()) {
542  consumeError(std::move(Err));
543  Request.setResponse({404, "text/plain", "Build ID not found\n"});
544  return;
545  }
546  streamFile(Request, *PathOrErr);
547  }));
548 }
549 
550 } // namespace llvm
llvm::DebuginfodLog::pop
DebuginfodLogEntry pop()
Definition: Debuginfod.cpp:287
MemoryBuffer.h
llvm::HTTPClient
A reusable client that can perform HTTPRequests through a network socket.
Definition: HTTPClient.h:51
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:54
llvm::DebuginfodLogEntry::DebuginfodLogEntry
DebuginfodLogEntry()=default
llvm::DebuginfodCollection::DebuginfodCollection
DebuginfodCollection(ArrayRef< StringRef > Paths, DebuginfodLog &Log, ThreadPool &Pool, double MinInterval)
Definition: Debuginfod.cpp:302
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::AArch64PACKey::ID
ID
Definition: AArch64BaseInfo.h:818
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:1199
llvm::HTTPClient::IsInitialized
static bool IsInitialized
Definition: HTTPClient.h:60
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::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
split
static Error split(StringRef Str, char Separator, std::pair< StringRef, StringRef > &Split)
Checked version of split, to ensure mandatory subparts.
Definition: DataLayout.cpp:219
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::sys::locale::isPrint
bool isPrint(int c)
Definition: Locale.cpp:13
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:82
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:1042
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:452
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:310
Caching.h
CachePruning.h
llvm::all_of
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1734
llvm::object::getBuildID
std::optional< BuildIDRef > getBuildID(const ObjectFile *Obj)
Returns the build ID, if any, contained in the given object file.
Definition: BuildID.cpp:48
llvm::uniqueKey
static std::string uniqueKey(llvm::StringRef S)
Definition: Debuginfod.cpp:50
llvm::errc::argument_out_of_domain
@ argument_out_of_domain
Magic.h
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
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:120
llvm::HTTPClient::perform
Error perform(const HTTPRequest &Request, HTTPResponseHandler &Handler)
Performs the Request, passing response data to the Handler.
Definition: HTTPClient.cpp:151
llvm::pdb::PDB_ColorItem::Path
@ Path
llvm::DebuginfodServer::Server
HTTPServer Server
Definition: Debuginfod.h:134
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
llvm::WithColor::warning
static raw_ostream & warning()
Convenience method for printing "warning: " to stderr.
Definition: WithColor.cpp:85
Debuginfod.h
uint64_t
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:156
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
StringExtras.h
llvm::HTTPClient::isAvailable
static bool isAvailable()
Returns true only if LLVM has been compiled with a working HTTPClient.
Definition: HTTPClient.cpp:143
llvm::AddStreamFn
std::function< Expected< std::unique_ptr< CachedFileStream > >(unsigned Task, const Twine &ModuleName)> AddStreamFn
This type defines the callback to add a file that is generated on the fly.
Definition: Caching.h:42
llvm::isHeader
static bool isHeader(StringRef S)
Definition: Debuginfod.cpp:175
llvm::HTTPClient::setTimeout
void setTimeout(std::chrono::milliseconds Timeout)
Sets the timeout for the entire request, in milliseconds.
Definition: HTTPClient.cpp:149
llvm::getDefaultDebuginfodCacheDirectory
Expected< std::string > getDefaultDebuginfodCacheDirectory()
Finds a default local file caching directory for the debuginfod client, first checking DEBUGINFOD_CAC...
Definition: Debuginfod.cpp:70
llvm::DebuginfodServer::DebuginfodServer
DebuginfodServer(DebuginfodLog &Log, DebuginfodCollection &Collection)
Definition: Debuginfod.cpp:509
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
llvm::localCache
Expected< FileCache > localCache(const Twine &CacheNameRef, const Twine &TempFilePrefixRef, const Twine &CacheDirectoryPathRef, AddBufferFn AddBuffer=[](size_t Task, const Twine &ModuleName, std::unique_ptr< MemoryBuffer > MB) {})
Create a local file system cache which uses the given cache name, temporary file prefix,...
Definition: Caching.cpp:29
Symbolize.h
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::getHeaders
static SmallVector< std::string, 0 > getHeaders()
Definition: Debuginfod.cpp:185
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:744
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::MemoryBuffer::getFile
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false, Optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
Definition: MemoryBuffer.cpp:248
llvm::DebuginfodCollection::updateForever
Error updateForever(std::chrono::milliseconds Interval)
Definition: Debuginfod.cpp:338
ELFObjectFile.h
llvm::DebuginfodLog::push
void push(DebuginfodLogEntry Entry)
Definition: Debuginfod.cpp:279
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:1238
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:58
llvm::errc::io_error
@ io_error
llvm::file_magic::elf_executable
@ elf_executable
ELF Executable image.
Definition: Magic.h:27
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.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:596
llvm::FileCache
std::function< Expected< AddStreamFn >(unsigned Task, StringRef Key, const Twine &ModuleName)> FileCache
This is the type of a file cache.
Definition: Caching.h:58
llvm::ErrorOr
Represents either an error or a value T.
Definition: ErrorOr.h:56
llvm::DebuginfodCollection::findDebugBinaryPath
Expected< std::string > findDebugBinaryPath(object::BuildIDRef)
Definition: Debuginfod.cpp:484
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:347
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:693
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::xxHash64
uint64_t xxHash64(llvm::StringRef Data)
Definition: xxhash.cpp:70
llvm::DebuginfodServer::Collection
DebuginfodCollection & Collection
Definition: Debuginfod.h:136
llvm::SmallVectorImpl::emplace_back
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:941
llvm::DebuginfodLogEntry
Definition: Debuginfod.h:80