Reputation: 5650
I have gdb attached to a process and just stopped at a function breakpoint. Unfortunately I can't see any source code since the mapping seems to be off.
The file it looks for reports as: ../../qpy/QtCore/qpycore_chimera.cpp
and the downloaded source resides in /home/user/debugging/pyqt5-5.4.2+dfsg/qpy/QtCore
.
No matter what I set as source mapping it won't open the file. What would be the correct syntax for a relative source mapping?
Upvotes: 5
Views: 5922
Reputation: 439
If you don't want to run the directory
gdb command for all the files, I've got a hack that works for me.
Say if your source path is ../../qpy/QtCore/qpycore_chimera.cpp
, and you have moved the source to /home/user/debugging/pyqt5-5.4.2+dfsg/qpy/QtCore
,
then try creating some dummy directory hierarchy $ mkdir -p /home/user/debugging/dir_1/dir_2
and run directory /home/user/debugging/dir_1/dir_2
in gdb.
This way in gdb, /home/user/debugging/dir_1/dir_2/
concatenated with ../../qpy/QtCore/qpycore_chimera.cpp
is /home/user/qpy/QtCore/qpycore_chimera.cpp
which is what you want.
In other more complex cases, I'm sure symbolic links will help (for my case as well).
Reference: https://sourceware.org/gdb/onlinedocs/gdb/Source-Path.html
For example, suppose an executable references the file /usr/src/foo-1.0/lib/foo.c, and our source path is /mnt/cross. The file is first looked up literally; if this fails, /mnt/cross/usr/src/foo-1.0/lib/foo.c is tried; if this fails, /mnt/cross/foo.c is opened; if this fails, an error message is printed. GDB does not look up the parts of the source file name, such as /mnt/cross/src/foo-1.0/lib/foo.c. Likewise, the subdirectories of the source path are not searched: if the source path is /mnt/cross, and the binary refers to foo.c, GDB would not find it under /mnt/cross/usr/src/foo-1.0/lib.
Plain file names, relative file names with leading directories, file names containing dots, etc. are all treated as described above; for instance, if the source path is /mnt/cross, and the source file is recorded as ../lib/foo.c, GDB would first try ../lib/foo.c, then /mnt/cross/../lib/foo.c, and after that—/mnt/cross/foo.c.
Upvotes: 1