From deb391309c9861dcdc995b2c70c2d64189611c3b Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Fri, 9 Jun 2017 00:28:08 +0000 Subject: [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 --- llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp') diff --git a/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp b/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp index 7b972a1a2770..6e647c4b976b 100644 --- a/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp +++ b/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp @@ -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 @@ -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(MaxOffset, Offset + S.size() + 1); + assert(Writer.getOffset() <= End); } - Writer.setOffset(MaxOffset); - assert(Writer.bytesRemaining() == 0); + Writer.setOffset(End); return Error::success(); } -- cgit v1.2.3