Rust tip #1 for beginners
Vinayak Raghuvamshi
Driving Engineering Excellence | Cybersecurity, Distributed Systems | AWS | Azure | AI | Author | Mentor | Spirituality Coach
How to enable debugging of your rust programs:
IntelliJ IDEA does not support debugging Rust programs. For this, you have to use CLion and that doesn't come free.
After digging through various options, I found this easy way to enable debugging using Visual Code. It is free and it works. If you are a C++ developer like myself, you will be thrilled to find that all the debugging short cut keys you used to debug VC++ programs work with Visual code and for your Rust programs. This free debugger is not perfect however it is good enough for learning and experimenting with the language. I will soon be evaluating CLion to see how good the debugging option there is.
Any inputs, comments or further tips are welcome.
The steps for enabling Rust debugging:
1. Install Rust
2. Install Visual Studio Code (https://code.visualstudio.com/download)
3. Install C/C++ extension (Windows)
https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools
OR
4. Install CodeLLB (Linux/OSX)
https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb
5. Configure VS Code:
Click Debug -> Add Configuration
If you are on Windows then select C++ (Windows)
If you are on Mac or Linux then select LLDB: Custom Launch
6. Make sure you change the executable name under "program" in the launch.json
That is it! Now you should be all set to start debugging Rust in VS Code.
Update: If you choose to get CLion, the debugging details are well documented here: https://blog.jetbrains.com/clion/2019/10/debugging-rust-code-in-clion/