drsyms: allow users to enumerate private symbols and control the demangling on Windows
From rnk@google.com on October 20, 2011 15:18:10
In my work to add control over symbol mangling, we ran into a limitation where our mangling flags are not honored unless we only enumerate public symbols.
Furthermore, we are not able to honor the user's mangling flags if we enumerate private symbols, because the PDB only contains the "name-only" version of the private symbol, which doesn't include the parameter types. This is probably an issue that we cannot abstract away from the user, and will have to expose in the form of a flag or alternative Windows-only enumeration function.
From https://code.google.com/p/dynamorio/issues/detail?id=545#c4 :
""" B) Another issue is that SYMOPT_UNDNAME requires SYMOPT_PUBLIC_ONLY to be set. [2] The reason is that only "public" symbols are stored in mangled form. "Private" symbols, which are things like static functions and I believe anonymous namespace functions, do not need to have a mangled name present, so only the demangled name is stored in the PDB, because that's what they figure a debugger will want it. This means that for non-public symbols we can't produce either the mangled name or the "full" demangled name (meaning with parameter types).
[2] http://msdn.microsoft.com/en-us/library/windows/desktop/ms680551(v=vs.85).aspx My plan is to document A and file an issue.
For B, I can do a few things:
- Expose the notion of searching public or private symbols and document that for private symbols you can only get "short" demangled names with template params.
- Always set SYMOPT_PUBLIC_ONLY for lookup, enumeration, and search. Even with statically linked libc, malloc and friends will be public, so we'll find them. For address lookup, we can turn this back off to get nice callstacks through private functions.
- For symbol enumeration, enumerate public symbols with whatever mangling options the user requested, and then enumerate only non-public symbols with the default mangling. This way the user sees all the symbols, but the mangling settings they requested are not honored.
- For symbol lookup, if public symbol lookup fails, we can try again on private symbols.
I think implementing the second suggestion for B is the least confusing and easiest to document. We can file an issue on adding functionality to search private symbols. """
Original issue: http://code.google.com/p/dynamorio/issues/detail?id=588