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

Notes... #1

Open
fitzgen opened this issue Dec 13, 2016 · 5 comments
Open

Notes... #1

fitzgen opened this issue Dec 13, 2016 · 5 comments

Comments

@fitzgen
Copy link
Member

fitzgen commented Dec 13, 2016

Useful info:

Looks like we want the contents of the .gnu_debuglink section, and we probably want to validate the CRC too. It seems like maybe we can call out to the find-debuginfo.sh script?

For MacOS, there doesn't seem to be a section linking to the proper .dSYM bundle. It seems like dsymutil generates these bundles. Perhaps we will just have to rely on the .dSYM bundle being where we expect it to be?

@fitzgen
Copy link
Member Author

fitzgen commented Dec 13, 2016

http://lldb.llvm.org/symbols.html mentions a DebugSymbols.framework we might be able to use on MacOS.

@kamalmarhubi
Copy link

👍 thanks for this!

@luser
Copy link
Collaborator

luser commented Jan 12, 2017

Breakpad has some code for handling this sort of thing that might be useful. On Linux if you run dump_syms on a binary that has been stripped but contains a .gnu_debuglink we hit these code paths:
https://chromium.googlesource.com/breakpad/breakpad/+/master/src/common/linux/dump_symbols.cc#802
https://chromium.googlesource.com/breakpad/breakpad/+/master/src/common/linux/dump_symbols.cc#958

They require passing the debug directories to search on the dump_syms commandline, though. I don't know that there's a standard way to locate that.

Nowadays all binaries have a build id in the ELF headers, which you can also use for lookup, which might be the simpler path. You can take a build id abcdefg and look for the symbol file at /usr/lib/debug/.build-id/ab/cdefg.debug.

Breakpad has code for reading build ids from ELF headers, but not for locating debug symbols based on them:
https://dxr.mozilla.org/mozilla-central/source/toolkit/crashreporter/google-breakpad/src/common/linux/file_id.cc#64

For finding debug symbols that aren't installed...there's not a really good story here. Fedora has a thing called Darkserver that will let you find RPMs by build id, but there's no equivalent that I know of for Ubuntu.

On Mac, there's some code for locating the actual file inside of a dSYM bundle:
https://chromium.googlesource.com/breakpad/breakpad/+/master/src/common/mac/dump_syms.cc#131

...but you have to pass the paths to the binary and the dSYM on the dump_syms commandline, it won't locate the dSYM for you:
https://chromium.googlesource.com/breakpad/breakpad/+/master/src/tools/mac/dump_syms/dump_syms_tool.cc#113

LLDB has support for locating dSYM bundles by way of DebugSymbols.framework:
http://lldb.llvm.org/symbols.html

That's a private framework and I can't find any documentation on it, but it's a thing that exists. It even has support for "run a script to fetch symbols on-demand", which is neat. (I keep meaning to make that work with Mozilla's symbol server.)

I've seen references to using Spotlight for locating dSYMs, specifically the command mdfind "com_apple_xcode_dsym_uuids == <UUID>". It looks like Spotlight will index dSYMs by UUID for quick lookup. There seem to be APIs for doing these queries as well, which would be nicer than shelling out:
https://developer.apple.com/library/content/documentation/Carbon/Conceptual/SpotlightQuery/Concepts/Introduction.html#//apple_ref/doc/uid/TP40001843-BBCFBCAG
https://developer.apple.com/reference/coreservices/1658109-mdquery

@fitzgen
Copy link
Member Author

fitzgen commented Jan 20, 2017

@luser just realized I never thanked you for this knowledge dump -- thank you very much!

@luser
Copy link
Collaborator

luser commented Dec 15, 2017

I wrote a little tool using addr2line and wound up needing something like this, so I've got an implementation of most of the stuff to use the Spotlight APIs to find dSYM files. It needs a little cleanup, but I'll submit it as a PR soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants