How to debug a Linux build using Visual Studio and WSL

If you use Microsoft Visual Studio for your coding, then Visual Studio can debug on Linux using Windows Subsystem for Linux (WSL) and GDB.

The WSL lets you run a GNU/Linux environment, including most command-line tools, utilities, and applications, directly on Windows, unmodified, without the overhead of a virtual machine.

In this GDB tutorial, I’ve asked Microsoft Developer Advocate Sy Brand to show you how.

Setup for GDB debugging

To install WSL, go to https://AKA.MS/WSL on your web browser. Just follow the instructions to get a full installation of your favorite Linux distribution.

When you are back in your code, go to My Configurations, click on Manage Configuration, and add a new configuration so you can target WSL right from Visual Studio. Scroll down the list to find the WSL-GCC-Debug, and that allows a new target.

You are set.

Yes, it is easy to get started.

Effective breakpoints

Now you can set breakpoints like you usually cannot do in Visual Studio. You can change the settings to add conditions to the breakpoint. Or you can add actions such as show a message in the output window whenever the breakpoint is hit.

Debugging in context

You can see your locals in your window and when you are at a breakpoint, and you know where you are in your code. So, you stay in your debugging flow all the time.

You can even right-click on a variable and add a watchpoint.

Super helpful!

Visual Studio offers you a genuinely comfortable debugging experience.

Enjoy the Visual Studio debugging experience.

Originally published at https://undo.io.

--

--

--

Time travel debugging: understand complex code and fix bugs faster

Recommended from Medium

RandomBALZ_No1

How to Fork, Use Git and Github

Selenium Webdriver for Automation Web Application Testing (Part 1)

GitLab’s 2018 Product Vision: Prototype demo

Developing Python application: Virtual environment

Fast Gray Rabbit Gin Helping Ty Find His Tiger-Eye Gemstones

Fast Gray Rabbit Gin Helping Ty Find His Tiger-Eye Gemstones

Visual Studio Code Web Development Setup and Extensions

7 Lessons I learned during probably the largest hackathon ever

Dual track agile process at Quentic

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Undo Bytes

Undo Bytes

Undo is the time travel debugging company for Linux. We equip developers with the technology to understand complex code and fix bugs faster. https://undo.io

More from Medium

.NET Core C# Development Setup On Apple Silicon Mac

It’s time to tidy up your code: How to use Visual Studio Code Autoformat

Docker and Python debugging error in VS Code: Timed out waiting for launcher to connect.

Command-Line Interface — Homebrew