Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===- InfoStreamBuilder.h - PDB Info Stream Creation -----------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef LLVM_DEBUGINFO_PDB_RAW_PDBINFOSTREAMBUILDER_H |
| 11 | #define LLVM_DEBUGINFO_PDB_RAW_PDBINFOSTREAMBUILDER_H |
| 12 | |
| 13 | #include "llvm/ADT/Optional.h" |
| 14 | #include "llvm/Support/Error.h" |
| 15 | |
| 16 | #include "llvm/DebugInfo/PDB/Native/NamedStreamMap.h" |
| 17 | #include "llvm/DebugInfo/PDB/Native/PDBFile.h" |
| 18 | #include "llvm/DebugInfo/PDB/Native/RawConstants.h" |
| 19 | #include "llvm/DebugInfo/PDB/PDBTypes.h" |
| 20 | |
| 21 | namespace llvm { |
| 22 | class WritableBinaryStreamRef; |
| 23 | |
| 24 | namespace msf { |
| 25 | class MSFBuilder; |
| 26 | } |
| 27 | namespace pdb { |
| 28 | class PDBFile; |
| 29 | class NamedStreamMap; |
| 30 | |
| 31 | class InfoStreamBuilder { |
| 32 | public: |
| 33 | InfoStreamBuilder(msf::MSFBuilder &Msf, NamedStreamMap &NamedStreams); |
| 34 | InfoStreamBuilder(const InfoStreamBuilder &) = delete; |
| 35 | InfoStreamBuilder &operator=(const InfoStreamBuilder &) = delete; |
| 36 | |
| 37 | void setVersion(PdbRaw_ImplVer V); |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 38 | void addFeature(PdbRaw_FeatureSig Sig); |
| 39 | |
| 40 | // If this is true, the PDB contents are hashed and this hash is used as |
| 41 | // PDB GUID and as Signature. The age is always 1. |
| 42 | void setHashPDBContentsToGUID(bool B); |
| 43 | |
| 44 | // These only have an effect if hashPDBContentsToGUID() is false. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 45 | void setSignature(uint32_t S); |
| 46 | void setAge(uint32_t A); |
| 47 | void setGuid(codeview::GUID G); |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 48 | |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 49 | bool hashPDBContentsToGUID() const { return HashPDBContentsToGUID; } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 50 | uint32_t getAge() const { return Age; } |
| 51 | codeview::GUID getGuid() const { return Guid; } |
| 52 | Optional<uint32_t> getSignature() const { return Signature; } |
| 53 | |
| 54 | uint32_t finalize(); |
| 55 | |
| 56 | Error finalizeMsfLayout(); |
| 57 | |
| 58 | Error commit(const msf::MSFLayout &Layout, |
| 59 | WritableBinaryStreamRef Buffer) const; |
| 60 | |
| 61 | private: |
| 62 | msf::MSFBuilder &Msf; |
| 63 | |
| 64 | std::vector<PdbRaw_FeatureSig> Features; |
| 65 | PdbRaw_ImplVer Ver; |
| 66 | uint32_t Age; |
| 67 | Optional<uint32_t> Signature; |
| 68 | codeview::GUID Guid; |
| 69 | |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 70 | bool HashPDBContentsToGUID = false; |
| 71 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 72 | NamedStreamMap &NamedStreams; |
| 73 | }; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | #endif |