1 //===- GSIStreamBuilder.h - PDB Publics/Globals Stream Creation -*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_DEBUGINFO_PDB_RAW_GSISTREAMBUILDER_H
10 #define LLVM_DEBUGINFO_PDB_RAW_GSISTREAMBUILDER_H
12 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
13 #include "llvm/DebugInfo/PDB/Native/GlobalsStream.h"
14 #include "llvm/DebugInfo/PDB/Native/RawConstants.h"
15 #include "llvm/DebugInfo/PDB/Native/RawTypes.h"
16 #include "llvm/Support/BinaryByteStream.h"
17 #include "llvm/Support/BinaryItemStream.h"
18 #include "llvm/Support/BinaryStreamRef.h"
19 #include "llvm/Support/BinaryStreamWriter.h"
20 #include "llvm/Support/Endian.h"
21 #include "llvm/Support/Error.h"
25 template <> struct BinaryItemTraits
<codeview::CVSymbol
> {
26 static size_t length(const codeview::CVSymbol
&Item
) {
27 return Item
.RecordData
.size();
29 static ArrayRef
<uint8_t> bytes(const codeview::CVSymbol
&Item
) {
30 return Item
.RecordData
;
39 struct GSIHashStreamBuilder
;
41 class GSIStreamBuilder
{
44 explicit GSIStreamBuilder(msf::MSFBuilder
&Msf
);
47 GSIStreamBuilder(const GSIStreamBuilder
&) = delete;
48 GSIStreamBuilder
&operator=(const GSIStreamBuilder
&) = delete;
50 Error
finalizeMsfLayout();
52 Error
commit(const msf::MSFLayout
&Layout
, WritableBinaryStreamRef Buffer
);
54 uint32_t getPublicsStreamIndex() const;
55 uint32_t getGlobalsStreamIndex() const;
56 uint32_t getRecordStreamIdx() const { return RecordStreamIdx
; }
58 void addPublicSymbol(const codeview::PublicSym32
&Pub
);
60 void addGlobalSymbol(const codeview::ProcRefSym
&Sym
);
61 void addGlobalSymbol(const codeview::DataSym
&Sym
);
62 void addGlobalSymbol(const codeview::ConstantSym
&Sym
);
63 void addGlobalSymbol(const codeview::CVSymbol
&Sym
);
66 uint32_t calculatePublicsHashStreamSize() const;
67 uint32_t calculateGlobalsHashStreamSize() const;
68 Error
commitSymbolRecordStream(WritableBinaryStreamRef Stream
);
69 Error
commitPublicsHashStream(WritableBinaryStreamRef Stream
);
70 Error
commitGlobalsHashStream(WritableBinaryStreamRef Stream
);
72 uint32_t RecordStreamIdx
= kInvalidStreamIndex
;
74 std::unique_ptr
<GSIHashStreamBuilder
> PSH
;
75 std::unique_ptr
<GSIHashStreamBuilder
> GSH
;