Remote debugging in Visual Studio (Linux)

Since Visual Studio 2015, remote debugging is supported. You can compile it in the target Linux environment, run it on GDB, and work with that GDB using the Visual Studio debugger interface.

Create a new project

newproject.PNG

Write code

code.PNG

Anything that is not included in the standard C / C ++ library will appear as a syntax error in Visual Studio. However, since the code is compiled and executed on the target Linux, there is no problem if the code can be compiled by hitting g ++ etc. in the target environment.

syntaxerror.PNG

If you really care about it, you can bring a set of header files from the target system, throw them in an appropriate directory, and add them to the include directory of the project properties.

2017.08.20 Addendum: It can also be a network drive or Samba share. If Visual Studio can read and parse the header file, the syntax error will disappear.

As long as you're using Visual Studio, you want to take care of IntelliSense.

Frequently used items are included in $ (ISenseIncludePath).

$(ISenseIncudePath) By default, it looks like this: (Depending on the version of Visual Studio)

Run

Build and run the project.

Since you cannot see the console output as it is, open the console in the Linux environment.

linux_console.PNG

When using remote debugging for the first time, a screen for specifying the connection destination will appear.

ssh.PNG

It looks like this when it can be executed. console_out.png

By default, gdbserver is started in the target environment and connected to it from Visual Studio.

If you are told that gdbserver cannot be found, include gdbserver.

gdbserver_notfound.PNG

% zypper in gdbserver
And
% apt-get install gdbserver

Debugger operation

You can use variable watchers, deassembly, and call stacks with familiar screens and operations.

break.PNG

Recommended Posts

Remote debugging in Visual Studio (Linux)
Remote debugging with Visual Studio 2017
Problems and solutions for using the remote debugging environment for Linux apps in Visual Studio 2017
Install numpy in Visual Studio 2019
Bottle Pug in Visual studio 2019
Python development in Visual Studio 2017
Python development in Visual Studio
How to use linux commands in Visual Studio Code terminal
Edit files directly on Linux with Visual Studio Code Remote SSH
Run Python in C ++ on Visual Studio 2017
Run Python YOLOv3 in C ++ on Visual Studio 2017
Data Science Workloads and RTVS in Visual Studio 2017
Settings for Python coding in Visual Studio Code
Let's do Linux System Programming with Visual Studio Code and Azure! (From helloworld to nginx development and remote debugging)
Linux permissions in Java
Translator in Python from Visual Studio 2017 (Microsoft Translator Text API)
Try debugging Python on Raspberry Pi with Visual Studio.
Seurat in Linux (installation)
Until you run server Django in Visual Studio Code
Japanese output when dealing with python in visual studio
AWS SDK for Python (Boto3) development in Visual Studio 2017
How to debug the Python standard library in Visual Studio
Do something like a Python interpreter in Visual Studio Code
SSH restrictions in Linux environment
Debugging with pdb in Python
Remote related settings in pycharm
Collaborate in a remote environment
[Linux Mint 20] Remote desktop connection / connection
Linux: DNS replacement in systemd.
Run Amazon Linux 2 in VirtualBox
Bash, Python, Javascript, code command, etc. in Visual Studio Code on Mac
A memo for those who use Python in Visual Studio (me)