This repository has been archived by the owner on Feb 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Debugging Rust with Visual Studio Code
James Ray edited this page May 11, 2018
·
17 revisions
- Install VS Code
- (Not recommended for non-Mac OSs) Follow this blog post to setup debugging with breakpoints using LLDB in VS Code.
- (Not recommended as using RLS and Native Debug with the below launch.json should be simpler). Troubleshoot by following these steps
- Example Debug Config file Diamond-drops/.vscode/launch.json. Use by going to menu: Debug > Start Debugging. Note that you shouldn't have to build the project first, as running these debuggers will just run
cargo run -mode c
for example. - Further information is here. Use CTRL+P before entering
ext install <insert-extension>
.
See the .vscode in this folder for the latest changes available in the develop branch.
/diamond_drops/.vscode/launch.json
:
{
// 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": [
// This is just for testing really;
// it filters out all tests in the below cli target debug binary.
{
"type": "lldb-mi",
"request": "launch",
"name": "preLaunchTask (no arguments), will err",
"target": "./target/debug/cli",
"cwd": "${workspaceRoot}"
},
{
"type": "lldb-mi",
"request": "launch",
"name": "mode -b",
"target": "./target/debug/cli",
"cwd": "${workspaceRoot}",
"arguments": "mode -b"
},
{
"type": "lldb-mi",
"request": "launch",
"name": "mode -n",
"target": "./target/debug/cli",
"cwd": "${workspaceRoot}",
"arguments": "mode -n"
},
{
"type": "lldb-mi",
"request": "launch",
"name": "mode -p",
"target": "./target/debug/cli",
"cwd": "${workspaceRoot}",
"arguments": "mode -p"
},
{
"type": "lldb-mi",
"request": "launch",
"name": "mode -h",
"target": "./target/debug/cli",
"cwd": "${workspaceRoot}",
"arguments": "mode -h"
},
{
"type": "lldb-mi",
"request": "launch",
"name": "mode -v",
"target": "./target/debug/cli",
"cwd": "${workspaceRoot}",
"arguments": "mode -v"
},
]
}
- Following is an example Build Task file Diamond-drops/.vscode/tasks.json. Use by going to menu: Tasks > Run Build Task. Note that Cargo tasks are already available via Tasks > Run Task.
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
// Refer to https://stackoverflow.com/questions/31702041/multiple-commands-tasks-with-visual-studio-code/32290053#32290053
"command": "bash",
"type": "shell",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"args": [
"-c"
],
"tasks": [
/* template
{
"label": "cargo ",
"args": [
"cargo","make", "all"
],
"problemMatcher": [
"$rustc"
]`
},
*/
{
"label": "cargo make all",
"args": [
"cargo","make", "all"
],
"group": "build",
"problemMatcher": [
"$rustc"
]
},
{
"label": "cargo make test-all",
"args": [
"cargo","make", "test-all"
],
"group": "test",
"problemMatcher": [
"$rustc"
]
},
{
"label": "cargo make test-node",
"args": [
"cargo","make", "test-node"
],
"group": "test",
"problemMatcher": [
"$rustc"
]
},
{
"label": "cargo make test-cli",
"args": [
"cargo","make", "test-cli"
],
"group": "test",
"problemMatcher": [
"$rustc"
]
},
{
"label": "cargo make test-env",
"args": [
"cargo","make", "test-env"
],
"group": "test",
"problemMatcher": [
"$rustc"
]
},
{
"label": "cargo make build; cargo make watch",
// cargo install cargo-watch; is omitted for performance
"args": [
"cargo make build; cargo make watch"//"make", "p"
],
"problemMatcher": [
"$rustc"
]
},
{
"label": "cargo make docs",
"args": [
"cargo make docs"
],
"problemMatcher": [
"$rustc"
]
},
// cargo make uml-X only works on a Mac,
// https://github.com/Drops-of-Diamond/diamond_drops/issues/48
{
"label": "cargo make uml-chrome",
"args": [
"cargo make uml-chrome"
],
"problemMatcher": [
"$rustc"
]
},
{
"label": "cargo make uml-firefox",
"args": [
"cargo make uml-firefox"
],
"problemMatcher": [
"$rustc"
]
},
{
"label": "cargo make uml-brave",
"args": [
"cargo make uml-brave"
],
"problemMatcher": [
"$rustc"
]
},
{
"label": "cargo make n",
"command": "cargo",
"args": [
"make", "n"
],
"problemMatcher": [
"$rustc"
]
},
{
"label": "cargo make b",
"command": "cargo",
"args": [
"make", "b"
],
"problemMatcher": [
"$rustc"
]
},
{
"label": "cargo build",
"command": "cargo build",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$rustc"
]
},
{
"label": "cargo run -- mode --help",
"command": "cargo",
"args": [
"run", "--", "mode", "--help"
],
"problemMatcher": [
"$rustc"
]
},
{
"label": "cargo run -- mode -b",
"command": "cargo",
"args": [
"run", "--", "mode", "-b"
],
"problemMatcher": [
"$rustc"
]
},
{
"label": "cargo run -- --help",
"command": "cargo",
"args": [
"run", "--", "--help"
],
"problemMatcher": [
"$rustc"
]
},
},
]
}