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

Implement and expose line information #39

Closed jan-auer closed 5 years ago

jan-auer commented 5 years ago

This PR implements proper handling for C13 line and file information. Disclaimer: This will need some more testing with PDBs from different sources.

To give due credit, this PR is loosely based on initial work by @jrmuizel.

Backgrounds

Alright, so we've known for a while that module info streams ("modi") can store either C11 or C13 line information. LLVM claims they have only ever encountered C13 -- although that doesn't mean much since they are also not handling OMAPs so far. I did some digging and found that:

The implementation in this PR tries to cover C13 only, but prepares for the introduction of C11 code, if necessary -- or even a potential successor if that is ever the case.

C13 data in the module info stream consists of a variable number of sub streams of various kinds. Some of those only occur once, while others exist multiple times. To expose line information, only two of those needed to be read, but here's a slightly more complete picture:

Implementation

Caveats

Line and column numbers seem to sometimes contain special values. I yet have to find out what they mean. Specifically, I have observed:

Fixes #19

jan-auer commented 5 years ago

This PR now includes a breaking change: PDB::module_info returns an Option, which is None if the module stream points to 0xffffffff. This is generally treated as a marker for missing streams in PDBs.

I was thinking about introducing a wrapper type StreamNumber that encapsulates this, but this would require more refactoring which exceeds the scope of this PR.

willglynn commented 5 years ago

Thanks!

jan-auer commented 5 years ago

@willglynn Just don't release this right away please :) I'm planning of adding more features quite soon and they might have more breaking changes. Might make sense to batch them up for the next release.

willglynn commented 5 years ago

I figured about as much :-)