I am programming in c++ using docker. Recently I tried to set up my GDB debugger in VSCode to help with some issues I was having and it turns out that was a bigger pain to do than I thought. I've gotten close but I keep getting the error Error: Unable to resolve non-existing file '/mnt/files/p5-student/src/main.cpp'. I'm not sure why this is happening.
I followed most of the instructions from this post, but I skipped a decent amount of steps because I don't want to create a new docker image, I just want to use one provided by my professor.
This is my launch.json:
{
"version": "0.2.0",
"configurations": [{
"name": "(gdb) Pipe Launch",
"type": "cppdbg",
"request": "launch",
"program": "/mnt/files/p5-student/main",
"cwd": "/mnt/files/p5-student",
"args": [],
"stopAtEntry": true,
"environment": [],
"externalConsole": true,
"pipeTransport": {
"debuggerPath": "/usr/bin/gdb",
"pipeProgram": "docker",
"pipeArgs": ["exec", "-i", "os_container", "sh", "-c"],
"pipeCwd": "${workspaceRoot}"
},
"MIMode": "gdb",
"setupCommands": [{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}]
}, ]
}
My code is stored in my docker container in /mnt/files/p5-student and our MakeFile creates an executable called main
This is tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "prepare to debug",
"type": "shell",
"command": "docker start -i os_container",
"group": "build",
"problemMatcher": []
}
]
}
I have an already created docker container, so I just want to start it with this task.
When I run the debugger I get the first local variable from main.cpp, but then VSCode hits me with Error: Unable to resolve non-existing file '/mnt/files/p5-student/src/main.cpp'