xref: /freebsd/contrib/llvm-project/llvm/include/llvm/Object/BuildID.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
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 #include "llvm/Support/Compiler.h"
21 
22 namespace llvm {
23 namespace object {
24 
25 /// A build ID in binary form.
26 typedef SmallVector<uint8_t, 10> BuildID;
27 
28 /// A reference to a BuildID in binary form.
29 typedef ArrayRef<uint8_t> BuildIDRef;
30 
31 class ObjectFile;
32 
33 /// Parses a build ID from a hex string.
34 LLVM_ABI BuildID parseBuildID(StringRef Str);
35 
36 /// Returns the build ID, if any, contained in the given object file.
37 LLVM_ABI BuildIDRef getBuildID(const ObjectFile *Obj);
38 
39 /// BuildIDFetcher searches local cache directories for debug info.
40 class LLVM_ABI BuildIDFetcher {
41 public:
BuildIDFetcher(std::vector<std::string> DebugFileDirectories)42   BuildIDFetcher(std::vector<std::string> DebugFileDirectories)
43       : DebugFileDirectories(std::move(DebugFileDirectories)) {}
44   virtual ~BuildIDFetcher() = default;
45 
46   /// Returns the path to the debug file with the given build ID.
47   virtual std::optional<std::string> fetch(BuildIDRef BuildID) const;
48 
49 private:
50   const std::vector<std::string> DebugFileDirectories;
51 };
52 
53 } // namespace object
54 } // namespace llvm
55 
56 #endif // LLVM_DEBUGINFO_OBJECT_BUILDID_H
57