2012-02-06 72 views
2

這裏沒有設置斷點是我的代碼:爲什麼我可以的fopen在linux

#include <stdio.h> 
int main() 
{ 
    fopen("./1.txt","r"); 
    printf("hello"); 
    return 0; 
} 

$ G ++ -g -om的main.cpp

$gdb ./m 
(gdb) b fopen 
Breakpoint 1 at 0x804842c 
(gdb) b printf 
Breakpoint 2 at 0x804843c 
(gdb) i b 
Num  Type   Disp Enb Address What 
1  breakpoint  keep y 0x0804842c <[email protected]> 
2  breakpoint  keep y 0x0804843c <[email protected]> 
(gdb) r 

似乎斷點功能打開從來沒有工作,但在printf工作正常。 爲什麼?

由於

回答

4

它在GDB的一個錯誤,這似乎被固定在電流源CVS(作爲20120124)。

的問題是,有32位libc.so.6 版本fopen在Linux和GDB用來選擇錯誤:

nm -D /lib32/libc.so.6 | grep '\<fopen\>' 
0005d0c0 T fopen 
00109750 T fopen 

readelf -s /lib32/libc.so.6 | egrep '0005d0c0|00109750' 
181: 0005d0c0 50 FUNC GLOBAL DEFAULT 12 [email protected]@GLIBC_2.1 
182: 00109750 136 FUNC GLOBAL DEFAULT 12 [email protected]_2.0 
679: 0005d0c0 50 FUNC GLOBAL DEFAULT 12 [email protected]@GLIBC_2.1 
680: 00109750 136 FUNC GLOBAL DEFAULT 12 [email protected]_2.0 

如果您還main突破,並重復info break ,你會看到GDB在[email protected]_2.0上設置了斷點,但是調用的函數是[email protected]@GLIBC_2.1

+1

FWIW,'gdb-7.4'已於數週前發佈。 – 2012-02-06 05:46:56

+1

嗨,我已經提出了另一個問題庫的答案,謝謝。 http://stackoverflow.com/questions/9156414/why-lib32-libc-so-6-has-two-fopen-symbol-in-it – camino 2012-02-06 06:36:57

相關問題