【发布时间】:2016-11-26 08:16:06
【问题描述】:
我正在尝试调试一个加载共享库的程序。我可以完美地调试主程序部分,但是在共享库中,我遇到了一些问题。
gdb -p 70876
GNU gdb (GDB) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin15.5.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Attaching to process 70876
Reading symbols from /usr/local/pgsql/bin/postgres...done.
0x00007fff9496a2a2 in poll () from /usr/lib/system/libsystem_kernel.dylib
(gdb) b multi_ProcessUtility
Breakpoint 1 at 0xdaa9: multi_ProcessUtility. (2 locations)
(gdb) b multi_utility.c:129
Cannot access memory at address 0xdaa9
(gdb)
所以,问题是,我可以用方法名本身设置一个断点,然后程序在指定的点停止。但是,我无法使用文件名和行号设置断点。 (指定的文件名和行号也涉及相同的功能)
当程序在共享库函数中停止时,运行info source 命令结果与No current source file. 消息
在我附加到进程时,共享库已加载并运行。
我在 Mac OS X El Capitan 上,使用自制软件中的 GNU GCC 6 和 GDB 7.11.1。我已经用“-Og -ggdb -g3”标志编译了主程序和共享库。
【问题讨论】: