Skip to content

Uplift .dSYM for unit tests as well #7960

Closed
@jiegec

Description

@jiegec

Describe the problem you are trying to solve

Currently, debug symbols are uplifted for binaries and examples only, see

// 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:

  1. Change the executable path in JSON to /path/to/project/target/debug/deps/project-123462f2a057f680
  2. Add symlink
  3. Let those tools handle this specific case

Notes

Related issue: rust-lang/rust#59907

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions