如何在命令行中使用addr2line [英] how to use addr2line in commandline

查看:1471
本文介绍了如何在命令行中使用addr2line的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用addr2line?
我有一个程序,它提供了在崩溃之前访问过的最后10个地址的回溯。但如果我使用这些地址addr2line喜欢

  addr2line -e test [address] 



它只是给我

  0 

是否有一种特殊的方法来编译使用addr2line,就像我们使用ggdb使用gdb? p>

解决方案

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

  $ gcc tc#未请求的调试信息
$ gdb ./a.out
。 。
(gdb)break main
断点1在0x400588
(gdb)q
$ addr2line -e a.out 0x400588
??:0#没有返回信息

$ gcc -g tc#请求的默认调试信息-g
$ addr2line -e a.out 0x400588
tc:4#line information returnedd
$


how to use addr2line? i have a program that gives the backtrace of last 10 addresses that it visited before crash. but if i use these address to addr2line like

addr2line -e test [address]

it just gives me

??:0

is there a special way to compile to use addr2line like we use ggdb to use gdb?

解决方案

You need to have some debugging information compiled in to your executable. e.g.

$ 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
$ 

这篇关于如何在命令行中使用addr2line的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆