Debugging Rust Projects in VS Code and Terminal

alpha2phi
2 min readDec 16, 2020

Overview

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.

--

--

alpha2phi
alpha2phi

Written by alpha2phi

Software engineer, Data Science and ML practitioner.

No responses yet