I compile a program with gcc
. From VSCode
I open a font file, and I set a breakpoint.
Next, on the target machine, I launch the gdbserver
with the appropriate arguments. The debugger runs and waits for connections.
From VSCode
the debug view, I launch remote debugging. All correct, it connects to the gdbserver
.
As soon as the breakpoint is hit, the source file is closed , and the VSCode
displays the window with the warning:
Cannot open
nombre-del-archivo
: File not found (file:///full/path/to/the/file)
I'm building from a VM, where the project directory is correctly shared between Windows (host) and Linux (guest). From Linux, the shared folder (as shown in the image) is /media/sf_D_Drive
.
Of course, the file that supposedly doesn't exist is present:
How VSCode
do I get the source file to not close, or show the error window, when I reach the breakpoint?
EDIT
I just realized the problem: I compile from the VM, but VSCode
I'm running it from the host machine; the executable has the paths relative to the VM, while the paths on Windows (host) are different.
Path on Linux:/media/sf_D_DRIVE/CMS/Subversion/CORE_5G/src/com
Path on Windows:D:\CMS\Subversion\CORE_5G\src\com
File .vscode\launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdbserver) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/CFGP_bin_ConfigParam_cos",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "c:/cygwin64/bin/gdb.exe",
"miDebuggerServerAddress": "214.25.250.7:10000",
"targetArchitecture": "x86",
"linux": {
"MIMode": "gdb"
},
"windows": {
"MIMode": "gdb"
},
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
You must set the source path using
sourceFileMap
, as explained here:Locate font files .
You must add the following in
launch.json
:You
launch.json
will be like this: