Skip to content

Instantly share code, notes, and snippets.

@puffybsd
Last active July 7, 2022 11:56
Show Gist options
  • Save puffybsd/4dbee720b23c542e11eba90adfc0ce96 to your computer and use it in GitHub Desktop.
Save puffybsd/4dbee720b23c542e11eba90adfc0ce96 to your computer and use it in GitHub Desktop.
VSCode launcher for rust using lldb
{
// 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": [
{
"name": "Debug-LLDB",
"type": "lldb",
"request": "launch",
"program": "${workspaceRoot}/target/debug/${workspaceRootFolderName}",
"args": [],
"cwd": "${workspaceRoot}",
"sourceMap":{
"/checkout/src/" : "${env:HOME}/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/"
}
},
{
"name": "Debug-GDB",
"type": "gdb",
"request": "launch",
"arguments": "",
"cwd": "${workspaceRoot}",
"target": "${workspaceRoot}/target/debug/${workspaceRootFolderName}",
"printCalls": true,
"autorun": [
"set substitute-path /checkout ${env:HOME}/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust"
]
},
{
"name": "Debug-LLDB-Lib",
"type": "lldb",
"request": "launch",
"preLaunchTask": "rust lib debug copier",
"program": "${workspaceRoot}/target/debug/deps/${workspaceRootFolderName}",
"args": [],
"cwd": "${workspaceRoot}",
"sourceMap":{
"/checkout/src/" : "${env:HOME}/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/"
}
}
]
}
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
// Based on info from https://github.com/rust-lang/cargo/issues/1924
// Requires "jq" to be installed
// Works on Linux (possibly WSL)
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "rust lib debug copier",
"command": "cp",
"args": [
{
"value":
"$(ls -1t --indicator-style=slash $(cargo test --no-run --message-format=json | jq -r 'select(.profile.test == true) | .filenames[]') | head -n1)",
"quoting": "weak"
},
"${workspaceRoot}/target/debug/deps/${workspaceRootFolderName}",
],
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
}
}
]
}
@puffybsd
Copy link
Author

puffybsd commented Apr 5, 2018

Enables stepping into the rust core code while debugging in vscode using LLDB and GDB.

@puffybsd
Copy link
Author

Added tasks.json and Debug-LLDB-Lib to enable stepping through lib projects (unit tests and lib.rs) using a few subshells and pipes to position the most recently generated binary into a "deterministic" name. Used the jq technique to identify the binary name as listed here: rust-lang/cargo#1924

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