Skip to content

Instantly share code, notes, and snippets.

@xanathar
Created September 17, 2020 18:16
Show Gist options
  • Save xanathar/c7c83e6d53b72dd4464f695607012629 to your computer and use it in GitHub Desktop.
Save xanathar/c7c83e6d53b72dd4464f695607012629 to your computer and use it in GitHub Desktop.
launch.json to debug Rust with VsCode
{
// The following are sample configurations for common case scenarios of debugging
// Rust in Visual Studio Code
//
// For syntax, visit: https://go.microsoft.com/fwlink/?linkid=830387
//
"version": "0.2.0",
"configurations": [
{
"name": "Launch an application",
"type": "lldb",
"request": "launch",
"program": "${workspaceRoot}/path-to/the-executable",
"args": [ "arg1", "arg2" ],
"cwd": "${workspaceRoot}/path-to",
},
{
"name": "Attach to a named executable",
"type": "lldb",
"request": "attach",
"program": "${workspaceRoot}/path-to/the-executable",
},
{
"name": "Debug ALL unit tests in library 'mylib'",
"type": "lldb",
"request": "launch",
"cargo": {
"args": [
"test",
"--no-run",
"--lib",
"--package=mylib"
],
"filter": {
"name": "mylib",
"kind": "lib"
}
},
"args": [ ],
"cwd": "${workspaceFolder}"
},
{
"name": "Debug specific unit test in library 'mylib'",
"type": "lldb",
"request": "launch",
"cargo": {
"args": [
"test",
"--no-run",
"--lib",
"--package=mylib"
],
"filter": {
"name": "mylib",
"kind": "lib"
}
},
"args": [ "name_of_the_unit_test" ],
"cwd": "${workspaceFolder}"
},
{
"name": "Debug example 'some-example'",
"type": "lldb",
"request": "launch",
"cargo": {
"args": [
"build",
"--example=some-example",
"--package=my-package"
],
"filter": {
"name": "some-example",
"kind": "example"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
]
}
@felipelalli
Copy link

Very useful, thank you!

@wjx0912
Copy link

wjx0912 commented Jun 12, 2024

good job, thanks.

@MatthewYaegerTR
Copy link

thanks for creating this. we could be using RustRover for debugging, but VSCode is prettier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment