Skip to content

Instantly share code, notes, and snippets.

@vfdev-5
Last active March 5, 2020 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vfdev-5/6577a2d786ae73362f36e02c55fa298d to your computer and use it in GitHub Desktop.
Save vfdev-5/6577a2d786ae73362f36e02c55fa298d to your computer and use it in GitHub Desktop.
How to remotely debug C++ program from VSCode

How to remotely debug C++ program from VSCode

Good references:

The setup:

  • Local: MacOSX
  • Remote: Ubuntu 16.04 in Docker

Local

  • install gdb --with-all-targets
  • sign gdb
  • setup vscode .launch as in vscode-cpp-remote-debug

Remote

Launch docker with option

--security-opt seccomp:unconfined

moby/moby#21051 (comment)

Inside the container:

gdbserver :1234 build/app_to_debug

Example of launh.json

    {
        "name": "(gdb) cpp-app",
        "type": "cppdbg",
        "request": "launch",
        "program": "${workspaceRoot}/project/app/build/app_to_debug",
        "miDebuggerServerAddress": "0.0.0.0:1234",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceRoot}",
        "sourceFileMap": {
          "/home/project/app/": "${workspaceRoot}/project/app"
        },
        "environment": [],
        "externalConsole": true,
        "linux": {
          "MIMode": "gdb"
        },
        "osx": {
          "MIMode": "gdb"
        },
        "windows": {
          "MIMode": "gdb"
        }
    },  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment