getsentry / pdb

A parser for Microsoft PDB (Program Database) debugging information
https://docs.rs/pdb/
Apache License 2.0
385 stars 69 forks source link

Implement support for IPI types #51

Closed jan-auer closed 5 years ago

jan-auer commented 5 years ago

This PR exposes the ID stream (IPI).

The TPI and IPI streams share the same structure, but they contain different records. Most importantly, the type of index used indicates whether a type lives in the IPI or the TPI. In microsoft-pdb this is either CV_typ_t for types, or CV_ItemId for ids. Of course, both are u32.

To create a clear interface that avoids confusion, identifiers are clearly separated into TypeIndex(u32) and IdIndex(u32). Since now the id stream needs the same root struct, iterator and finder, this is abstracted into ItemInformation<I>, ItemIter<I> and ItemFinder<I>, where I is the index being used. On top of that, there are type definitions to simplify the handling of such types: type Type<'t> = Item<'t, TypeIndex>, etc.

Apart from some renaming for consistency, usage stays mostly the same.

Unrelated, this PR contains two more fixes. They can be moved into separate PRs if desired:

jan-auer commented 5 years ago

@willglynn Before I finish this up, wondering if you have reservations against the general approach of splitting the streams up into an explicit TPI and IPI stream rather than merging them magically internally.

Unforunately, it's not possible to know which stream to use by just looking at the numbers. That means, that it would be necessary to look in both streams and then prefer one result over the other. However, at the declaration side, it is always clear which stream the index refers to, hence the differentiation.

jan-auer commented 5 years ago

@willglynn All feedback should be addressed now. I hope that the type defs don't make it odd to use TypeIndex now.