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