Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Toggle Breakpoint does not work in Visual Studio Code

When I try to set a breakpoint nothing happens; I put my cursor on the println! line and press F9.

fn main() {
    println!("Hello, world!");
}

I works on another machine where Visual Studio 2017 is installed, so I suspect this might the problem.

tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "command": "cargo build",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "panel": "dedicated",
                "clear": true
            },
            "problemMatcher": {
                "owner": "rust",
                "fileLocation": [
                    "relative",
                    "${workspaceRoot}"
                ],
                "pattern": {
                    "regexp": "^(.+):(\\d+):(\\d+):\\s+(\\d+):(\\d+)\\s+(warning|error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "endLine": 4,
                    "endColumn": 5,
                    "severity": 6,
                    "message": 7
                }
            }
        },
        {
            "label": "clean",
            "type": "shell",
            "command": "cargo clean"
        },
        {
            "label": "run",
            "type": "shell",
            "command": "cargo run",
            "presentation": {
                "panel": "dedicated",
                "clear": true
            },
            "problemMatcher": []
        },
        {
            "label": "test",
            "type": "shell",
            "command": "cargo test",
            "group": {
                "kind": "test",
                "isDefault": true
            },
            "presentation": {
                "panel": "dedicated",
                "clear": true
            },
            "problemMatcher": [
                {
                    "owner": "rust",
                    "fileLocation": [
                        "relative",
                        "${workspaceRoot}"
                    ],
                    "pattern": {
                        "regexp": "^(.+):(\\d+):(\\d+):\\s+(\\d+):(\\d+)\\s+(warning|error):\\s+(.*)$",
                        "file": 1,
                        "line": 2,
                        "column": 3,
                        "endLine": 4,
                        "endColumn": 5,
                        "severity": 6,
                        "message": 7
                    }
                },
                {
                    "owner": "rust",
                    "fileLocation": [
                        "relative",
                        "${workspaceRoot}"
                    ],
                    "severity": "error",
                    "pattern": {
                        "regexp": "^.*panicked\\s+at\\s+'(.*)',\\s+(.*):(\\d+)$",
                        "message": 1,
                        "file": 2,
                        "line": 3
                    }
                }
            ]
        }
    ]
}

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(Windows) Launch",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${workspaceFolder}/target/debug/${workspaceRootFolderName}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}/target/debug/",
            "environment": [],
            "externalConsole": true,
        },       
    ]
}

I have Visual Studio 2019 installed:

>cl --version   
Microsoft (R) C/C++ Optimizing Compiler Version 19.20.27508.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

I have these Visual Studio Code extensions installed:

  1. C/C++ 0.22.1
  2. Rust (rls) 0.6.0

I am using Rust 1.33.0.

like image 245
Damian Avatar asked Dec 13 '25 01:12

Damian


1 Answers

try setting the setting value "debug.allowBreakpointsEverywhere" to true

like image 64
Tal Avatar answered Dec 15 '25 14:12

Tal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!