1

I'm trying to improve SymbolSort library, which reads PDB files with DIA SDK. I need to match the symbols read from object files with the symbols read from PDB.

The question is: given an IDiaSymbol variable, how can I obtain its real name? I'm not interesting in the undecorated or human-readable name, I need the mangled name, exactly as it appears in the object file, exactly as linker sees it.


The undecorated name can be easily obtained via IDiaSymbol::get_undecoratedName (ref). For decorated name, I use the following code:

    string rawName;
    IDiaSymbolUndecoratedNameExFlags flags = Flags.UNDNAME_32_BIT_DECODE | Flags.UNDNAME_TYPE_ONLY;
    diaSymbol.get_undecoratedNameEx((uint)flags, out rawName);

It was found empirically that this hack seems to work well in most cases (for no reason). But sometimes it gives some trash as result, e.g.:

diaSymbol.undecoratedName:
    "private: bool __cdecl idPhysics_Player::SlideMove(bool,bool,bool,bool) __ptr64"
rawSymbol:
    " ?? :: ?? ::Z::_N_N000 & __ptr64 volatile "
stgatilov
  • 5,333
  • 31
  • 54

1 Answers1

2

I was reading only private symbols from the PDB. The private symbols in general do not provide raw symbol name (in some cases they don't even have one).

The problem is solved by reading public symbols instead (using SymTagEnum.SymTagPublicSymbol). For them, diaSymbol.name always gives the raw name of the symbol.

All this is well documented in public and private symbols article.

stgatilov
  • 5,333
  • 31
  • 54