linuxvisual-studio-codegdbgdbserver

How to configure json file in VScode to remote debugging?


I would like to have a remote option to debug application. For this purpose, I created the "launch.json" file from the following configuration:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "gdb",
            "request": "attach",
            "name": "Attach to gdbserver",
            "executable": "/home/jakub/repo/app/build/app",
            "target": "193.168.100.1:2345",
            "remote": true,
            "cwd": "/home/jakub/repo/app", 
            "gdbpath": "/home/jakub/repo/ext-toolchain/bin/arm-linux-gnueabihf-gdb",
            "autorun": [
                    "info break"
                ]
        }
    ]
}

First I start GDB Server on the arm board:

# gdbserver :2345 app
Process app created; pid = 173
Listening on port 2345

then the debugger fires in the vscode but nothing happens, no errors or reaction. I have available only pause, restart and disconnect buttons. The program is definitely correctly built to Debug because I am able to connect through GDB consoles


Solution

  • It should work with this launch configuration:

    {
        "name": "Attach to gdbserver",
        "type": "cppdbg",
        "request": "launch",
        "program": "/home/jakub/repo/app/build/app",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceRoot}",
        "environment": [],
        "externalConsole": true,
        "MIMode": "gdb",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ],
        "miDebuggerServerAddress": "193.168.100.1:2345",
        "miDebuggerPath": "/home/jakub/repo/ext-toolchain/bin/arm-linux-gnueabihf-gdb"
    }
    

    After running: gdbserver localhost:2345 app

    It may take a few seconds for everything to connect.