-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Describe the problem you are trying to solve
Currently, debug symbols are uplifted for binaries and examples only, see
cargo/src/cargo/core/compiler/build_context/target_info.rs
Lines 260 to 269 in e618d47
// See rust-lang/cargo#4490, rust-lang/cargo#4960. | |
// Only uplift debuginfo for binaries. | |
// - Tests are run directly from `target/debug/deps/` with the | |
// metadata hash still in the filename. | |
// - Examples are only uplifted for apple because the symbol file | |
// needs to match the executable file name to be found (i.e., it | |
// needs to remove the hash in the filename). On Windows, the path | |
// to the .pdb with the hash is embedded in the executable. | |
let is_apple = target_triple.contains("-apple-"); | |
if *kind == TargetKind::Bin || (*kind == TargetKind::ExampleBin && is_apple) { |
Related Issue: #4490.
Yet it seems that the path in executable key in cargo json format output points to target/debug/xxx-hash instead of target/debug/deps/xxx-hash, so tools like Intellij Rust fail to debug these tests: intellij-rust/intellij-rust#3680.
Cargo json output:
{
"reason": "compiler-artifact",
"package_id": "project 0.1.0 (path+file:///path/to/project)",
"target": {
"kind": [
"lib"
],
"crate_types": [
"lib"
],
"name": "project",
"src_path": "/path/to/project/src/lib.rs",
"edition": "2018",
"doctest": true
},
"profile": {
"opt_level": "0",
"debuginfo": 2,
"debug_assertions": true,
"overflow_checks": true,
"test": true
},
"features": [
],
"filenames": [
"/path/to/project/target/debug/project-123462f2a057f680"
],
"executable": "/path/to/project/target/debug/project-123462f2a057f680",
"fresh": true
}
Only /path/to/project/target/debug/deps/project-123462f2a057f680.dSYM exists, but /path/to/project/target/debug/project-123462f2a057f680.dSYM doesn't. So lldb can't pick up debug symbols when debugging /path/to/project/target/debug/project-123462f2a057f680.
Describe the solution you'd like
I think there are three possible solutions:
- Change the executable path in JSON to /path/to/project/target/debug/deps/project-123462f2a057f680
- Add symlink
- Let those tools handle this specific case
Notes
Related issue: rust-lang/rust#59907