VSCode Debugger won't stop at breakpoints in Rust code

190 Views Asked by At

I am learning Rust through the rustlings project, and I cannot get VSCode to stop at my breakpoints no matter what tutorial I follow on Rust debugging. I am currently doing this on Mac OS 12.6.

I installed rust-analyzer installed, and CodeLLDB , and set “allow breakpoints anywhere” to enabled.

The file I am trying to debug is intro2.rs. I tried compiling it a couple of times by running rustc .../rustlings/intro/intro2.rs, and an executable (I think) file intro2 appears in the intro folder. Then I tried running the debugger but it doesn't stop at my breakpoints, and it doesn't output the print statements in my code (I do get the messages if I run executable directly from the command line).

I tried building the whole rustlings project by running "cargo build" in the rustlings directory and I get a message saying: "Finished dev [unoptimized + debuginfo] target(s) in 0.09s" and a file called rustlings appears in the directory ".../rustlings/target/debug". Still the debugger won't stop at my breakpoints.

I have my launch.json file set up as shown below at the end with the "program" property set to either one of: "program": /path/to/intro2 OR "program": .../rustlings/target/debug/rustlings

still nothing.

The debugger does stop at some assembly instructions if I add "main" to my breakpoints which leads me to conclude that the debugger is working but the debug info is not included when compiling "intro2.rs" but I don't why that's the case.

Someone please help!

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug executable 'rustlings'",
            "program": "/Users/mo0dy/Desktop/.rustuff/rustlings/exercises/intro/intro2",
            "cargo": {
                "args": [
                    "build",
                    "--bin=rustlings",
                    "--package=rustlings"
                ],
                "filter": {
                    "name": "rustlings",
                    "kind": "bin"
                }
            },
            "args": [],
            "cwd": "${workspaceFolder}"
        },
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug unit tests in executable 'rustlings'",
            "cargo": {
                "args": [
                    "test",
                    "--no-run",
                    "--bin=rustlings",
                    "--package=rustlings"
                ],
                "filter": {
                    "name": "rustlings",
                    "kind": "bin"
                }
            },
            "args": [],
            "cwd": "${workspaceFolder}"
        },
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug integration test 'integration_tests'",
            "cargo": {
                "args": [
                    "test",
                    "--no-run",
                    "--test=integration_tests",
                    "--package=rustlings"
                ],
                "filter": {
                    "name": "integration_tests",
                    "kind": "test"
                }
            },
            "args": [],
            "cwd": "${workspaceFolder}"
        }
    ]
}
0

There are 0 best solutions below