2013-11-15 43 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

在這種情況下,它可能沒有任何源文件名。 –

相關問題