OSDN Git Service

[pdb] Use MappedBlockStream to parse the PDB directory.
authorZachary Turner <zturner@google.com>
Tue, 7 Jun 2016 05:28:55 +0000 (05:28 +0000)
committerZachary Turner <zturner@google.com>
Tue, 7 Jun 2016 05:28:55 +0000 (05:28 +0000)
commit6e00ec14d5bec16b850a3e01bbaef8fa1de457ac
tree3be57075f1bb15e6f3aec377f9a2eeb38b7c389b
parent47f90f5156b438c3272047abc671a1090f37b6c1
[pdb] Use MappedBlockStream to parse the PDB directory.

In order to efficiently write PDBs, we need to be able to make a
StreamWriter class similar to a StreamReader, which can transparently deal
with writing to discontiguous streams, and we need to use this for all
writing, similar to how we use StreamReader for all reading.

Most discontiguous streams are the typical numbered streams that appear in
a PDB file and are described by the directory, but the exception to this,
that until now has been parsed by hand, is the directory itself.
MappedBlockStream works by querying the directory to find out which blocks
a stream occupies and various other things, so naturally the same logic
could not possibly work to describe the blocks that the directory itself
resided on.

To solve this, I've introduced an abstraction IPDBStreamData, which allows
the client to query for the list of blocks occupied by the stream, as well
as the stream length. I provide two implementations of this: one which
queries the directory (for indexed streams), and one which queries the
super block (for the directory stream).

This has the side benefit of vastly simplifying the code to parse the
directory. Whereas before a mini state machine was rolled by hand, now we
simply use FixedStreamArray to read out the stream sizes, then build a
vector of FixedStreamArrays for the stream map, all in just a few lines of
code.

Reviewed By: ruiu
Differential Revision: http://reviews.llvm.org/D21046

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271982 91177308-0d34-0410-b5e6-96231b3b80d8
23 files changed:
include/llvm/DebugInfo/CodeView/StreamArray.h
include/llvm/DebugInfo/CodeView/StreamReader.h
include/llvm/DebugInfo/PDB/Raw/IPDBFile.h
include/llvm/DebugInfo/PDB/Raw/IPDBStreamData.h [new file with mode: 0644]
include/llvm/DebugInfo/PDB/Raw/IndexedStreamData.h [new file with mode: 0644]
include/llvm/DebugInfo/PDB/Raw/InfoStream.h
include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h
include/llvm/DebugInfo/PDB/Raw/ModStream.h
include/llvm/DebugInfo/PDB/Raw/PDBFile.h
include/llvm/DebugInfo/PDB/Raw/SymbolStream.h
include/llvm/DebugInfo/PDB/Raw/TpiStream.h
lib/DebugInfo/PDB/CMakeLists.txt
lib/DebugInfo/PDB/Raw/DbiStream.cpp
lib/DebugInfo/PDB/Raw/IndexedStreamData.cpp [new file with mode: 0644]
lib/DebugInfo/PDB/Raw/InfoStream.cpp
lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp
lib/DebugInfo/PDB/Raw/ModStream.cpp
lib/DebugInfo/PDB/Raw/PDBFile.cpp
lib/DebugInfo/PDB/Raw/PublicsStream.cpp
lib/DebugInfo/PDB/Raw/SymbolStream.cpp
lib/DebugInfo/PDB/Raw/TpiStream.cpp
lib/DebugInfo/PDB/Raw/TpiStream.cpp.rej [new file with mode: 0644]
tools/llvm-pdbdump/LLVMOutputStyle.cpp