This is an archive of the discontinued LLVM Phabricator instance.

Parse and dump PDB TPI Stream
ClosedPublic

Authored by zturner on May 2 2016, 4:08 PM.

Details

Summary

This parses the TPI stream (stream 2) from the PDB file. This stream contains some header information followed by a series of codeview records. There is some additional complexity here in that alongside this stream of codeview records is a serialized hash table in order to efficiently query the types. We parse the necessary bookkeeping information to allow us to reconstruct the hash table, but we do not actually construct it yet as there is some additional complexity that needs to be understood before that is possible.

Diff Detail

Event Timeline

zturner updated this revision to Diff 55908.May 2 2016, 4:08 PM
zturner retitled this revision from to Parse and dump PDB TPI Stream.
zturner updated this object.
zturner added reviewers: ruiu, rnk, majnemer.
zturner added a subscriber: llvm-commits.
ruiu added inline comments.May 2 2016, 4:16 PM
include/llvm/DebugInfo/PDB/Raw/TpiStream.h
23

Why do you need __fastcall here?

lib/DebugInfo/PDB/Raw/ByteStream.cpp
66

I think you can use ArrayRef::slice.

zturner added inline comments.May 2 2016, 4:22 PM
include/llvm/DebugInfo/PDB/Raw/TpiStream.h
23

This was the calling convention in the reference implementation, but you're right, as long as I control both ends it's not important.

zturner updated this revision to Diff 55912.May 2 2016, 4:32 PM

Fix suggestions from ruiu@

rnk accepted this revision.May 2 2016, 4:43 PM
rnk edited edge metadata.

lgtm

include/llvm/DebugInfo/PDB/Raw/TpiStream.h
2

Maybe this? "PDB Type Information (TPI) stream (stream 2) access"

I was wondering what the mystery "P" was.

23

Also, it won't compile on Linux. :)

25

Doc comments here, with the acronym expansion as well would be good.

lib/DebugInfo/PDB/Raw/TpiStream.cpp
26

This is llvm::codeview::TypeIndex::FirstNonSimpleIndex.

96

Check for failure here and on the getArrayRef, otherwise there's not much point to std::error_code

This revision is now accepted and ready to land.May 2 2016, 4:43 PM
zturner added inline comments.May 2 2016, 4:46 PM
lib/DebugInfo/PDB/Raw/TpiStream.cpp
96

The std::error_code is because in the generic case of a StreamReader for which you don't know what type of underlying stream backs it (for example a MappedBlockStream, you might get an error. In this case we know it's backed by a ByteStream (because that's the type of RecordsBuffer) which is guaranteed be contiguous and so getArrayRef should never return an error.

rnk added inline comments.May 2 2016, 4:50 PM
lib/DebugInfo/PDB/Raw/TpiStream.cpp
96

The getArrayRef could fail on an invalid type stream or if we get off track accidentally. Len - sizeof(Prefix.Leaf) could take us past the end of the stream.

zturner added inline comments.May 2 2016, 4:56 PM
lib/DebugInfo/PDB/Raw/TpiStream.cpp
96

Ahh fair point. We could have a corrupt PDB.

Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Committed in r268343.