How to Launch and Debug WSL C++ Binary from Within Visual Studio

Viewed 370

I want to be able to launch and debug a WSL Linux binary from within Visual Studio.

EDIT:

Please note that I want to build within WSL, i.e. gcc -g test.cpp -o test and only use Visual Studio to launch and debug the binary. Ideally I would like something like: devenv.exe /debugexe <binary> for a Linux binary. This would probably equate to something like DebugAdapterHost.Launch /LaunchJson:c:\wsl\vs\launch.json inside the command-window.

Taking the approach from this article, the following is a launch.json that acheives this for .NET:

{
  "version": "0.2.0",
  "adapter": "c:\\tools\\plink.exe",
  "adapterArgs": "-ssh -pw <password> chrisnas@DBGDQPZ1 -batch -T ~/vsdbg/vsdbg --interpreter=vscode",
  "configurations": [
    {
      "name": ".NET Core Launch",
      "type": "coreclr",
      "cwd": "/mnt/d/wsl/TestConsole/TestConsole/bin/Debug/netcoreapp2.1/publish",
      "program": "TestConsole.dll",
      "request": "launch"
    }
  ]
}

I have seen articles that use GDBServer, however this a lot more cumbersome than the approach outlined above.

How could this be modified to work with C++?

0 Answers
Related