gpt4 book ai didi

gdb - 如何为相对路径设置 gdb 源映射

转载 作者:行者123 更新时间:2023-12-03 20:19:36 25 4
gpt4 key购买 nike

我将 gdb 附加到一个进程,并在函数断点处停止。
不幸的是,我看不到任何源代码,因为映射似乎已关闭。

它查找的文件报告为:../../qpy/QtCore/qpycore_chimera.cpp下载的源代码位于/home/user/debugging/pyqt5-5.4.2+dfsg/qpy/QtCore .

无论我将什么设置为源映射,它都不会打开文件。相对源映射的正确语法是什么?

最佳答案

如果您不想运行 directory所有文件的 gdb 命令,我有一个适合我的 hack。

假设您的源路径是 ../../qpy/QtCore/qpycore_chimera.cpp ,并且您已将源移至 /home/user/debugging/pyqt5-5.4.2+dfsg/qpy/QtCore ,

然后尝试创建一些虚拟目录层次结构$ mkdir -p /home/user/debugging/dir_1/dir_2并运行 directory /home/user/debugging/dir_1/dir_2在 gdb 中。

这种方式在 gdb 中,/home/user/debugging/dir_1/dir_2/../../qpy/QtCore/qpycore_chimera.cpp 连接是 /home/user/qpy/QtCore/qpycore_chimera.cpp这就是你想要的。

在其他更复杂的情况下,我确信符号链接(symbolic link)会有所帮助(对于我的情况也是如此)。

引用:
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.

关于gdb - 如何为相对路径设置 gdb 源映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37330688/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com