How can I debug Rust application step by step interactively like I'm able to do with "pry" in Ruby?
I want to be able to see and preferably change the variables in real time when I reach a break point. Is there any production ready finished project?
I find a good level of usability with VS Code and the CodeLLDB extension:
launch.json
file will be opened, if not, open it, it's under .vscode
folderYour launch.json
should look like this:
{
// 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",
"program": "${workspaceRoot}/target/debug/hello_world",
"args": [],
"cwd": "${workspaceRoot}/target/debug/",
"sourceLanguages": ["rust"]
}
]
}
If you wanted to keep things generic and only compile a binary that matches the cargo folder name, you could use ${workspaceRootFolderName} variable substitution for the "program" key:
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug",
"program": "${workspaceRoot}/target/debug/${workspaceRootFolderName}",
"args": [],
"cwd": "${workspaceRoot}/target/debug/",
"sourceLanguages": ["rust"]
}
]
}
Here are some blog posts about Rust and VS Code: