1 //===- GSIStreamBuilder.h - PDB Publics/Globals Stream Creation -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_DEBUGINFO_PDB_RAW_GSISTREAMBUILDER_H
11 #define LLVM_DEBUGINFO_PDB_RAW_GSISTREAMBUILDER_H
13 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
14 #include "llvm/DebugInfo/PDB/Native/GlobalsStream.h"
15 #include "llvm/DebugInfo/PDB/Native/RawConstants.h"
16 #include "llvm/DebugInfo/PDB/Native/RawTypes.h"
17 #include "llvm/Support/BinaryByteStream.h"
18 #include "llvm/Support/BinaryItemStream.h"
19 #include "llvm/Support/BinaryStreamRef.h"
20 #include "llvm/Support/BinaryStreamWriter.h"
21 #include "llvm/Support/Endian.h"
22 #include "llvm/Support/Error.h"
26 template <> struct BinaryItemTraits<codeview::CVSymbol> {
27 static size_t length(const codeview::CVSymbol &Item) {
28 return Item.RecordData.size();
30 static ArrayRef<uint8_t> bytes(const codeview::CVSymbol &Item) {
31 return Item.RecordData;
40 struct GSIHashStreamBuilder;
42 class GSIStreamBuilder {
45 explicit GSIStreamBuilder(msf::MSFBuilder &Msf);
48 GSIStreamBuilder(const GSIStreamBuilder &) = delete;
49 GSIStreamBuilder &operator=(const GSIStreamBuilder &) = delete;
51 Error finalizeMsfLayout();
53 Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer);
55 uint32_t getPublicsStreamIndex() const;
56 uint32_t getGlobalsStreamIndex() const;
57 uint32_t getRecordStreamIdx() const { return RecordStreamIdx; }
59 void addPublicSymbol(const codeview::PublicSym32 &Pub);
61 void addGlobalSymbol(const codeview::ProcRefSym &Sym);
62 void addGlobalSymbol(const codeview::DataSym &Sym);
63 void addGlobalSymbol(const codeview::ConstantSym &Sym);
64 void addGlobalSymbol(const codeview::UDTSym &Sym);
65 void addGlobalSymbol(const codeview::CVSymbol &Sym);
68 uint32_t calculatePublicsHashStreamSize() const;
69 uint32_t calculateGlobalsHashStreamSize() const;
70 Error commitSymbolRecordStream(WritableBinaryStreamRef Stream);
71 Error commitPublicsHashStream(WritableBinaryStreamRef Stream);
72 Error commitGlobalsHashStream(WritableBinaryStreamRef Stream);
74 uint32_t RecordStreamIdx = kInvalidStreamIndex;
76 std::unique_ptr<GSIHashStreamBuilder> PSH;
77 std::unique_ptr<GSIHashStreamBuilder> GSH;