-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
extra-debug-info does not appear to work on OSX with lldb #11352
Comments
This is a known issue with the Servo team, fwiw. |
Does clang give you usable debug symbols? |
I do indeed get nice debugging with clang:
|
Could you dump the IR from clang and rustc for similar programs? |
I'd also be interested in seeing if clang produces dSYM bundles and whether there are any observable differences between them and the ones that rustc produces. Relevant literature at http://lldb.llvm.org/symbols.html . |
This has the two IR outputs: https://gist.github.com/alexcrichton/8288727 |
Clang:
rustc:
That's some strong difference there. |
I spent a while tracking this down due to a red herring, but the actual issue is simple: the DWARF version is too high. As of OS X 10.9, 'dwarfdump' and 'dsymutil', the latter of which is required to aggregate DWARF info from .o files into the final executable, appear to ignore DWARF information with version > 3. Rust uses LLVM's default of DWARF 4. clang defaults to DWARF 2 on OS X; in fact, the version of clang distributed with Xcode (but not the version I have installed through MacPorts? too tired to investigate this properly) seems to ignore -gdwarf-3 and above, so probably better to go with 2 than 3. Workaround: I believe the correct way to solve this is for rustc to set the LLVM module flag "Dwarf Version", as clang does. It should also set "Debug Info Version", which, as far as I can tell, causes a separate issue where anything reading bitcode files using a new version of LLVM (e.g. the versions of llvm-dis or llc compiled by rust) will magically discard all the debug metadata. |
@comex, you are my new favorite person in the world, thank you for figuring this out!!! I would be more than ok accepting a patch to pass these arguments by default! Pull requests are always welcome :) |
Ship it, shipt it! 🌵 |
This is a great find indeed! For anyone interested, here is another source of information on DWARF on Mac OS X: The DWARF standard says that namespaces are not supported yet in version 2. I'd be interested in what the consequences of this are. Other than that I don't think we use anything that needs a newer version than 2. I'd be happy to turn this information into a fix and a pull request but I don't have a Mac to test it (yet). |
cc me |
OSX apparently doesn't have tooling which understands higher versions of dwarf by default right now. Closes rust-lang#11352
Set "Dwarf Version" to 2 on OS X to avoid toolchain incompatibility, and set "Debug Info Version" to prevent debug info from being stripped from bitcode. Fixes #11352.
Here's a recent session of mine
Even if I continue into my own
main
function (actually the symbolmain::largehashher
), I'm not getting any source level debugging.Is there an extra option that I should be passing or should this be "just working"?
I compiled a C executable with
gcc -g
and I got nice debug-info without doing anything extra in lldb.cc @michaelwoerister
The text was updated successfully, but these errors were encountered: