On macOS, when you build tests (with cargo test --no-run) in a lib target, and right after that run LLDB on the test binary, the debugger unable to resolve breakpoints.
Cargo.toml:[package]
name = "sandbox"
version = "0.1.0"
edition = "2018"
src/main.rs:fn main() {}
#[test]
fn test() { assert_eq!(2 + 2, 5) }
src/lib.rs:#[test]
fn test() { assert_eq!(2 + 2, 4) }
test.sh:#!/usr/bin/env bash
rm -rf target
EXE="$(cargo test --no-run --message-format=json --lib test 2>/dev/null | jq -r '.executable')"
sleep "$1"
lldb "$EXE" <<< "b test"
> ./test.sh 1
(lldb) target create "/Users/mikhail.chernyavsky/Workspace/rust-sandbox/target/debug/sandbox-5d25a79faaa6e465"
Current executable set to '/Users/mikhail.chernyavsky/Workspace/rust-sandbox/target/debug/sandbox-5d25a79faaa6e465' (x86_64).
(lldb) b test
Breakpoint 1: no locations (pending).
WARNING: Unable to resolve breakpoint to any actual locations.
> ./test.sh 2
(lldb) target create "/Users/mikhail.chernyavsky/Workspace/rust-sandbox/target/debug/sandbox-5d25a79faaa6e465"
Current executable set to '/Users/mikhail.chernyavsky/Workspace/rust-sandbox/target/debug/sandbox-5d25a79faaa6e465' (x86_64).
(lldb) b test
Breakpoint 1: where = sandbox-5d25a79faaa6e465`sandbox::test::h95a153b117ba44e2 + 11 at lib.rs:2:23, address = 0x00000001000017bb
I also noticed that the *.dSYM file is not listed in the filenames field:
> cargo test --no-run --message-format=json --lib test 2>/dev/null | jq -r '.filenames'
[
"/Users/mikhail.chernyavsky/Workspace/rust-sandbox/target/debug/sandbox-5d25a79faaa6e465"
]
For example, build unit tests in bin target:
> cargo test --no-run --message-format=json --bin sandbox 2>/dev/null | jq -r '.filenames'
[
"/Users/mikhail.chernyavsky/Workspace/rust-sandbox/target/debug/deps/libsandbox-006b5c7138cbbb04.rlib"
]
[
"/Users/mikhail.chernyavsky/Workspace/rust-sandbox/target/debug/sandbox-94b9126e8bd84c57",
"/Users/mikhail.chernyavsky/Workspace/rust-sandbox/target/debug/sandbox-94b9126e8bd84c57.dSYM"
]
Any plans for this? Still doesn't work in 1.39
I think this issue should be moved to cargo. This is how dSYM uplifting works for binaries:
I tried to make a simple workaround to avoid this problem with VSCode (CodeLLDB).
https://github.com/kwhrtsk/rust-lldb-workaround
Any other workarounds?
This should be fixed by rust-lang/cargo#7965
After upgrading the Rust seems I am still having this problem
Most helpful comment
This should be fixed by rust-lang/cargo#7965