29 using namespace llvm::codeview;
30 using namespace llvm::msf;
31 using namespace llvm::pdb;
32 using namespace llvm::support;
35 : Allocator(Allocator) {}
40 auto ExpectedMsf = MSFBuilder::create(Allocator, BlockSize);
42 return ExpectedMsf.takeError();
43 Msf = llvm::make_unique<MSFBuilder>(std::move(*ExpectedMsf));
51 Info = llvm::make_unique<InfoStreamBuilder>(*Msf, NamedStreams);
57 Dbi = llvm::make_unique<DbiStreamBuilder>(*Msf);
63 Tpi = llvm::make_unique<TpiStreamBuilder>(*Msf,
StreamTPI);
69 Ipi = llvm::make_unique<TpiStreamBuilder>(*Msf,
StreamIPI);
79 Publics = llvm::make_unique<PublicsStreamBuilder>(*Msf);
84 auto ExpectedStream = Msf->addStream(Size);
86 return ExpectedStream.takeError();
87 NamedStreams.
set(Name, *ExpectedStream);
93 if (Ipi && Ipi->getRecordCount() > 0) {
105 return std::move(EC);
107 return std::move(EC);
110 if (
auto EC = Info->finalizeMsfLayout())
111 return std::move(EC);
114 if (
auto EC = Dbi->finalizeMsfLayout())
115 return std::move(EC);
118 if (
auto EC = Tpi->finalizeMsfLayout())
119 return std::move(EC);
122 if (
auto EC = Ipi->finalizeMsfLayout())
123 return std::move(EC);
126 if (
auto EC = Publics->finalizeMsfLayout())
127 return std::move(EC);
129 Dbi->setPublicsStreamIndex(Publics->getStreamIndex());
130 Dbi->setSymbolRecordStreamIndex(Publics->getRecordStreamIdx());
139 if (!NamedStreams.
get(Name, SN))
146 auto ExpectedLayout = finalizeMsfLayout();
148 return ExpectedLayout.takeError();
149 auto &Layout = *ExpectedLayout;
151 uint64_t Filesize = Layout.SB->BlockSize * Layout.SB->NumBlocks;
153 if (OutFileOrError.getError())
165 if (
auto EC = Writer.
writeArray(Layout.DirectoryBlocks))
168 auto DirStream = WritableMappedBlockStream::createDirectoryStream(
169 Layout, Buffer, Allocator);
177 for (
const auto &Blocks : Layout.StreamMap) {
184 return ExpectedSN.takeError();
186 auto NS = WritableMappedBlockStream::createIndexedStream(
187 Layout, Buffer, *ExpectedSN, Allocator);
189 if (
auto EC = Strings.
commit(NSWriter))
193 if (
auto EC = Info->commit(Layout, Buffer))
198 if (
auto EC = Dbi->commit(Layout, Buffer))
203 if (
auto EC = Tpi->commit(Layout, Buffer))
208 if (
auto EC = Ipi->commit(Layout, Buffer))
213 auto PS = WritableMappedBlockStream::createIndexedStream(
214 Layout, Buffer, Publics->getStreamIndex(), Allocator);
216 if (
auto EC = Publics->commit(PSWriter))
Error writeObject(const T &Obj)
Writes the object Obj to the underlying stream, as if by using memcpy.
uint64_t blockToOffset(uint64_t BlockNumber, uint64_t BlockSize)
PDBStringTableBuilder & getStringTableBuilder()
Expected< uint32_t > getNamedStreamIndex(StringRef Name) const
void set(StringRef Stream, uint32_t StreamNo)
Error commit(BinaryStreamWriter &Writer) const
DbiStreamBuilder & getDbiBuilder()
Tagged union holding either a T or a Error.
TpiStreamBuilder & getIpiBuilder()
Error commit(StringRef Filename)
Error writeArray(ArrayRef< T > Array)
Writes an array of objects of type T to the underlying stream, as if by using memcpy.
Error commit() override
For buffered streams, commits changes to the backing store.
Error initialize(uint32_t BlockSize)
Allocate memory in an ever growing pool, as if by bump-pointer.
Provides write only access to a subclass of WritableBinaryStream.
static ErrorOr< std::unique_ptr< FileOutputBuffer > > create(StringRef FilePath, size_t Size, unsigned Flags=0)
Factory method to create an OutputBuffer object which manages a read/write buffer of the specified si...
Error writeInteger(T Value)
Write the the integer Value to the underlying stream in the specified endianness. ...
PublicsStreamBuilder & getPublicsBuilder()
static const int BlockSize
static ErrorSuccess success()
Create a success value.
InfoStreamBuilder & getInfoBuilder()
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
void setOffset(uint32_t Off)
msf::MSFBuilder & getMsfBuilder()
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Error addNamedStream(StringRef Name, uint32_t Size)
Lightweight error class with error context and mandatory checking.
bool get(StringRef Stream, uint32_t &StreamNo) const
An implementation of WritableBinaryStream backed by an llvm FileOutputBuffer.
StringRef - Represent a constant reference to a string, i.e.
uint32_t calculateSerializedSize() const
TpiStreamBuilder & getTpiBuilder()