2013-11-15 39 views

回答

1

如果您的程序已经编译了调试信息,那么是的,这是可能的。

例如,我编译test.cgcc -ggdb3 test.c -o test

然后,gdb ./test

(gdb) info functions 
All defined functions: 

File main.c: 
int main(int, char **); 

Non-debugging symbols: 
0x0000000000400370 _init 
0x00000000004003a0 [email protected] 
0x00000000004003b0 [email protected] 
0x00000000004003c0 _start 
0x00000000004003f0 deregister_tm_clones 
0x0000000000400420 register_tm_clones 
0x0000000000400460 __do_global_dtors_aux 
0x0000000000400480 frame_dummy 
0x00000000004004d0 __libc_csu_init 
0x0000000000400540 __libc_csu_fini 
0x0000000000400544 _fini 

(gdb) info sources 
Source files for which symbols have been read in: 

/home/john/Projects/test/main.c, /usr/include/bits/sys_errlist.h, ... 

Source files for which symbols will be read in on demand: 
1

这完全取决于体系结构,以及是否可执行文件在调试模式下(或类似的)编译。例如,UNIX系统将调试信息(包括文件名)嵌入到可执行文件本身中,而Windows将信息存储在单独的文件中(即,myprog.exe与所有调试信息相对应的myprog.pdb)。

+0

代码没有编译调试模式。 – Joshua

+0

在这种情况下,它可能没有任何源文件名。 –

相关问题