getsentry / pdb

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

Add an explicit type for stream indices #42

Closed jan-auer closed 5 years ago

jan-auer commented 5 years ago

While the MSF stores the stream count as u32, it seems to be a general pattern in PDBs to store u16 stream indices and indicate the absence of a stream with 0xffff. To abstract this behavior, this PR introduces a transparent StreamIndex type.

All code is refactored to use this new type now. As a nice side effect, the access to DBI extra streams is now much smoother. Also, this forces us to check for the absence of streams more consistently when using stream indices internally (e.g. as it was missed for module info streams initially).

The only exception to this seems to be the named stream table, which contains u32 stream indices. I've decided to make a lossy conversion to a StreamIndex, since this is in the public interface. In general, the StreamNames type might need a refactor, but that's for a different PR.