-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Line numbers in backtrace still do not appear on macOS for Cargo projects #4490
Comments
I think Cargo can definitely manage lifting this directory up a level, but currently nothing in Rust knows about it (neither Cargo nor rustc itself). This is the same way for a number of debug files on Windows where rustc/cargo only know about a subset of the artifacts, not everything together. I'm under the impression, though, that there's an API that's typically used on OSX to find this information and just doesn't work when spotlight is turned off (who knew?) and maybe that should be called? |
There is such an API (which lldb and gdb use) in the DebugSymbols framework but like CoreSymbolication it's a private API. If we're willing to lean on that I think it might be better to just use CoreSymbolication from start to finish (weakly linked or via dlsym). |
The risk of using private APIs are:
Unless there's a way to entirely strip off the CoreSymbolication/DebugSymbols part in release build (leaving only dladdr-based backtrace), I don't recommend using the private APIs. |
Ah that's a bummer :( But yeah I think we should avoid these sorts of APIs in libstd. Maybe a "hack" that's specific to Cargo then? |
We're so close to something that works 'out-of-the-box' for OSX... |
For intelliRust people reading this, you can add an external tool that's run before launch. Getting it to kick off cp works: cp (using the arg -n as well is faster but gives a non-zero error code second time around so you might want to put this in a script as intellirust won't continue otherwise.) |
I think we could do the lift-up @gilescope Symlink should be enough, no need to copy unless symlink fails. |
Just to note that I'm currently working on fixing this (uplift the dSYM). |
Uplift *.dSYM Fixed #4490. The solution is based on #4570. Simply adding `.dSYM` into `add_target_specific_suffixes` will cause cargo trying to actually run that `.dSYM` folder, so I've upgraded the `linkable` boolean into a 3-value enum `TargetFileType`, to tell `cargo run` and `cargo test` to avoid these debug symbol files. (I haven't checked if it can solve #4056, don't wanna mess with Spotlight 😝)
Is this supposed to work now? I'm still not getting any line numbers out-of-the-box. |
@therealprof It is supported since 1.22.1. |
Doesn't work for me and it's driving me nuts. This is all I get, even when calling the debug binary directly from the
Im running on: rustc 1.24.0-nightly (73bca2b9f 2017-11-28) |
@therealprof Probably a rustc issue rust-lang/rust#46346. |
Could be, but interestingly, I've never seen it work and rust-lldb craps out on the debug info, too. |
I did not see line number with rust version 1.37.0 in OSX as well, this info is useful when debugging.
While I try to run in Ubuntu:
But still can not locate where the issue happened, actually this is the line have problem
I am new to Rust, but as other do, I am thinking whether we can print the failed line number in |
You need to enable debuginfo in release builds if you want line numbers. |
@sfackler Great and Thanks I can see the line numbers after enable debug info. For further I am thinking we may can keep the the info sync. |
I still get this on Mac. Here's an example - I made it panic immediately.
It got a line number for the panic, so clearly there are some line numbers in there (this is a debug build). But the actual backtrace has no line numbers:
And
This isn't expected surely? |
Ah I figured it out. I had moved the executable - you need to move the |
I'm on Mac and using cargo 1.49.0 with rustc 1.49.0 I tested for a while and found that you can build with option E.g. |
I'm actually still having an issue with this. If I don't build in release mode on MacOS(M1 Monterey), things are fine. But when I do build with [profile.release]
debug = 1 I don't get line numbers. Here's the code I'm working on and if you run You'll get something like the following: ../scopes.rs:(Couldn't determine line number) No more words left in vcd file."', src/main.rs:24:31 I'm using backtrack by the way, as seen here Testing on my x86 Linux machine however, things seem to work fine. |
Repro steps:
Create a cargo project.
Run it. Note that the line numbers are missing (unexpected).
Output
Run the actual hard-linked program. The line numbers now appear (expected).
RUST_BACKTRACE=1 target/debug/deps/a-*
Output
The problem is that in rust-lang/rust#44251 we did not search for the
deps/
folder. The fix is either,target/debug/deps/a-«hash».dSYM
totarget/debug/a-«hash».dSYM
(actual name irrelevant), don't touchlibstd
. This may also fix No deterministic/easily findable name for debug symbol directory on macOS #4056; ordeps/
as well, don't touchcargo
.cc @JohnColanduoni
Meta
The text was updated successfully, but these errors were encountered: