| 1 | //===- llvm/DebugInfod/BuildIDFetcher.cpp - Build ID fetcher --------------===// |
|---|---|
| 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 | /// This file defines a DIFetcher implementation for obtaining debug info |
| 11 | /// from debuginfod. |
| 12 | /// |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "llvm/Debuginfod/BuildIDFetcher.h" |
| 16 | |
| 17 | #include "llvm/Debuginfod/Debuginfod.h" |
| 18 | #include "llvm/Support/Error.h" |
| 19 | |
| 20 | using namespace llvm; |
| 21 | |
| 22 | Expected<std::string> |
| 23 | DebuginfodFetcher::fetch(ArrayRef<uint8_t> BuildID) const { |
| 24 | Expected<std::string> Path = BuildIDFetcher::fetch(BuildID); |
| 25 | if (Path) |
| 26 | return Path; |
| 27 | // Not available locally, so try and download it now. |
| 28 | assert(errorToErrorCode(Path.takeError()) == |
| 29 | std::errc::no_such_file_or_directory && |
| 30 | "BuildIDFetcher::fetch() failed in an unexpected way"); |
| 31 | consumeError(Err: Path.takeError()); |
| 32 | return getCachedOrDownloadDebuginfo(ID: BuildID); |
| 33 | } |
| 34 |