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 /// Returns the build ID, if any, contained in the given object file. 33 std::optional<BuildIDRef> getBuildID(const ObjectFile *Obj); 34 35 /// BuildIDFetcher searches local cache directories for debug info. 36 class BuildIDFetcher { 37 public: BuildIDFetcher(std::vector<std::string> DebugFileDirectories)38 BuildIDFetcher(std::vector<std::string> DebugFileDirectories) 39 : DebugFileDirectories(std::move(DebugFileDirectories)) {} 40 virtual ~BuildIDFetcher() = default; 41 42 /// Returns the path to the debug file with the given build ID. 43 virtual std::optional<std::string> fetch(BuildIDRef BuildID) const; 44 45 private: 46 const std::vector<std::string> DebugFileDirectories; 47 }; 48 49 } // namespace object 50 } // namespace llvm 51 52 #endif // LLVM_DEBUGINFO_OBJECT_BUILDID_H 53