LLVM 20.0.0git
InfoStreamBuilder.cpp
Go to the documentation of this file.
1//===- InfoStreamBuilder.cpp - 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
10
17
18using namespace llvm;
19using namespace llvm::codeview;
20using namespace llvm::msf;
21using namespace llvm::pdb;
22
24 NamedStreamMap &NamedStreams)
25 : Msf(Msf), Ver(PdbRaw_ImplVer::PdbImplVC70), Age(0),
26 NamedStreams(NamedStreams) {
27 ::memset(&Guid, 0, sizeof(Guid));
28}
29
31
33 Features.push_back(Sig);
34}
35
37 HashPDBContentsToGUID = B;
38}
39
41
42void InfoStreamBuilder::setSignature(uint32_t S) { Signature = S; }
43
45
46
49 NamedStreams.calculateSerializedLength() +
50 (Features.size() + 1) * sizeof(uint32_t);
51 if (auto EC = Msf.setStreamSize(StreamPDB, Length))
52 return EC;
53 return Error::success();
54}
55
57 WritableBinaryStreamRef Buffer) const {
58 llvm::TimeTraceScope timeScope("Commit info stream");
60 Layout, Buffer, StreamPDB, Msf.getAllocator());
61 BinaryStreamWriter Writer(*InfoS);
62
64 // Leave the build id fields 0 so they can be set as the last step before
65 // committing the file to disk.
66 ::memset(&H, 0, sizeof(H));
67 H.Version = Ver;
68 if (auto EC = Writer.writeObject(H))
69 return EC;
70
71 if (auto EC = NamedStreams.commit(Writer))
72 return EC;
73 if (auto EC = Writer.writeInteger(0))
74 return EC;
75 for (auto E : Features) {
76 if (auto EC = Writer.writeEnum(E))
77 return EC;
78 }
79 assert(Writer.bytesRemaining() == 0);
80 return Error::success();
81}
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define G(x, y, z)
Definition: MD5.cpp:56
#define H(x, y, z)
Definition: MD5.cpp:57
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Provides write only access to a subclass of WritableBinaryStream.
Error writeInteger(T Value)
Write the integer Value to the underlying stream in the specified endianness.
uint64_t bytesRemaining() const
Error writeEnum(T Num)
Similar to writeInteger.
Error writeObject(const T &Obj)
Writes the object Obj to the underlying stream, as if by using memcpy.
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
static ErrorSuccess success()
Create a success value.
Definition: Error.h:337
The TimeTraceScope is a helper class to call the begin and end functions of the time trace profiler.
Definition: TimeProfiler.h:180
BumpPtrAllocator & getAllocator()
Definition: MSFBuilder.h:119
Error setStreamSize(uint32_t Idx, uint32_t Size)
Update the size of an existing stream.
Definition: MSFBuilder.cpp:193
static std::unique_ptr< WritableMappedBlockStream > createIndexedStream(const MSFLayout &Layout, WritableBinaryStreamRef MsfData, uint32_t StreamIndex, BumpPtrAllocator &Allocator)
void addFeature(PdbRaw_FeatureSig Sig)
Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer) const
InfoStreamBuilder(msf::MSFBuilder &Msf, NamedStreamMap &NamedStreams)
void setVersion(PdbRaw_ImplVer V)
void setGuid(codeview::GUID G)
Error commit(BinaryStreamWriter &Writer) const
uint32_t calculateSerializedLength() const
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Length
Definition: DWP.cpp:480
This represents the 'GUID' type from windows.h.
Definition: GUID.h:21
The header preceding the global PDB Stream (Stream 1)
Definition: RawTypes.h:304