[PATCH] D55344: Support skewed Stream Arrays

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 5 15:45:46 PST 2018


zturner created this revision.
zturner added reviewers: rnk, aganea, amccarth.
Herald added subscribers: arphaman, hiraditya.

`VarStreamArray` was built on the assumption that it is backed by a `StreamRef`, and offset 0 of that `StreamRef` is the first byte of the first record in the array.

This is a logical and intuitive assumption, but unfortunately we have use cases where it doesn't hold.  Specifically, a PDB module's symbol stream is prefixed by 4 bytes containing a magic value, and the first byte of record data in the array is actually at offset 4 of this byte sequence.

Previously, we would just truncate the first 4 bytes and then construct the `VarStreamArray` with the resulting `StreamRef`, so that offset 0 of the underlying stream did correspond to the first byte of the first record, but this is problematic, because symbol records reference other symbol records **by the absolute offset including that initial magic 4 bytes**.  So if another record wants to refer to the first record in the array, it would say "the record at offset 4".

This led to extremely confusing hacks and semantics in loading code, and after spending 30 minutes trying to get some math right and failing, I decided to fix this in the underlying implementation of `VarStreamArray`.  Now, we can say that a stream is skewed by a particular amount.  This way, when we access a record by absolute offset, we can use the same values that the records themselves contain, instead of having to do fixups.


https://reviews.llvm.org/D55344

Files:
  lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp
  llvm/include/llvm/Support/BinaryStreamArray.h
  llvm/include/llvm/Support/BinaryStreamReader.h
  llvm/lib/DebugInfo/CodeView/CVSymbolVisitor.cpp
  llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp
  llvm/test/DebugInfo/PDB/module-bytes.test

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55344.176888.patch
Type: text/x-patch
Size: 15066 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181205/4df1c737/attachment-0001.bin>


More information about the llvm-commits mailing list