not finding the source files despite setting the sourceFileMap correctly
Katze719 opened this issue · comments
If submitting a bug please make sure
- If you are using gdb
-
gdb --version
>= 7.7.1 - it works on the command line with
gdb
-
cwd
andtarget
are properly set
-
- If you are using lldb
-
lldb --version
>= 3.7.1 - it works on the command line with
lldb-mi
-
cwd
andtarget
are properly set
-
Im trying to use the breakpoints but the execution is not stopping and im getting the errors that my source files are not found. I have looked through various Issues here addressing a similiar or even the same issues but none of the solutions worked for me.
could someone help me understand my problem, please thank you
{
"version": "0.2.0",
"configurations": [
{
"type": "gdb",
"request": "launch",
"name": "launch debug",
"target": "./build/test",
"preLaunchTask": "scp_files_to_remote",
// "stopAtEntry": true,
"printCalls": true,
"showDevDebugOutput": true,
"internalConsoleOptions": "openOnSessionStart",
"cwd": "${workspaceRoot}",
"valuesFormatting": "prettyPrinters",
"ssh": {
"sudo": "true",
"host": "169.254.245.107", // ip von remote
"user": "pi",
"password": "********",
"cwd": "/home/pi/rpitestadv",
"sourceFileMap": {
"/home/pi/rpitestadv": "${workspaceRoot}"
},
"forwardX11": false,
"x11host": "localhost",
"x11port": 6000
}
}
]
}
LOG =>
Running gdb over ssh...
1-gdb-set target-async on
2-list-features
3-environment-directory "/home/pi/rpitestadv/"
4-file-exec-and-symbols "/home/pi/rpitestadv/build/test"
5-enable-pretty-printing
6-environment-cd "/home/pi/rpitestadv/"
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-group-added","output":[["id","i1"]]}]}
GDB -> App: {"token":1,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
GDB -> App: {"token":2,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["features",["frozen-varobjs","pending-breakpoints","thread-info","data-read-memory-bytes","breakpoint-notifications","ada-task-info","language-option","info-gdb-mi-command","undefined-command-error-code","exec-run-start-option","data-disassemble-a-option","python"]]]}}
GDB -> App: {"token":3,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["source-path","/home/pi/rpitestadv:$cdir:$cwd"]]}}
GDB -> App: {"token":4,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
GDB -> App: {"token":5,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
GDB -> App: {"token":6,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
7-break-insert -f "/home/pi/rpitestadv/src/main.cpp:8"
8-break-insert -f "/home/pi/rpitestadv/src/test.cpp:4"
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"log","content":"No source file named /home/pi/rpitestadv/src/main.cpp.\n"}]}
No source file named /home/pi/rpitestadv/src/main.cpp.
GDB -> App: {"token":7,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["bkpt",[["number","1"],["type","breakpoint"],["disp","keep"],["enabled","y"],["addr","<PENDING>"],["pending","/home/pi/rpitestadv/src/main.cpp:8"],["times","0"],["original-location","/home/pi/rpitestadv/src/main.cpp:8"]]]]}}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"log","content":"No source file named /home/pi/rpitestadv/src/test.cpp.\n"}]}
No source file named /home/pi/rpitestadv/src/test.cpp.
GDB -> App: {"token":8,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["bkpt",[["number","2"],["type","breakpoint"],["disp","keep"],["enabled","y"],["addr","<PENDING>"],["pending","/home/pi/rpitestadv/src/test.cpp:4"],["times","0"],["original-location","/home/pi/rpitestadv/src/test.cpp:4"]]]]}}
Running executable
9-exec-run
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-group-started","output":[["id","i1"],["pid","1198"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-created","output":[["id","1"],["group-id","i1"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"library-loaded","output":[["id","/lib/ld-linux-aarch64.so.1"],["target-name","/lib/ld-linux-aarch64.so.1"],["host-name","/lib/ld-linux-aarch64.so.1"],["symbols-loaded","0"],["thread-group","i1"],["ranges",[[["from","0x0000007ff7fbed80"],["to","0x0000007ff7fda5b4"]]]]]}]}
GDB -> App: {"token":9,"outOfBandRecord":[],"resultRecords":{"resultClass":"running","results":[]}}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"running","output":[["thread-id","all"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"library-loaded","output":[["id","/lib/aarch64-linux-gnu/libstdc++.so.6"],["target-name","/lib/aarch64-linux-gnu/libstdc++.so.6"],["host-name","/lib/aarch64-linux-gnu/libstdc++.so.6"],["symbols-loaded","0"],["thread-group","i1"],["ranges",[[["from","0x0000007ff7e10670"],["to","0x0000007ff7f145f0"]]]]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"library-loaded","output":[["id","/lib/aarch64-linux-gnu/libgcc_s.so.1"],["target-name","/lib/aarch64-linux-gnu/libgcc_s.so.1"],["host-name","/lib/aarch64-linux-gnu/libgcc_s.so.1"],["symbols-loaded","0"],["thread-group","i1"],["ranges",[[["from","0x0000007ff7d429d0"],["to","0x0000007ff7d507b0"]]]]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"library-loaded","output":[["id","/lib/aarch64-linux-gnu/libc.so.6"],["target-name","/lib/aarch64-linux-gnu/libc.so.6"],["host-name","/lib/aarch64-linux-gnu/libc.so.6"],["symbols-loaded","0"],["thread-group","i1"],["ranges",[[["from","0x0000007ff7bb6a00"],["to","0x0000007ff7cc4a30"]]]]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"library-loaded","output":[["id","/lib/aarch64-linux-gnu/libm.so.6"],["target-name","/lib/aarch64-linux-gnu/libm.so.6"],["host-name","/lib/aarch64-linux-gnu/libm.so.6"],["symbols-loaded","0"],["thread-group","i1"],["ranges",[[["from","0x0000007ff7aeca50"],["to","0x0000007ff7b32f50"]]]]]}]}
10-thread-info
11-thread-info
GDB -> App: {"token":10,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","process 1198"],["name","test"],["state","running"],["core","1"]]]],["current-thread-id","1"]]}}
GDB -> App: {"token":11,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","process 1198"],["name","test"],["state","running"],["core","1"]]]],["current-thread-id","1"]]}}
1
2
3
4
5
6
7
2
Hello World!
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"[Inferior 1 (process 1198) exited normally]\n"}]}
[Inferior 1 (process 1198) exited normally]
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-exited","output":[["id","1"],["group-id","i1"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-group-exited","output":[["id","i1"],["exit-code","0"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"stopped","output":[["reason","exited-normally"]]}]}
-gdb-exit
GDB -> App: {"outOfBandRecord":[],"resultRecords":{"resultClass":"exit","results":[]}}
i can definitely find the files as you can see here =>
pi@raspberrypi:~ $ cat /home/pi/rpitestadv/src/main.cpp
#include <iostream>
#include <vector>
#include "test.h"
int main(int argc, char const *argv[])
{
std::vector<int> v = {1,2,3,4,5,6,7};
v.push_back(2);
int a = add(2,6);
for(auto& e:v){
std::cout << e << std::endl;
}
std::cout<< "Hello World!" << std::endl;
return 0;
}
Hi @Katze719, there are a couple different things to check.
First, make sure you're compiling with debug information included (e.g., "-g"). If you aren't, this will prevent breakpoints from being set.
Next, if that checks out, find out what the source path is in the embedded debug information for the "main" routine. To do that, you can use "nm" with the "-l" option to output line numbers. This will also output the source path as well. It's this source path you're trying to match with your path mapping.
nm -l <executable> | grep -i main
thank you for the quick answer
debug information is on via -g
the ouput for nm -l <executable> | grep -i main
is
0000000000000e94 t $x /mnt/d/testing/debugging/rpitestadv/src/main.cpp:7
00000000000010b0 t _GLOBAL__sub_I_main
0000000000001050 t _Z41__static_initialization_and_destruction_0ii /mnt/d/testing/debugging/rpitestadv/src/main.cpp:16
U __libc_start_main@GLIBC_2.34
0000000000000e94 T main /mnt/d/testing/debugging/rpitestadv/src/main.cpp:6
/mnt/d/testing/debugging/rpitestadv
equals my ${workspaceRoot}
what else could be the problem?
im confused now, using =>
"sourceFileMap": {
"${workspaceRoot}": "${workspaceRoot}"
},
fixed it for me
full file =>
{
"version": "0.2.0",
"configurations": [
{
"type": "gdb",
"request": "launch",
"name": "launch debug",
"target": "./build/test",
"preLaunchTask": "sync_files_to_remote",
// "stopAtEntry": true,
"printCalls": true,
"showDevDebugOutput": true,
"internalConsoleOptions": "openOnSessionStart",
"cwd": "${workspaceRoot}",
"valuesFormatting": "prettyPrinters",
"ssh": {
"sudo": "true",
"host": "169.254.245.107", // ip von remote
"user": "pi",
"password": "raspberry",
"cwd": "/home/pi/rpitestadv",
"sourceFileMap": {
"${workspaceRoot}": "${workspaceRoot}"
},
"forwardX11": false,
"x11host": "localhost",
"x11port": 6000
}
}
]
}
but it is still saying file not found when reaching a breakpoint
Breakpoint 2, add (x=2, y=6) at /mnt/d/testing/debugging/rpitestadv/src/test.cpp:4
4 /mnt/d/testing/debugging/rpitestadv/src/test.cpp: No such file or directory.
im confused now, using =>
"sourceFileMap": { "${workspaceRoot}": "${workspaceRoot}" },fixed it for me
Are you building locally and then pushing the executable and source to the raspberry pi? If so, that makes sense as the paths embedded in the debug information will be your local path. In that case, you likely don't need a source file mapping in the SSH portion at all.
but it is still saying file not found when reaching a breakpoint
Breakpoint 2, add (x=2, y=6) at /mnt/d/testing/debugging/rpitestadv/src/test.cpp:4 4 /mnt/d/testing/debugging/rpitestadv/src/test.cpp: No such file or directory.
From the previous comments above, I assume it's working fine in VSCode, but you're having the nuisance message being emitted from GDB. If that's the case, then you can try telling GDB what the mapping is on the remote side, using pathSubstitutions
.
{
"version": "0.2.0",
"configurations": [
{
"type": "gdb",
"request": "launch",
"name": "launch debug",
"target": "./build/test",
"preLaunchTask": "sync_files_to_remote",
// "stopAtEntry": true,
"printCalls": true,
"showDevDebugOutput": true,
"internalConsoleOptions": "openOnSessionStart",
"cwd": "${workspaceRoot}",
"valuesFormatting": "prettyPrinters",
"pathSubstitutions": {
"${workspaceRoot}": "/home/pi/rpitestadv"
"ssh": {
"sudo": "true",
"host": "169.254.245.107", // ip von remote
"user": "pi",
"password": "raspberry",
"cwd": "/home/pi/rpitestadv"
},
"forwardX11": false,
"x11host": "localhost",
"x11port": 6000
}
}
]
}
If you still have trouble after this, you can experiment changing the embedded path prefix in the debug information with the -fdebug-prefix-map
compilation option.
@brownts thank you for your quick and very professional help. All my problems are solved, thank you.
Are you building locally and then pushing the executable and source to the raspberry pi? If so, that makes sense as the paths embedded in the debug information will be your local path. In that case, you likely don't need a source file mapping in the SSH portion at all.
yes, i am building (cross compiling) locally and then pushing the files to the raspberry pi