1 //===- llvm/Object/BuildID.h - Build ID -------------------------*- C++ -*-===// 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 declares a library for handling Build IDs and using them to find 11 /// debug info. 12 /// 13 //===----------------------------------------------------------------------===// 14 15 #ifndef LLVM_DEBUGINFO_OBJECT_BUILDID_H 16 #define LLVM_DEBUGINFO_OBJECT_BUILDID_H 17 18 #include "llvm/ADT/ArrayRef.h" 19 #include "llvm/ADT/SmallVector.h" 20 21 namespace llvm { 22 namespace object { 23 24 /// A build ID in binary form. 25 typedef SmallVector<uint8_t, 10> BuildID; 26 27 /// A reference to a BuildID in binary form. 28 typedef ArrayRef<uint8_t> BuildIDRef; 29 30 class ObjectFile; 31 32 /// Parses a build ID from a hex string. 33 BuildID parseBuildID(StringRef Str); 34 35 /// Returns the build ID, if any, contained in the given object file. 36 BuildIDRef getBuildID(const ObjectFile *Obj); 37 38 /// BuildIDFetcher searches local cache directories for debug info. 39 class BuildIDFetcher { 40 public: BuildIDFetcher(std::vector<std::string> DebugFileDirectories)41 BuildIDFetcher(std::vector<std::string> DebugFileDirectories) 42 : DebugFileDirectories(std::move(DebugFileDirectories)) {} 43 virtual ~BuildIDFetcher() = default; 44 45 /// Returns the path to the debug file with the given build ID. 46 virtual std::optional<std::string> fetch(BuildIDRef BuildID) const; 47 48 private: 49 const std::vector<std::string> DebugFileDirectories; 50 }; 51 52 } // namespace object 53 } // namespace llvm 54 55 #endif // LLVM_DEBUGINFO_OBJECT_BUILDID_H 56