Closed nico-abram closed 1 year ago
By "unmangled" you mean "not mangled" I presume? In PDB the situation is a bit odd as inline and non inline symbols are quite different. You can look at what symbolic does. For inlines we're resolving this around here: https://github.com/getsentry/symbolic/blob/c03080a1d75bf66bcbee6b2a9c9df84266d7a581/symbolic-debuginfo/src/pdb.rs#L1052-L1057
For actually mangled names, we demangle on the fly later as these are known to massively blow up in size: https://github.com/getsentry/symbolic/blob/50a4d2eff93a4b529bd5120c47924dcbc8a4275c/symbolic-demangle/src/lib.rs#L163-L178 (uses msvc_demangler
).
To demangle "decorated" global symbols, use msvc_demangler
.
To emit function arguments for procedures, use pdb_addr2line::TypeFormatter::format_function
.
To emit namespaces and function arguments for inlines, use pdb_addr2line::TypeFormatter::format_id
.
To get function names for code addresses, use pdb_addr2line::Context::find_frames
.
Yes, I meant "not mangled". I presume msvc_demangler
is only useful if working with C/C++ symbols generated by msvc (Or a compatible compiler like clang-cl)? I was working with a rustc-generated PDB when I opened this, in which case I don't think the symbols in question use that mangling scheme.
My problem was I did not know if a given PDB was using the V0 or legacy rust mangling schemes, so I couldn't really reliably demangle. I was hoping the PDB itself contained the undecorated/not-mangled names, but that doesn't seem to be the case. So I just assumed the V0 rust mangling scheme and demangled them, which should work fine the vast majority of the time.
Closing this, thanks for the help.
Hi
I'm trying to get all the functions in a pdb file, their lengths, and their unmangled names (I believe the term used in pdbs might be "unique names") for the cargo-bloat tool.
This crate's ProcedureSymbol type does not have unmangled names. From what I've seen reading the LLVM docs on PDB files and using the
llvm-pdbutil
, they're not actually included in symbol records. Is there a recommended/reliable way of getting unmangled names? Right now what I'm doing is first collecting all PublicSymbols and then trying to find a matching public symbol. But, at least for rustc/cargo generated PDBs, this seems to miss a lot of functions that have ProcedureSymbol records and do not have a matching PublicSymbol record.Is this approach fine, and I should try to find a way/file an issue with rust to try to get it to generate better PDBs, or is there some other way I can already use this crate to get these unmangled names, or is there something that can be added to this crate?
The code I'm using follows