GDB无法在共享库

时间:2016-07-22 12:17:02

标签: c macos debugging gcc gdb

我正在尝试调试加载共享库的程序。我可以完美地调试主程序部分,但是在共享库中,我遇到了一些问题。

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。我用&#34; -Og -ggdb -g3&#34;编译了主程序和共享库。标志。

1 个答案:

答案 0 :(得分:1)

我已经通过降级到gdb 6.3.50解决了我的问题。

基本上,我已经从macports安装了gdb-apple,它基于gdb 6.3.50。我不知道它是否与gdb版本有关,或者gdb-apple端口有一些调整可以使它工作。