[CodeView] Support remaining debug subsection types

This adds support for Symbols, StringTable, and FrameData subsection
types.  Even though these subsections rarely if ever appear in a PDB
file (they are usually in object files), there's no theoretical reason
why they *couldn't* appear in a PDB.  The real issue though is that in
order to add support for dumping and writing them (which will be useful
for object files), we need a way to test them.  And since there is no
support for reading and writing them to / from object files yet, making
PDB support them is the best way to both add support for the underlying
format and add support for tests at the same time.  Later, when we go
to add support for reading / writing them from object files, we'll need
only minimal changes in the underlying read/write code.

llvm-svn: 305037
This commit is contained in:
Zachary Turner
2017-06-09 00:28:08 +00:00
parent 4fcdaa9423
commit deb391309c
19 changed files with 637 additions and 132 deletions

View File

@@ -24,7 +24,7 @@ Error DebugStringTableSubsectionRef::initialize(BinaryStreamRef Contents) {
return Error::success();
}
Error DebugStringTableSubsectionRef::initialize(BinaryStreamReader &Reader) {
return Reader.readStreamRef(Stream, Reader.bytesRemaining());
return Reader.readStreamRef(Stream);
}
Expected<StringRef>
@@ -55,20 +55,19 @@ uint32_t DebugStringTableSubsection::calculateSerializedSize() const {
}
Error DebugStringTableSubsection::commit(BinaryStreamWriter &Writer) const {
assert(Writer.bytesRemaining() == StringSize);
uint32_t MaxOffset = 1;
uint32_t Begin = Writer.getOffset();
uint32_t End = Begin + StringSize;
for (auto &Pair : Strings) {
StringRef S = Pair.getKey();
uint32_t Offset = Pair.getValue();
uint32_t Offset = Begin + Pair.getValue();
Writer.setOffset(Offset);
if (auto EC = Writer.writeCString(S))
return EC;
MaxOffset = std::max<uint32_t>(MaxOffset, Offset + S.size() + 1);
assert(Writer.getOffset() <= End);
}
Writer.setOffset(MaxOffset);
assert(Writer.bytesRemaining() == 0);
Writer.setOffset(End);
return Error::success();
}