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
18
19using namespace llvm;
20using namespace llvm::codeview;
21using namespace llvm::msf;
22using namespace llvm::pdb;
23
25 NamedStreamMap &NamedStreams)
26 : Msf(Msf), Ver(PdbRaw_ImplVer::PdbImplVC70), Age(0),
27 NamedStreams(NamedStreams) {
28 ::memset(&Guid, 0, sizeof(Guid));
29}
30
32
34 Features.push_back(Sig);
35}
36
38 HashPDBContentsToGUID = B;
39}
40
42
43void InfoStreamBuilder::setSignature(uint32_t S) { Signature = S; }
44
46
47
50 NamedStreams.calculateSerializedLength() +
51 (Features.size() + 1) * sizeof(uint32_t);
52 if (auto EC = Msf.setStreamSize(StreamPDB, Length))
53 return EC;
54 return Error::success();
55}
56
58 WritableBinaryStreamRef Buffer) const {
59 llvm::TimeTraceScope timeScope("Commit info stream");
61 Layout, Buffer, StreamPDB, Msf.getAllocator());
62 BinaryStreamWriter Writer(*InfoS);
63
65 // Leave the build id fields 0 so they can be set as the last step before
66 // committing the file to disk.
67 ::memset(&H, 0, sizeof(H));
68 H.Version = Ver;
69 if (auto EC = Writer.writeObject(H))
70 return EC;
71
72 if (auto EC = NamedStreams.commit(Writer))
73 return EC;
74 if (auto EC = Writer.writeInteger(0))
75 return EC;
76 for (auto E : Features) {
77 if (auto EC = Writer.writeEnum(E))
78 return EC;
79 }
80 assert(Writer.bytesRemaining() == 0);
81 return Error::success();
82}
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:163
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