2012-02-06 95 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

相关问题