Rust Visual Studio Code



At the very beginning, I want to share my development environment for Rust. While I’m writing, I changed my mind in the middle of writing adding debugger’s too. It seems more valuable to help others.

I use the Visual Studio Code for creating Rust applications. My environment is not the best. To hear about your development environment, I want to share mine first. Please share your environments in replies. I’m open to the new one. For simplicity and lightweight, I select the Visual Studio Code. It’s powerful too. Then, the most important things are the extensions.

Shows how to build & debug Rust in VS Code.In this case, demonstrated from linux. Open Visual Studio Code and go to./src/main.rs and place a breakpoint. Edit launch.json. Press F5 to run the project. A selection box will appear that will ask you what environment you want to use. Choose LLDB Debugger here. This will open up the launch.json file, and here we need to tell Visual Studio Code how to launch our project. Edit the file so it looks similar to this. To start using Rust, download the installer, then run the program and follow the onscreen instructions. You may need to install the Visual Studio C Build tools when prompted to do so. If you are not on Windows see 'Other Installation Methods'. Download rustup-init.exe (32-bit). Rust support for Visual Studio Code. Adds language support for Rust to Visual Studio Code. Supports: code completion; jump to definition, peek definition, find all references, symbol search; types and documentation on hover; code formatting; refactoring (rename, deglob) error squiggles and apply suggestions from errors; snippets; build tasks. Rust for Visual Studio Code alternatives and similar packages Based on the 'IDEs' category. Alternatively, view Rust for Visual Studio Code alternatives based on common mentions on social networks and blogs.

Extensions

Rust Visual Studio Code

crates

The crates extension helps me managing packages in the project. [1]

rust-analyzer

While programming in Rust, it gives me warnings, errors, and hints when calling functions. It boosts productivity a lot. [2]

Rust Visual Studio Code

I try to find about debugging in Rust. How we can use debugger with the Visual Studio Code.

Tutorial

dbg! macro - the Basic

First, the most basic one prints the variable, or we can use println! macro.

Rust Visual Studio Code Debug

Debug rust vscode

The dbg macro[3] gives more information than the println macro. It shows a line number and a file name too.

Rust Vscode Extension

gdb(pwndbg)

I think the pwndbg [4] makes the GDB [5] more visually friendly. Unfortunately, I have been failed to use the pwndbg since this issue arises [6]. I saw how does it look like while debugging. The package brings the debugged source code to the top part of a screen. Instead of pure GDB, I can debug by watching the source.

Here are postings about how to use pwndbg. https://blog.xpnsec.com/pwndbg/https://www.ins1gn1a.com/basics-of-gdb-and-pwndbg/

CodeLLDB - Step by Step Debugger

I followed these steps [7] to install the CodeLLDB [8]. It’s an extension in the Visual Studio Code. All the steps are working. Photo editor for java mobile. My versions are followings.

In step 7, I need to set “launch.json” and I used this.

Rust Visual Studio Code Crack

I can use a step-by-step debugger as the following image. On the left sidebar, we can see the variable ‘a’ is 3.

Rust Visual Studio Code Tutorial

References