getsentry / pdb

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

Fix UDT source reference parsing #96

Closed jan-auer closed 3 years ago

jan-auer commented 3 years ago

There is a difference between the type definitions of LF_UDT_SRC_LINE and LF_UDT_MOD_SRC_LINE that we missed in the initial implementation. To make it easier to consume the ID stream, we stick to a single UDT type, but create an enum for local and remote file name references.

This is the full definition of types from Microsoft's implementation. Note how the description differs from the actual type signature:

typedef struct lfUdtSrcLine {
    unsigned short leaf;        // LF_UDT_SRC_LINE
    CV_typ_t       type;        // UDT's type index
    CV_ItemId      src;         // index to LF_STRING_ID record where source file name is saved
    unsigned long  line;        // line number
} lfUdtSrcLine;

typedef struct lfUdtModSrcLine {
    unsigned short leaf;        // LF_UDT_MOD_SRC_LINE
    CV_typ_t       type;        // UDT's type index
    CV_ItemId      src;         // index into string table where source file name is saved
    unsigned long  line;        // line number
    unsigned short imod;        // module that contributes this UDT definition
} lfUdtModSrcLine;

Fixes https://github.com/willglynn/pdb/issues/95

jan-auer commented 3 years ago

Note that this is a breaking change and therefore will require a bump in the 0.x minor version.