1 //===- InfoStreamBuilder.h - PDB Info Stream Creation -----------*- 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 #ifndef LLVM_DEBUGINFO_PDB_NATIVE_INFOSTREAMBUILDER_H 10 #define LLVM_DEBUGINFO_PDB_NATIVE_INFOSTREAMBUILDER_H 11 12 #include "llvm/ADT/Optional.h" 13 #include "llvm/Support/Error.h" 14 15 #include "llvm/DebugInfo/CodeView/GUID.h" 16 #include "llvm/DebugInfo/PDB/Native/RawConstants.h" 17 18 namespace llvm { 19 class WritableBinaryStreamRef; 20 21 namespace msf { 22 class MSFBuilder; 23 struct MSFLayout; 24 } 25 namespace pdb { 26 class NamedStreamMap; 27 28 class InfoStreamBuilder { 29 public: 30 InfoStreamBuilder(msf::MSFBuilder &Msf, NamedStreamMap &NamedStreams); 31 InfoStreamBuilder(const InfoStreamBuilder &) = delete; 32 InfoStreamBuilder &operator=(const InfoStreamBuilder &) = delete; 33 34 void setVersion(PdbRaw_ImplVer V); 35 void addFeature(PdbRaw_FeatureSig Sig); 36 37 // If this is true, the PDB contents are hashed and this hash is used as 38 // PDB GUID and as Signature. The age is always 1. 39 void setHashPDBContentsToGUID(bool B); 40 41 // These only have an effect if hashPDBContentsToGUID() is false. 42 void setSignature(uint32_t S); 43 void setAge(uint32_t A); 44 void setGuid(codeview::GUID G); 45 46 bool hashPDBContentsToGUID() const { return HashPDBContentsToGUID; } 47 uint32_t getAge() const { return Age; } 48 codeview::GUID getGuid() const { return Guid; } 49 Optional<uint32_t> getSignature() const { return Signature; } 50 51 uint32_t finalize(); 52 53 Error finalizeMsfLayout(); 54 55 Error commit(const msf::MSFLayout &Layout, 56 WritableBinaryStreamRef Buffer) const; 57 58 private: 59 msf::MSFBuilder &Msf; 60 61 std::vector<PdbRaw_FeatureSig> Features; 62 PdbRaw_ImplVer Ver; 63 uint32_t Age; 64 Optional<uint32_t> Signature; 65 codeview::GUID Guid; 66 67 bool HashPDBContentsToGUID = false; 68 69 NamedStreamMap &NamedStreams; 70 }; 71 } // namespace pdb 72 } 73 74 #endif 75