LLVM: lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
10
20
21using namespace llvm;
25
26namespace llvm {
29}
30}
31
42
46 : MSF(Msf), ModuleName(std::string(ModuleName)) {
47 ::memset(&Layout, 0, sizeof(Layout));
48 Layout.Mod = ModIndex;
49}
50
52
54 return Layout.ModDiStream;
55}
56
58 ObjFileName = std::string(Name);
59}
60
62 PdbFilePathNI = NI;
63}
64
69
74
77
78 if (BulkSymbols.empty())
79 return;
80
82
83
85 "Invalid Symbol alignment!");
86 SymbolByteSize += BulkSymbols.size();
87}
88
91 assert(SymLength > 0);
93
94
95
97 "Invalid Symbol alignment!");
98 SymbolByteSize += SymLength;
99}
100
101void DbiModuleDescriptorBuilder::addSourceFile(StringRef Path) {
103}
104
105uint32_t DbiModuleDescriptorBuilder::calculateC13DebugInfoSize() const {
107 for (const auto &Builder : C13Builders) {
108 Result += Builder.calculateSerializedLength();
109 }
110 return Result;
111}
112
115 uint32_t M = ModuleName.size() + 1;
116 uint32_t O = ObjFileName.size() + 1;
118}
119
121 Layout.FileNameOffs = 0;
122 Layout.Flags = 0;
123 Layout.C11Bytes = 0;
124 Layout.C13Bytes = calculateC13DebugInfoSize();
125 (void)Layout.Mod;
126 (void)Layout.ModDiStream;
127 Layout.NumFiles = SourceFiles.size();
128 Layout.PdbFilePathNI = PdbFilePathNI;
129 Layout.SrcFileNameNI = 0;
130
131
132
133 Layout.SymBytes =
135}
136
139 uint32_t C13Size = calculateC13DebugInfoSize();
140 if (!C13Size && !SymbolByteSize)
142 auto ExpectedSN =
144 if (!ExpectedSN)
145 return ExpectedSN.takeError();
146 Layout.ModDiStream = *ExpectedSN;
148}
149
151
152
154 return EC;
156 return EC;
158 return EC;
160 return EC;
162}
163
168
170 MsfLayout, MsfBuffer, Layout.ModDiStream, MSF.getAllocator());
173
175 return EC;
177 if (Sym.NeedsToBeMerged) {
178 assert(MergeSymsCallback);
179 if (auto EC = MergeSymsCallback(MergeSymsCtx, Sym.SymPtr, SymbolWriter))
180 return EC;
181 } else {
182 if (auto EC = SymbolWriter.writeBytes(Sym.asArray()))
183 return EC;
184 }
185 }
186
187
188 auto SavedOffset = SymbolWriter.getOffset();
192 return E;
193 }
194 SymbolWriter.setOffset(SavedOffset);
195
197 "Invalid debug section alignment!");
198
199 for (const auto &Builder : C13Builders) {
201 return EC;
202 }
203
204
206 return EC;
209
211}
212
214 std::shared_ptr Subsection) {
217}
218
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static uint32_t calculateDiSymbolStreamSize(uint32_t SymbolByteSize, uint32_t C13Size)
Definition DbiModuleDescriptorBuilder.cpp:32
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
bool empty() const
empty - Check if the array is empty.
Provides write only access to a subclass of WritableBinaryStream.
LLVM_ABI Error writeCString(StringRef Str)
Write the string Str to the underlying stream followed by a null terminator.
uint64_t getOffset() const
Error writeInteger(T Value)
Write the integer Value to the underlying stream in the specified endianness.
uint64_t bytesRemaining() const
LLVM_ABI Error writeBytes(ArrayRef< uint8_t > Buffer)
Write the bytes specified in Buffer to the underlying stream.
void setOffset(uint64_t Off)
Error writeObject(const T &Obj)
Writes the object Obj to the underlying stream, as if by using memcpy.
LLVM_ABI Error padToAlignment(uint32_t Align)
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
StringRef - Represent a constant reference to a string, i.e.
static std::unique_ptr< WritableMappedBlockStream > createIndexedStream(const MSFLayout &Layout, WritableBinaryStreamRef MsfData, uint32_t StreamIndex, BumpPtrAllocator &Allocator)
LLVM_ABI void addUnmergedSymbols(void *SymSrc, uint32_t SymLength)
Definition DbiModuleDescriptorBuilder.cpp:89
LLVM_ABI void setObjFileName(StringRef Name)
Definition DbiModuleDescriptorBuilder.cpp:57
LLVM_ABI ~DbiModuleDescriptorBuilder()
LLVM_ABI void setFirstSectionContrib(const SectionContrib &SC)
Definition DbiModuleDescriptorBuilder.cpp:65
LLVM_ABI Error finalizeMsfLayout()
Definition DbiModuleDescriptorBuilder.cpp:137
LLVM_ABI void finalize()
Definition DbiModuleDescriptorBuilder.cpp:120
LLVM_ABI uint16_t getStreamIndex() const
Definition DbiModuleDescriptorBuilder.cpp:53
LLVM_ABI void addSymbol(codeview::CVSymbol Symbol)
Definition DbiModuleDescriptorBuilder.cpp:70
LLVM_ABI void setPdbFilePathNI(uint32_t NI)
Definition DbiModuleDescriptorBuilder.cpp:61
LLVM_ABI Error commitSymbolStream(const msf::MSFLayout &MsfLayout, WritableBinaryStreamRef MsfBuffer)
Commit the accumulated symbols to the module symbol stream.
Definition DbiModuleDescriptorBuilder.cpp:164
LLVM_ABI Error commit(BinaryStreamWriter &ModiWriter)
Commit the DBI descriptor to the DBI stream.
Definition DbiModuleDescriptorBuilder.cpp:150
LLVM_ABI void addDebugSubsection(std::shared_ptr< codeview::DebugSubsection > Subsection)
uint32_t getNextSymbolOffset() const
Return the offset within the module symbol stream of the next symbol record passed to addSymbol.
LLVM_ABI void addSymbolsInBulk(ArrayRef< uint8_t > BulkSymbols)
Definition DbiModuleDescriptorBuilder.cpp:75
LLVM_ABI DbiModuleDescriptorBuilder(StringRef ModuleName, uint32_t ModIndex, msf::MSFBuilder &Msf)
Definition DbiModuleDescriptorBuilder.cpp:43
LLVM_ABI uint32_t calculateSerializedLength() const
Definition DbiModuleDescriptorBuilder.cpp:113
CVRecord< SymbolKind > CVSymbol
uint32_t alignOf(CodeViewContainer Container)
const uint16_t kInvalidStreamIndex
This is an optimization pass for GlobalISel generic memory operations.
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
@ Ref
The access may reference the value stored in memory.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Implement std::hash so that hash_code can be used in STL containers.
Represents a string table reference at some offset in the module symbol stream.