It appears that as of the time of writing this, there is no official rust debugger. Luckily, there are two generic debuggers which seem to do the job alright: GDB, LLDB. Setting up both of them is basically the same process. So far, I had a nicer experience with LLDB so that will be the focus.
There are a few LLDB debuggers available for VSCode. The one I decided to use was CodeLLDB (vadimcn.vscode-lldb
), but once again all of them should work almost the same way.
Here is the .vscode/launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug",
"preLaunchTask": "build",
"program": "${workspaceFolder}/target/debug/${workspaceFolderBasename}",
"args": [],
"cwd": "${workspaceFolder}"
}
]
}
You may notice that I had a preLaunchTask
defined. The reason for this is that LLDB doesn't know how to rebuild your code. It is necessary to define that process:
.vscode/tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "cargo",
"args": ["build", "-q"],
"type": "process"
}
]
}