2011-05-16 139 views
1

如何使用addr2line? 我有一个程序,给出了它在崩溃之前访问的最后10个地址的回溯。但是,如果使用这些地址addr2line像如何在命令行中使用addr2line

addr2line -e test [address] 

它只是给我

??:0 

有编译就像我们使用ggdb使用gdb来使用addr2line一种特殊的方式?

回答

3

您需要将一些调试信息编译到您的可执行文件中。例如

$ gcc t.c       # debug information not requested 
$ gdb ./a.out 
... 
(gdb) break main 
Breakpoint 1 at 0x400588 
(gdb) q 
$ addr2line -e a.out 0x400588 
??:0        # no information returned 

$ gcc -g t.c      # default debug information requested with -g 
$ addr2line -e a.out 0x400588  
t.c:4        # line information returnedd 
$