If you are developing using Rust on Windows with a WSL2, adding support for debugging is very easy. If you haven’t started using WSL2(Windows subsystem for Linux 2) yet, you can follow my previous post on how to Install and setup Rust development environment on WSL2.
Configure the debugger
Once the extension is installed, setup a debug configuration by clicking
Run -> Add Configuration from the VSCode menu. Add the following
launch.json configuration. You would need to change the program path when setting up the debug config for a different project.
Add a breakpoint in the rust file and hit
Run -> Start Debugging or press the
F5 key. You should see the the debugger pause at the breakpoint.
You can step through the code using the standard debug commands or by using the Debug control buttons in VsCode.
And that’s it! Have fun developing with Rust. 😃