BuildIDFetcher.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031
  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. #include "llvm/Debuginfod/BuildIDFetcher.h"
  15. #include "llvm/Debuginfod/Debuginfod.h"
  16. using namespace llvm;
  17. std::optional<std::string>
  18. DebuginfodFetcher::fetch(ArrayRef<uint8_t> BuildID) const {
  19. if (std::optional<std::string> Path = BuildIDFetcher::fetch(BuildID))
  20. return std::move(*Path);
  21. Expected<std::string> PathOrErr = getCachedOrDownloadDebuginfo(BuildID);
  22. if (PathOrErr)
  23. return *PathOrErr;
  24. consumeError(PathOrErr.takeError());
  25. return std::nullopt;
  26. }