Debugging Rust Projects in VS Code and Terminal

2 min readDec 16, 2020


Compared to other tools, Visual Studio Code is a great code editor providing seamless integration with Rust projects in terms of LSP (Language Server Protocol) and DAP (Debugger Adapter Protocol). Configure LSP for Rust is easy for all the Rust tools but setting DAP for debugging may not be so straight forward. If you prefer a light-weight code editor with seamless DAP integration then VS Code is a good choice.

Getting Started

Install Rust by following the instructions here.

Install Visual Studio Code.

From VS Code, press Ctrl-P (Command P for macOS), and enter ext install rust-lang.rustto setup LSP support for Rust. You may be prompted to install other components by the extension.

Below are the different ways that you can use Visual Studio Code to debug your Rust projects.

LLDB Native Debugger

The LLDB Debugger is the debugger component of the LLVM project.

In Visual Studio Code, press Ctrl-P (Command P for macOS), enter ext install vadimcn.vscode-lldbto install CodeLLDB.

When it runs for the first time, the extension detects the Cargo project settings and creates a launch.json. After that you can set breakpoints and press F5 to start debug your application.

Cargo Debug

We are going to use cargo-debug instead of rust-lldb

Install cargo-debug

# cargo install cargo-debug

Once installed you can use lldb to debug the code in terminal.

Debug using the LLDb debugger

# cargo debug --debugger=lldb

Once you are in lldb debugger, you can set breakpoint

E.g. breakpoint set -l 1 sets a breakpoint at line 1.

Enterrunto start debugging.




Software engineer, Data Science and ML practitioner.