[PATCH] D21046: Use MappedBlockStream for parsing the directory

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 6 17:18:17 PDT 2016


zturner created this revision.
zturner added reviewers: rnk, ruiu, majnemer.
zturner added a subscriber: llvm-commits.

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.

http://reviews.llvm.org/D21046

Files:
  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
  include/llvm/DebugInfo/PDB/Raw/IndexedStreamData.h
  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
  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
  tools/llvm-pdbdump/LLVMOutputStyle.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21046.59809.patch
Type: text/x-patch
Size: 31716 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160607/90301622/attachment-0001.bin>


More information about the llvm-commits mailing list