Refactor the PDB Stream reading interface.
authorZachary Turner <zturner@google.com>
Fri, 29 Apr 2016 17:22:58 +0000 (17:22 +0000)
committerZachary Turner <zturner@google.com>
Fri, 29 Apr 2016 17:22:58 +0000 (17:22 +0000)
commit6ba65deeb9b017e4144cdae341dcb9e3564c7c7b
tree7b038a1cbb48d78056d0af5bd76f9a3ad44ea9d6
parenteaaec4a4c85a81ee9169e1647b733d839159c648
Refactor the PDB Stream reading interface.

The motivation for this change is that PDB has the notion of
streams and substreams.  Substreams often consist of variable
length structures that are convenient to be able to treat as
guaranteed, contiguous byte arrays, whereas the streams they
are contained in are not necessarily so, as a single stream
could be spread across many discontiguous blocks.

So, when processing data from a substream, we want to be able
to assume that we have a contiguous byte array so that we can
cast pointers to variable length arrays and such.

This leads to the question of how to be able to read the same
data structure from either a stream or a substream using the
same interface, which is where this patch comes in.

We separate out the stream's read state from the underlying
representation, and introduce a `StreamReader` class.  Then
we change the name of `PDBStream` to `MappedBlockStream`, and
introduce a second kind of stream called a `ByteStream` which is
simply a sequence of contiguous bytes.  Finally, we update all
of the std::vectors in `PDBDbiStream` to use `ByteStream` instead
as a proof of concept.

llvm-svn: 268071
16 files changed:
llvm/include/llvm/DebugInfo/PDB/Raw/ByteStream.h [new file with mode: 0644]
llvm/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h [new file with mode: 0644]
llvm/include/llvm/DebugInfo/PDB/Raw/PDBDbiStream.h
llvm/include/llvm/DebugInfo/PDB/Raw/PDBInfoStream.h
llvm/include/llvm/DebugInfo/PDB/Raw/PDBNameMap.h
llvm/include/llvm/DebugInfo/PDB/Raw/PDBStream.h [deleted file]
llvm/include/llvm/DebugInfo/PDB/Raw/StreamInterface.h [new file with mode: 0644]
llvm/include/llvm/DebugInfo/PDB/Raw/StreamReader.h [new file with mode: 0644]
llvm/lib/DebugInfo/PDB/CMakeLists.txt
llvm/lib/DebugInfo/PDB/Raw/ByteStream.cpp [new file with mode: 0644]
llvm/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp [moved from llvm/lib/DebugInfo/PDB/Raw/PDBStream.cpp with 54% similarity]
llvm/lib/DebugInfo/PDB/Raw/PDBDbiStream.cpp
llvm/lib/DebugInfo/PDB/Raw/PDBInfoStream.cpp
llvm/lib/DebugInfo/PDB/Raw/PDBNameMap.cpp
llvm/lib/DebugInfo/PDB/Raw/StreamReader.cpp [new file with mode: 0644]
llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp