VSCode debug shows "Locations: 0" for all breakpoints when debugging Rust library
Asked Answered
T

2

8

I'm trying to debug a Rust library in Visual Studio Code and I'm running into an issue. When I run the debug, all the breakpoints turn grey and when I hover over them they show Locations: 0 (Picture of the problem here). The tests then execute without hitting any of the breakpoints. It debugs fine when I run lldb in the terminal, and I can't reproduce the issue with other libraries, it seems to be specific to this project. I've tried copying only the required files to a new project and the issue reappears, so I think it must be something to do with my configuration.

I'm using the launch.json file created automatically by vscode:

{
  "type": "lldb",
  "request": "launch",
  "name": "Debug unit tests in library 'my_project'",
  "cargo": {
    "args": [
      "test",
      "--no-run",
      "--lib",
      "--package=my_project"
    ],
    "filter": {
      "name": "my_project",
      "kind": "lib"
    }
  },
  "args": [],
  "cwd": "${workspaceFolder}"
} 

I have tests in most of the library files and the included binary, and they all have the same issue. Here's a simplified version of the project structure:

main project directory
├── benches
│   └── my_benchmark.rs
├── Cargo.lock
├── Cargo.toml
├── src
│   ├── bin
│   │   └── main.rs
│   ├── lib.rs
│   ├── requests
│   │   └── [several library files]
│   ├── requests.rs
│   ├── structures
│   │   └── [several library files]
│   └── structures.rs

The software versions I'm using are:

  • Visual Studio Code v1.55.2
  • CodeLLDB v1.6.2
  • rustc v1.51.0
  • Ubuntu v20.10

I looked for quite a while but I couldn't find any other mentions of this issue in other questions. Thanks for your help, please let me know if I can provide more information!

Titanomachy answered 25/4, 2021 at 22:48 Comment(0)
T
3

Well, I figured it out. The problem seems to be a bug in CodeLLDB version 1.6.2. I reverted to 1.6.1 and everything works fine. Leaving this up in case anyone else runs into the same issue.

Titanomachy answered 26/4, 2021 at 19:22 Comment(0)
M
0

I faced a similar issue, but my problem was that I was opening the folder in VSCode through a symbolic link, while debugging information usually contains the realpath of files (e.g. I did code ~/symbolic-link-to-project instead of code /real/path/to/project)

Opening the folder using the real path in vscode fixed it for me, but there are other options, such as using sourceMaps

Milone answered 19/6 at 21:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.