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

Not all symbol records have names #14

Closed philipc closed 5 years ago

philipc commented 7 years ago

I'm looking at adding support for parsing more symbol records.

Currently, Symbol assumes that every symbol has a name, which is returned by Symbol::name. The name isn't stored in the symbol variants. Instead, it is found at a fixed offset given by Symbol::data_length().

This is fine for most symbols. However, some symbols consist of multiple records, and the additional records don't always have a name, such as the S_DEFRANGE records for local symbols, or S_BLOCK and S_END within local procedures.

The simplest fix is to change Symbol::name to return an Option. This still relies on the name being at a fixed offset in records, but so far that seems to be a valid assumption. However, I was wondering if it would be better to add the name to the Symbol variants, in the same manner as TypeData. This avoids callers needing to unwrap the Option for records that always have a name.

rlabrecque commented 5 years ago

I believe I'm running into this with S_BUILDINFO as well

https://github.com/llvm-mirror/llvm/blob/6b547686c5410b7528212e898fe30fc7ee7a70a3/include/llvm/DebugInfo/CodeView/SymbolRecord.h#L869

jan-auer commented 5 years ago

FYI: This is being fixed as part of #47