LLVM 23.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 {
25namespace codeview {
26struct GUID;
27}
28
29namespace msf {
30class MSFBuilder;
31struct MSFLayout;
32}
33namespace pdb {
39
41public:
42 LLVM_ABI explicit PDBFileBuilder(BumpPtrAllocator &Allocator);
44 PDBFileBuilder(const PDBFileBuilder &) = delete;
46
48
56 LLVM_ABI std::unique_ptr<SmallVector<char>> &getDXContainerData();
57
58 // If HashPDBContentsToGUID is true on the InfoStreamBuilder, Guid is filled
59 // with the computed PDB GUID on return.
61
65 std::unique_ptr<MemoryBuffer> Buffer);
66
67private:
68 struct InjectedSourceDescriptor {
69 // The full name of the stream that contains the contents of this injected
70 // source. This is built as a concatenation of the literal "/src/files"
71 // plus the "vname".
72 std::string StreamName;
73
74 // The exact name of the file name as specified by the user.
75 uint32_t NameIndex;
76
77 // The string table index of the "vname" of the file. As far as we
78 // understand, this is the same as the name, except it is lowercased and
79 // forward slashes are converted to backslashes.
80 uint32_t VNameIndex;
81 std::unique_ptr<MemoryBuffer> Content;
82 };
83
84 Error finalizeMsfLayout();
85 Expected<uint32_t> allocateNamedStream(StringRef Name, uint32_t Size);
86
87 void commitInjectedSources(WritableBinaryStream &MsfBuffer,
88 const msf::MSFLayout &Layout);
89 void commitSrcHeaderBlock(WritableBinaryStream &MsfBuffer,
90 const msf::MSFLayout &Layout);
91
93
94 std::unique_ptr<msf::MSFBuilder> Msf;
95 std::unique_ptr<InfoStreamBuilder> Info;
96 std::unique_ptr<DbiStreamBuilder> Dbi;
97 std::unique_ptr<GSIStreamBuilder> Gsi;
98 std::unique_ptr<TpiStreamBuilder> Tpi;
99 std::unique_ptr<TpiStreamBuilder> Ipi;
100 std::unique_ptr<SmallVector<char>> Dxc;
101
102 std::unique_ptr<PDBStringTableBuilder> Strings;
103 StringTableHashTraits InjectedSourceHashTraits;
104 HashTable<SrcHeaderBlockEntry> InjectedSourceTable;
105
107
108 NamedStreamMap NamedStreams;
109 DenseMap<uint32_t, std::string> NamedStreamData;
110};
111}
112}
113
114#endif
This file defines the BumpPtrAllocator interface.
#define LLVM_ABI
Definition Compiler.h:213
This file defines the DenseMap class.
static constexpr StringLiteral Filename
Basic Register Allocator
This file defines the SmallVector class.
static const int BlockSize
Definition TarWriter.cpp:33
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.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
A BinaryStream which can be read from as well as written to.
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 std::unique_ptr< SmallVector< char > > & getDXContainerData()
LLVM_ABI Error initialize(uint32_t BlockSize)
LLVM_ABI PDBFileBuilder(BumpPtrAllocator &Allocator)
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.
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:383
This represents the 'GUID' type from windows.h.
Definition GUID.h:22
A single file record entry within the /src/headerblock stream.
Definition RawTypes.h:331