bazelbuild / bazelbuild/rules_rust

Can't attach breakpoints to the entry point of a `rust_test`, no debugging symbols generated

Open
#1,581 0 comments 0 reactions 0 assignees View on GitHub
needs-triage
Dominant language
Starlark
Stars
843
Forks
651
Avg merge
2d 18h
Merged PRs (30d)
15

Description

When debugging the output of a `rust_test` target using `lldb`, we can attach breakpoints to crate dependency sources and standard library sources, but not to the entry point file `tests/mytest.rs`.

Running on MacOS. I assume the problem is that no [dSYM folder containing debugging symbols](http://bazelbuild.github.io/rules_rust/defs.html#rust_binary) is generated for a `rust_test` even with `-c dbg` set. Whereas, for a `rust_binary`, it is generated.

**Environment**
OS is MacOS Monterey, `rules_rust` is v0.9.0, `lldb` is version lldb-1300.0.32.4, swift version 5.5.1-dev.

**Steps to reproduce**

1. Create a `rust_test` target (integration test style), and source file called say `tests/mytest.rs`, and create a simple test in a `#[test]` or `#[tokio:test]` block
2. `bazel build //tests:mytest -c dbg`
3. `lldb bazel-bin/tests/{path_to_test_binary}`
4. `b mytest.rs:{line_number}`

**Expected output**

A breakpoint should be attached

**Actual output**

It says: no locations (pending). Unable to resolve breakpoint to any actual locations.

**Additional information**

It is certainly feasible to make breakpoints work in the entry points of test files in Cargo, as when creating a `Cargo.toml` and using a Cargo build, the breakpoints can be hit. For some reason, this is not occurring in Bazel with `rules_rust`, even with `--compilation_mode=dbg`. I've also tried `--@rules_rust//:extra_rustc_flags=--codegen=debuginfo=2`.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with a rust_test using tests/mytest.rs, `bazel build //tests:mytest -c dbg`, and lldb. Compare the generated debug information for the rust_test and rust_binary cases, including the dSYM behavior described in the report. Done means breakpoints in tests/mytest.rs resolve and can be hit in lldb.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.