Skip to content
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

Unable to resolve breakpoints when debugging a unit test in a lib target #59907

Closed
mchernyavsky opened this issue Apr 12, 2019 · 5 comments
Closed
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) O-macos Operating system: macOS T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@mchernyavsky
Copy link

Environment

  • Operating system: macOS Mojave 10.14.4
  • Rust toolchain: nightly-x86_64-apple-darwin
  • Rustc version: 1.35.0-nightly (96d700f 2019-04-10)

Problem description

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.

Steps to reproduce:

Example project:

  • 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 script (bash):

  • 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"
  • Delay 1 second before running the LLDB:
> ./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.
  • Delay 2 seconds before running the LLDB:
> ./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

P.S.

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"
]
@jonas-schievink jonas-schievink added A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) O-macos Operating system: macOS T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 12, 2019
@stepan-romankov
Copy link

Any plans for this? Still doesn't work in 1.39

@jiegec
Copy link

jiegec commented Mar 3, 2020

@kwhrtsk
Copy link

kwhrtsk commented Mar 3, 2020

I tried to make a simple workaround to avoid this problem with VSCode (CodeLLDB).

https://github.com/kwhrtsk/rust-lldb-workaround

Any other workarounds?

@jiegec
Copy link

jiegec commented Mar 5, 2020

This should be fixed by rust-lang/cargo#7965

@tamerh
Copy link

tamerh commented Apr 23, 2020

After upgrading the Rust seems I am still having this problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) O-macos Operating system: macOS T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants