2016-07-22 138 views
1

我正在嘗試調試加載共享庫的程序。我可以完美地調試主程序部分,但在共享庫中,我遇到了一些問題。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從homebrew。我用「-Og -ggdb -g3」標誌編譯了主程序和共享庫。

回答

1

我已經通過降級到gdb 6.3.50解決了我的問題。

基本上,我已經從macports安裝gdb-apple,它基於gdb 6.3.50。我不知道它是否與gdb版本有關,或者gdb-apple port有一些調整它的工作。