I am trying to debug an application that is cross-compiled on a Windows host for a Linux target.
The problem:
Because the initial compilation is in windows the stored source file paths in the binary is of the form C:\Users\foo\project\...
. On the Linux target I have put the source files under \home\foo\project\....
By default gdb does not find the source file because of the different path.
What I have tried so far:
Use "directory" command in gdb to give an exact path for the .c source file in the target Linux system where the app is being debugged. This works but unfortunately there are literally hundreds of files so this solution is unrealistic.
Use the
set substitute-path C:\\Users\\foo\\project /home/foo/project
command to have gdb substitute all prefixes. Note that the\\
seems necessary such thatshow substitute-path
registers the right string. This unfortunately does not work. My guess is that the substitute-path command does not handle ms-dos style paths.Tried separating the debug info out into a separate .debug file (see How to generate gcc debug symbol outside the build target?) and then using debugedit to change the paths with the command
debugedit --base-dir=C:\Users\foo --dest-dir=/home/foo project.debug
. Unfortunately this does not work either.debugedit
seems to work fine if the existing path is all UNIX/Linux like but doesn't seem to work with ms-dos style paths.
I have looked around stackoverflow and while there are similar topics I can't find anything that will help me. Would really appreciate any suggestions/help. I realize that cross compiling from Windows is a very roundabout way but can't avoid that for the moment.
Thanks