Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove PDB code and use symbolic_debuginfo for all platforms #433

Merged
merged 28 commits into from Aug 2, 2022

Conversation

mstange
Copy link
Collaborator

@mstange mstange commented Jul 29, 2022

Fixes #406.
Fixes #280.

This PR adds inline support for Windows.
It also removes 1500 lines of code at the same time.

I've ported the following features from the Windows code to the cross-platform code:

  • Some Windows path handling (used in the source file code)
  • Appending a dummy symbol based on the last known symbol
  • Adopting the FUNC name from the PUBLIC at the same address if the function name doesn't have parameter information
  • Decoding parameter size from "C decorated" symbol names, and assigning it to the function or public at that address
  • Generating synthetic functions from the PE object's exception info, if no PDB is available
  • Skipping public symbols for string and number constants
  • Already landed: setting the "multiple" flag if multiple publics or functions have the same address (PR Make is_multiple work properly in elf.rs. #416)

I've also upstreamed the following changes to symbolic:

I deleted the following code without replacement:

  • Computing FUNC parameter size for 32 bit Windows based on argument type information. Now FUNC entries on 32 bit Windows will only have a non-zero parameter size if they can get it from the "C decorated" name of a public symbol at that same address. Otherwise the parameter size will be zero, and stack walking needs to obtain it from the STACK WIN entries. rust-minidump already prefers the size from the STACK WIN entries anyway, because the FUNC parameter size was found to be incorrect in some cases, see FUNC and WIN STACK entries disagree on parameter size #284. Furthermore, all 32 bit dll / exe files which I tested already generated STACK WIN entries for all of their PDB's FUNC addresses.
  • Getting "has code" information from section contributions. This was used to include more public symbols, but it didn't seem necessary. The symbolic PDB code doesn't look at section contributions at all, only at the section headers themselves. Checking the section header's "characteristics" seems to work fine and includes all symbols we care about.
  • Detecting split functions based on Block symbols with disjoint address ranges.
  • Splitting line information based on any encountered disjoint address ranges.
  • Splitting line information based on the PDB's address map. For these last three, I haven't found a PDB for which this was necessary.

I've done a lot of comparisons of before/after .sym files.

The remaining differences I've found all fall in the following categories:

  • Extra leading underscores. I think in the past we were sometimes stripping leading underscores twice, mostly by accident.
  • Different (better) demangling, thanks to fix(demangle): tweak MSVC demangling flags getsentry/symbolic#640
  • Some functions use different names because of a different arbitrary choice between multiple functions at the same address.
  • Fewer FILE records, because the cross-platform code omits unused FILE records.
  • Different file IDs in line records, as a result of the different FILE records.
  • Sometimes fewer line records because duplicate consecutive lines have been merged into one.
  • ntdll has more PUBLIC symbols now. I'm not quite sure why but I appreciate it.

This parsese the PE header twice, but that's ok.
This eliminates the custom PDB parsing and relies on symbolic's PDB
parsing instead.
 - Pass on a symbol name to an argument-less function name.
 - Detect the parameter size from the @8 at the end of the symbol name.
Even if the symbol name is not MSVC-mangled, it's often a better choice
for the function name. In the example I was looking at, the function
name started with an underscore, and taking the name from the symbol
stripped that underscore, which looked better.
We don't strip underscores from function names normally, because
function names are already expected to be clean.
They're not Linux-specific.
Remove lots of template parameters and traits because everything now has the same type.
Make multi-file path use auto detection on the file type just like in the single-file path.
Otherwise we lose the size of the placeholder function,
because publics don't have a size.
This is no longer needed because all file types now end up
as ObjectInfo which can be merged with each other.
@mstange mstange self-assigned this Jul 29, 2022
Copy link
Collaborator

@gabrielesvelto gabrielesvelto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for this excellent work 👏

@@ -42,7 +41,7 @@ serde = "1.0"
serde_json = "1.0"
sha2 = "0.10"
simplelog = { version = "0.12", optional = true, features = ["local-offset"] }
symbolic = { version = "9", features = ["demangle", "cfi"] }
symbolic = { git = "https://github.com/getsentry/symbolic", rev = "f0dc99bb400da20fed8a7a42d71d8206ffeee536", features = ["demangle", "cfi"] }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine but let's file a bug to turn this into a version when the fix gets a proper release

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed #438.

@mstange mstange merged commit 325cf2c into mozilla:main Aug 2, 2022
mstange added a commit to mstange/dump_syms that referenced this pull request Sep 14, 2022
This restores the error handling from elf.rs from before
mozilla#433 . That PR changed it to
an unwrap because the PDB code was using unwrap.

old elf.rs: https://github.com/mozilla/dump_syms/blob/de7cc440533b794f85ca4e1f10e26d918330140d/src/linux/elf.rs#L464-L466
old pdb.rs: https://github.com/mozilla/dump_syms/blob/de7cc440533b794f85ca4e1f10e26d918330140d/src/windows/pdb.rs#L254

We encounter this error for libmozavutil.so on certain Linux debug builds,
see https://bugzilla.mozilla.org/show_bug.cgi?id=1783899#c6 .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants