Connect Visual Studio C++ Remote Debugging on Windows to a Process on Linux system

Erdi Sayar 21 Reputation points
2020-12-30T21:58:21.54+00:00

Hello,
I would like to connect VS 2019 to a process on the linux system for debugging purposes. (If there is a more convenient way for that, I would like to get to know.)

Firstly, based on the information on this page, https://learn.microsoft.com/de-de/cpp/linux/connect-to-your-remote-linux-computer?view=msvc-160 I created an ssh server on my Linux machine and I connected VS 2019 to my Linux system via ssh

PXlAm.png

on my Linux machine, I am using a robot in a simulation program (ROS) and C++ code controls it. Debugging is working on my Linux machine using Visual studio code.

Here I attached the process using Visual Studio Code
57YBz.png

Here is the debugging using Visual Studio Code on Linux
uPxnV.png

However, I would like to connect my VS 2019 to this process for debugging purposes.

For that I open VS 2019 and click the "Attach to Process"

Here is the picture for clicking to attach process
XWN1C.png

After that , I connected to my Linux machine via SSH in VS 2019 and attached the process as I shown in the following picture.

Attaching Process to the specific Process ID on Linux machine
KA4Yu.png

Selecting debug code type
nTDMD.png
Then I see a empty screen in VS 2019 shown in following picture.

After attaching process ID

Bl406.png

Do you have any idea how can I do this? or do you know different and more convenient way?

Developer technologies Visual Studio Debugging
0 comments No comments
{count} votes

Accepted answer
  1. Dylan Zhu-MSFT 6,426 Reputation points
    2020-12-31T03:08:49.373+00:00

    Hi ErdiSayar,

    Attaching SSH is applied to .net core application. You need to create a Linux console application, which can help you debug your C++ code on remote linux server.

    Best Regards, Dylan

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our * *documentation* to enable e-mail notifications if you want to receive the related email notification for this thread.**

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Erdi Sayar 21 Reputation points
    2020-12-31T11:31:35.017+00:00

    Thank you very much for your comments.
    I followed instructions in the web page you refereed. However,I did not succeed in doing this.
    Let me explain these in the following;
    I created "Linux Console Application" and made a SSH Connections to the my Linux machine.

    I see the following page as a default page in Visual Studio 2019. When I clicked the run button (green arrow inside yellow rectangle in the picture ), then I see the output in Linux Console Window.
    52551-31-12-2020-12-14-56.png

    Now on the linux machine , I created a simple C++ Program named 'main.cpp' in Visual Studio Code.
    52561-screenshot-from-2020-12-31-12-18-59.png

    Now , I tried to attach process ;
    52328-attach-process.png

    then I see 2 different types of debugging;

    52552-debuggin-types.png

    If I select native GDB, , then I got the following error,
    52528-error.png

    If I select "Net Core for Unit", then I see the following screen which VS 2019 attached the process successfully.
    52495-following-screen.png

    Now How can I interact with the main.cpp file in my linux machine using VS 2019?

    Can I continue the debugging process using VS 2019 for the running script in the linux machine ?

    Thank you

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.