LLVM 22.0.0git
DbiStreamBuilder.h
Go to the documentation of this file.
1//===- DbiStreamBuilder.h - PDB Dbi 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
9#ifndef LLVM_DEBUGINFO_PDB_NATIVE_DBISTREAMBUILDER_H
10#define LLVM_DEBUGINFO_PDB_NATIVE_DBISTREAMBUILDER_H
11
12#include "llvm/ADT/StringMap.h"
13#include "llvm/ADT/StringRef.h"
15#include "llvm/Object/COFF.h"
18#include "llvm/Support/Error.h"
19
27
28namespace llvm {
29
31namespace codeview {
32struct FrameData;
33}
34namespace msf {
35class MSFBuilder;
36struct MSFLayout;
37}
38namespace pdb {
40
42public:
45
48
52 LLVM_ABI void setBuildNumber(uint8_t Major, uint8_t Minor);
58
59 // Add given bytes as a new stream.
61
63
65
70 LLVM_ABI void addOldFpoData(const object::FpoData &Fpo);
71
75 StringRef File);
77
79
80 LLVM_ABI Error commit(const msf::MSFLayout &Layout,
81 WritableBinaryStreamRef MsfBuffer);
82
84 SectionContribs.emplace_back(SC);
85 }
86
87 // Populate the Section Map from COFF section headers.
89
90private:
91 struct DebugStream {
92 std::function<Error(BinaryStreamWriter &)> WriteFn;
93 uint32_t Size = 0;
94 uint16_t StreamNumber = kInvalidStreamIndex;
95 };
96
98 uint32_t calculateModiSubstreamSize() const;
99 uint32_t calculateNamesOffset() const;
100 uint32_t calculateSectionContribsStreamSize() const;
101 uint32_t calculateSectionMapStreamSize() const;
102 uint32_t calculateFileInfoSubstreamSize() const;
103 uint32_t calculateNamesBufferSize() const;
104 uint32_t calculateDbgStreamsSize() const;
105
106 Error generateFileInfoSubstream();
107
108 msf::MSFBuilder &Msf;
110
111 std::optional<PdbRaw_DbiVer> VerHeader;
112 uint32_t Age;
113 uint16_t BuildNumber;
114 uint16_t PdbDllVersion;
115 uint16_t PdbDllRbld;
116 uint16_t Flags;
117 PDB_Machine MachineType;
118 uint32_t GlobalsStreamIndex = kInvalidStreamIndex;
119 uint32_t PublicsStreamIndex = kInvalidStreamIndex;
120 uint32_t SymRecordStreamIndex = kInvalidStreamIndex;
121
122 const DbiStreamHeader *Header;
123
124 std::vector<std::unique_ptr<DbiModuleDescriptorBuilder>> ModiList;
125
126 std::optional<codeview::DebugFrameDataSubsection> NewFpoData;
127 std::vector<object::FpoData> OldFpoData;
128
129 StringMap<uint32_t> SourceFileNames;
130
131 PDBStringTableBuilder ECNamesBuilder;
132 WritableBinaryStreamRef NamesBuffer;
133 MutableBinaryByteStream FileInfoBuffer;
134 std::vector<SectionContrib> SectionContribs;
135 std::vector<SecMapEntry> SectionMap;
136 std::array<std::optional<DebugStream>, (int)DbgHeaderType::Max> DbgStreams;
137};
138} // namespace pdb
139}
140
141#endif
This file defines the StringMap class.
arc branch finalize
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_ABI
Definition Compiler.h:213
#define F(x, y, z)
Definition MD5.cpp:55
Basic Register Allocator
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:41
Provides write only access to a subclass of WritableBinaryStream.
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
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
An implementation of BinaryStream which holds its entire data set in a single contiguous buffer.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition StringMap.h:133
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
void addSectionContrib(const SectionContrib &SC)
LLVM_ABI void createSectionMap(ArrayRef< llvm::object::coff_section > SecHdrs)
LLVM_ABI void addOldFpoData(const object::FpoData &Fpo)
LLVM_ABI void setPublicsStreamIndex(uint32_t Index)
LLVM_ABI void setFlags(uint16_t F)
LLVM_ABI Error addModuleSourceFile(DbiModuleDescriptorBuilder &Module, StringRef File)
DbiStreamBuilder(const DbiStreamBuilder &)=delete
LLVM_ABI void setAge(uint32_t A)
LLVM_ABI void setGlobalsStreamIndex(uint32_t Index)
LLVM_ABI Expected< uint32_t > getSourceFileNameIndex(StringRef FileName)
DbiStreamBuilder & operator=(const DbiStreamBuilder &)=delete
LLVM_ABI void setSymbolRecordStreamIndex(uint32_t Index)
LLVM_ABI void addNewFpoData(const codeview::FrameData &FD)
LLVM_ABI void setVersionHeader(PdbRaw_DbiVer V)
LLVM_ABI Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef MsfBuffer)
LLVM_ABI Expected< DbiModuleDescriptorBuilder & > addModuleInfo(StringRef ModuleName)
LLVM_ABI uint32_t calculateSerializedLength() const
LLVM_ABI Error addDbgStream(pdb::DbgHeaderType Type, ArrayRef< uint8_t > Data)
LLVM_ABI uint32_t addECName(StringRef Name)
LLVM_ABI void setBuildNumber(uint16_t B)
LLVM_ABI void setPdbDllVersion(uint16_t V)
LLVM_ABI void setMachineType(PDB_Machine M)
LLVM_ABI void setPdbDllRbld(uint16_t R)
LLVM_ABI DbiStreamBuilder(msf::MSFBuilder &Msf)
MachineTypes
Definition COFF.h:93
const uint16_t kInvalidStreamIndex
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
Data in the SUBSEC_FRAMEDATA subection.
Definition CodeView.h:558