LLVM 22.0.0git
PDBFileBuilder.h
Go to the documentation of this file.
1//===- PDBFileBuilder.h - PDB File 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
9#ifndef LLVM_DEBUGINFO_PDB_NATIVE_PDBFILEBUILDER_H
10#define LLVM_DEBUGINFO_PDB_NATIVE_PDBFILEBUILDER_H
11
12#include "llvm/ADT/DenseMap.h"
19#include "llvm/Support/Error.h"
21#include <memory>
22
23namespace llvm {
24class WritableBinaryStream;
25namespace codeview {
26struct GUID;
27}
28
29namespace msf {
30class MSFBuilder;
31struct MSFLayout;
32}
33namespace pdb {
34struct SrcHeaderBlockEntry;
35class DbiStreamBuilder;
36class InfoStreamBuilder;
37class GSIStreamBuilder;
38class TpiStreamBuilder;
39
41public:
42 LLVM_ABI explicit PDBFileBuilder(BumpPtrAllocator &Allocator);
44 PDBFileBuilder(const PDBFileBuilder &) = delete;
46
48
56
57 // If HashPDBContentsToGUID is true on the InfoStreamBuilder, Guid is filled
58 // with the computed PDB GUID on return.
60
64 std::unique_ptr<MemoryBuffer> Buffer);
65
66private:
67 struct InjectedSourceDescriptor {
68 // The full name of the stream that contains the contents of this injected
69 // source. This is built as a concatenation of the literal "/src/files"
70 // plus the "vname".
71 std::string StreamName;
72
73 // The exact name of the file name as specified by the user.
74 uint32_t NameIndex;
75
76 // The string table index of the "vname" of the file. As far as we
77 // understand, this is the same as the name, except it is lowercased and
78 // forward slashes are converted to backslashes.
79 uint32_t VNameIndex;
80 std::unique_ptr<MemoryBuffer> Content;
81 };
82
83 Error finalizeMsfLayout();
84 Expected<uint32_t> allocateNamedStream(StringRef Name, uint32_t Size);
85
86 void commitInjectedSources(WritableBinaryStream &MsfBuffer,
87 const msf::MSFLayout &Layout);
88 void commitSrcHeaderBlock(WritableBinaryStream &MsfBuffer,
89 const msf::MSFLayout &Layout);
90
92
93 std::unique_ptr<msf::MSFBuilder> Msf;
94 std::unique_ptr<InfoStreamBuilder> Info;
95 std::unique_ptr<DbiStreamBuilder> Dbi;
96 std::unique_ptr<GSIStreamBuilder> Gsi;
97 std::unique_ptr<TpiStreamBuilder> Tpi;
98 std::unique_ptr<TpiStreamBuilder> Ipi;
99
100 PDBStringTableBuilder Strings;
101 StringTableHashTraits InjectedSourceHashTraits;
102 HashTable<SrcHeaderBlockEntry> InjectedSourceTable;
103
105
106 NamedStreamMap NamedStreams;
107 DenseMap<uint32_t, std::string> NamedStreamData;
108};
109}
110}
111
112#endif
This file defines the BumpPtrAllocator interface.
#define LLVM_ABI
Definition: Compiler.h:213
This file defines the DenseMap class.
T Content
std::string Name
uint64_t Size
Basic Register Allocator
This file defines the SmallVector class.
static const int BlockSize
Definition: TarWriter.cpp:33
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:67
Lightweight error class with error context and mandatory checking.
Definition: Error.h:159
Tagged union holding either a T or a Error.
Definition: Error.h:485
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
A BinaryStream which can be read from as well as written to.
Definition: BinaryStream.h:72
PDBFileBuilder(const PDBFileBuilder &)=delete
LLVM_ABI TpiStreamBuilder & getTpiBuilder()
LLVM_ABI msf::MSFBuilder & getMsfBuilder()
PDBFileBuilder & operator=(const PDBFileBuilder &)=delete
LLVM_ABI PDBStringTableBuilder & getStringTableBuilder()
LLVM_ABI Error addNamedStream(StringRef Name, StringRef Data)
LLVM_ABI DbiStreamBuilder & getDbiBuilder()
LLVM_ABI TpiStreamBuilder & getIpiBuilder()
LLVM_ABI GSIStreamBuilder & getGsiBuilder()
LLVM_ABI InfoStreamBuilder & getInfoBuilder()
LLVM_ABI Error initialize(uint32_t BlockSize)
LLVM_ABI Error commit(StringRef Filename, codeview::GUID *Guid)
LLVM_ABI void addInjectedSource(StringRef Name, std::unique_ptr< MemoryBuffer > Buffer)
LLVM_ABI Expected< uint32_t > getNamedStreamIndex(StringRef Name) const
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
This represents the 'GUID' type from windows.h.
Definition: GUID.h:22