VsCode Debug RUST
Brian Horakh
Posted on May 23, 2022
This guide is intended to explain how to use the VSCode LLDB debugger with RUST.
Cunningham's Law states "the best way to get the right answer on the internet is not to ask a question; it's to post the wrong answer." The concept is named after Ward Cunningham, the inventor of wiki software.
With the Cunningham spirit in mind, if you know a better way to do this, or other cool stuff I should try please let me know in the comments.
Resources I used:
- https://github.com/vadimcn/vscode-lldb/blob/master/MANUAL.md#vscode-commands
- https://vscode-docs.readthedocs.io/en/stable/editor/debugging/
CodeLLDB natively supports visualization of most common Rust data types:
Built-in types: tuples, enums, arrays, array and string slices.
Standard library types: Vec, String, CString, OSString, Path, Cell, Rc, Arc and more.
Below is a fully functioning launch.json for vscode that works with rust 1.60, inline comments:
{
"version": "0.2.0",
"configurations": [
{
// 😓 LLDB Help: https://github.com/vadimcn/vscode-lldb/discussions
"type": "lldb",
"request": "launch",
"name": "Debug",
// 🤓 use this to debug RUST binaries:
"program": "${workspaceRoot}/target/debug/${workspaceRootFolderName}",
// 🤓 use cargo for libraries
/*
"cargo": {
"args": ["test", "--no-run", "--lib"], // Cargo command line to build the debug target
// "args": ["build", "--bin=foo"] is another possibility
"filter": { // Filter applied to compilation artifacts (optional)
"name": "mylib",
"kind": "lib"
}
*/
"args": [],
"cwd": "${workspaceFolder}",
"sourceLanguages": ["rust"], // required to add support for Vec, String, enum ..
"terminal":"integrated", // can also be 'console', 'external'
// 🤓 https://github.com/vadimcn/vscode-lldb/blob/master/MANUAL.md#stdio
"stdio": null // connect all streams to default terminal, can also use file(s)
// "stopOnEntry":true, // should open an lldb hex/asm dump on start
]
}
Posted on May 23, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.