pdb icon indicating copy to clipboard operation
pdb copied to clipboard

Add support for reading public symbol stream

Open luser opened this issue 5 years ago • 0 comments

The public symbol stream contains both a sorted list of all public symbols (which can be used to quickly locate a symbol given a section index and address by binary searching) as well as a hash table for looking up symbols by mangled names. These both seem like extremely useful operations and it would be great to support them. The index of this stream is in DBIHeader::ps_symbols_stream.

The Microsoft C++ code for this stream (+ the global symbol stream) is a nightmare: https://github.com/microsoft/microsoft-pdb/blob/082c5290e5aff028ae84e43affa8be717aa7af73/PDB/dbi/gsi.h https://github.com/microsoft/microsoft-pdb/blob/082c5290e5aff028ae84e43affa8be717aa7af73/PDB/dbi/gsi.cpp

The implementation of PSGSI1::NearestSym is interesting. That's what implements the binary search to look up a symbol by section index and address.

But LLVM has an implementation that's a lot more readable: https://github.com/llvm-mirror/llvm/blob/a27c90973c8a1d338f36b8148b687ab078de48aa/include/llvm/DebugInfo/PDB/Native/RawTypes.h https://github.com/llvm-mirror/llvm/blob/6b547686c5410b7528212e898fe30fc7ee7a70a3/include/llvm/DebugInfo/PDB/Native/PublicsStream.h https://github.com/llvm-mirror/llvm/blob/6b547686c5410b7528212e898fe30fc7ee7a70a3/lib/DebugInfo/PDB/Native/PublicsStream.cpp https://github.com/llvm-mirror/llvm/blob/6b547686c5410b7528212e898fe30fc7ee7a70a3/include/llvm/DebugInfo/PDB/Native/GlobalsStream.h https://github.com/llvm-mirror/llvm/blob/6b547686c5410b7528212e898fe30fc7ee7a70a3/lib/DebugInfo/PDB/Native/GlobalsStream.cpp

luser avatar Mar 18 '20 17:03 luser