Skip to content

Mapping source files during gdb remote debugging. #826

@nikitablack

Description

@nikitablack

Hello. I'm trying to remotely debug an executable in a docker container. I'm starting a gdbserver localhost:2222 ./app in the docker. And this is how my launch.json looks like:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) remote debug",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/build/bin/app",
            "debugServerArgs": "dir ${workspaceRoot}/src",
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerServerAddress": "localhost:2222",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

The application starts, gdbserver reports me that remote session from the host begins, but I'm not able to hit a breakpoint because gdb can't find source files - paths in docker and host are different and gdb searches in the wrong directory. Please notice in launch.json I added debugServerArgs option but it didn't help. How else can I substitute paths?

Upd: I found that if host and docker have identical paths to the source everything works.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions