Install the official Rust extension and configure the Cargo.toml to enable debugging symbols.
- Install the
rust-lang.rust-analyzerextension from the VS Code Marketplace. - Add
debug = trueto your[profile.dev]section inCargo.tomlto ensure debug info is generated. - Create a
.vscode/launch.jsonfile with thecargoconfiguration to run the debugger.
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "lldb",
"request": "launch",
"cargo": {
"args": ["run", "--bin", "your_binary_name"]
},
"cwd": "${workspaceFolder}"
}
]
}
- Set a breakpoint in your code and press F5 to start debugging.