[llvm-pdbutil] Dump raw bytes of module symbols and debug chunks.

llvm-svn: 306179
diff --git a/llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp b/llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp
index 4186f2e..83c5657 100644
--- a/llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp
@@ -47,15 +47,19 @@
 
   if (auto EC = Reader.readInteger(Signature))
     return EC;
-  if (auto EC = Reader.readArray(SymbolsSubstream, SymbolSize - 4))
+  if (auto EC = Reader.readSubstream(SymbolsSubstream, SymbolSize - 4))
+    return EC;
+  if (auto EC = Reader.readSubstream(C11LinesSubstream, C11Size))
+    return EC;
+  if (auto EC = Reader.readSubstream(C13LinesSubstream, C13Size))
     return EC;
 
-  if (auto EC = Reader.readStreamRef(C11LinesSubstream, C11Size))
-    return EC;
-  if (auto EC = Reader.readStreamRef(C13LinesSubstream, C13Size))
+  BinaryStreamReader SymbolReader(SymbolsSubstream.StreamData);
+  if (auto EC =
+          SymbolReader.readArray(SymbolArray, SymbolReader.bytesRemaining()))
     return EC;
 
-  BinaryStreamReader SubsectionsReader(C13LinesSubstream);
+  BinaryStreamReader SubsectionsReader(C13LinesSubstream.StreamData);
   if (auto EC = SubsectionsReader.readArray(Subsections,
                                             SubsectionsReader.bytesRemaining()))
     return EC;
@@ -63,7 +67,7 @@
   uint32_t GlobalRefsSize;
   if (auto EC = Reader.readInteger(GlobalRefsSize))
     return EC;
-  if (auto EC = Reader.readStreamRef(GlobalRefsSubstream, GlobalRefsSize))
+  if (auto EC = Reader.readSubstream(GlobalRefsSubstream, GlobalRefsSize))
     return EC;
   if (Reader.bytesRemaining() > 0)
     return make_error<RawError>(raw_error_code::corrupt_file,
@@ -72,9 +76,25 @@
   return Error::success();
 }
 
+BinarySubstreamRef ModuleDebugStreamRef::getSymbolsSubstream() const {
+  return SymbolsSubstream;
+}
+
+BinarySubstreamRef ModuleDebugStreamRef::getC11LinesSubstream() const {
+  return C11LinesSubstream;
+}
+
+BinarySubstreamRef ModuleDebugStreamRef::getC13LinesSubstream() const {
+  return C13LinesSubstream;
+}
+
+BinarySubstreamRef ModuleDebugStreamRef::getGlobalRefsSubstream() const {
+  return GlobalRefsSubstream;
+}
+
 iterator_range<codeview::CVSymbolArray::Iterator>
 ModuleDebugStreamRef::symbols(bool *HadError) const {
-  return make_range(SymbolsSubstream.begin(HadError), SymbolsSubstream.end());
+  return make_range(SymbolArray.begin(HadError), SymbolArray.end());
 }
 
 llvm::iterator_range<ModuleDebugStreamRef::DebugSubsectionIterator>
@@ -83,7 +103,7 @@
 }
 
 bool ModuleDebugStreamRef::hasDebugSubsections() const {
-  return C13LinesSubstream.getLength() > 0;
+  return !C13LinesSubstream.empty();
 }
 
 Error ModuleDebugStreamRef::commit() { return Error::success(); }