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

How to get a symbol size? #27

Open RazrFalcon opened 5 years ago

mstange commented 5 years ago

I think the following should get you fairly close:

  1. Wait for PR #26 to land
  2. Iterate over all the modules
  3. Iterate over the symbols of each module
  4. The ProcedureSymbols in each module have a len field. That's your symbol size.
RazrFalcon commented 5 years ago

I've tried the pdb_symbols example, but I've got:

error dumping PDB: The requested stream (65535) is not stored in this file

The PDB file is from building the cargo-bloat with the MSVC target.

RazrFalcon commented 5 years ago

Also, I'm not familiar with the pdb, but what is the difference between global_symbols and symbols from debug_information? AFAIU, they can have the same symbols/functions, but global_symbols doesn't contain size.

In my case, I have to collect a list of functions (name + size) that are used in the executable.

crlf0710 commented 5 years ago

Let me call a Windows expert for help here.

@retep998 Could you make some advises about above questions? Thank you!

retep998 commented 5 years ago

I don't know anything about the PDB format, sorry.

mstange commented 5 years ago

Also, I'm not familiar with the pdb, but what is the difference between global_symbols and symbols from debug_information? AFAIU, they can have the same symbols/functions, but global_symbols doesn't contain size.

I think global_symbols only lists the symbols that are exposed to the linker. And the symbols in debug_information describe all functions present in the binary, even those that are internal and not callable from the outside.

jan-auer commented 5 years ago

global_symbols in this crate does not expose information from the "Global Symbol Stream", but instead from a "Symbol Records Stream". I wasn't able to fully understand what the exact differences are, but it looks like the latter contains a combination of the "Global Symbol Stream" and the "Public Symbol Stream", plus more additional information.

jan-auer commented 4 years ago

@RazrFalcon is this still an issue?

RazrFalcon commented 4 years ago

I should retest it.