rust-lang / rust-lang/rust-analyzer

Test Debug Broken | Windows, GDB, Native Debug, Individual Unit Tests

Open
#19,415 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

rust-analyzer version: rust-analyzer version: 0.3.2345-standalone (b0632f749e 2025-03-16)

rustc version: rustc 1.85.0 (4d91de4e4 2025-02-17)

editor or extension: VSCode, extension version v0.3.2345

relevant settings: "rust-analyzer.debug.engine": "webfreak.debug"

I'm using GDB on Windows 11 Pro. I have been fighting to make the various debug interfaces work so I could step through rust code and use breakpoints like normal.

After some time I found that the Native Debug engine choice made the internal settings a little less default-to-llvm, so I changed to that. Once that was done, the Debug button next to the main() function began to work, and I could generally do debugging. However, pressing the Debug button next to the unit test did not work.

After entirely too much troubleshooting, I was able to determine the issue was that the test executable was being passed a test name that was mangled by the quote() function such that it didn't actually parse to the right unit test. Any instances of :: in the test name passed would be replaced with :\: (iirc, might have been :\\:). I ... wonder if this interacts with the default terminal somehow. Anyhow, on my system it does not work and the test doesn't debug.

I was able to monkeypatch out the quote() function's replacement operation by editing the compiled Javascript, and now individual unit tests work on my system.

See: https://github.com/rust-lang/rust-analyzer/blob/32fa60f3a64708a579996bfad4fe04b895f9d156/editors/code/src/debug.ts#L408

It looks like the purpose of the function is to format any argument list so it's compatible with the shell. I'd like to know the use-case, expected input -> output, etc. I can't quite tell if the system it's fed to will even care about special characters. Is it passed to a debug provider registered by the Native Debug extension? Is that how this all works? (There's some documentation about it not needing escaping here: https://github.com/WebFreak001/code-debug?tab=readme-ov-file#extra-debugger-arguments apparently.) I've done a lot of code-sleuthing already; I assume someone knows the deep magic of this area better.

I am suggesting investigating removing the quote() code, or replacing it with a join() if needed. I don't have an llvm setup so I have no way of knowing if other systems would be broken by this.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in editors/code/src/debug.ts around line 408 and inspect how quote() formats the individual unit-test name for the Native Debug engine. Reproduce the Windows/GDB case with the Debug action beside a unit test, compare it with debugging main(), and verify that the test executable receives a usable test name without breaking other debugger argument handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, typescript
Domain
devtools, operating-systems, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.