是否有一个库调用addr2line? [英] Is there a library call to addr2line?

查看:299
本文介绍了是否有一个库调用addr2line?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从C ++程序中获取addr2line(从回调函数调用的文件和行)提供的信息。是否有类似于addr2line的库调用?



编辑:我在Linux环境中工作。



我知道我可以直接调用addr2line,我知道我可以使用源代码 addr2line在我的程序(这也是GPL许可)。但我想调用一个库函数,如果它存在的话,更干净。



编辑:我将使用binutils的bfd,就像addr2line是的。

您可以尝试 dladdr()

c>。它使用程序的动态符号,而不是调试信息(使用 gcc -rdynamic 编译程序)。



此外,您还可以检查 backtrace 库,或更高级别 stacktrace 库。

不完全是您要求的,但它们可能是有用的。


I need to get the information provided by addr2line (file and line from backtracing a function call) from within a C++ program. Is there a library call similar to addr2line?

edit: I am working in a Linux environment.

I know I can call addr2line directly and I know that I can use the source code of addr2line in my program (which is also GPL licensed). But I guess calling a library function, if it exists, is cleaner.

edit: I will use bfd of the binutils, just as addr2line does. What does bfd mean anyway?

解决方案

You can try the function dladdr(). It uses the dynamic symbols of the program, not the debugging information (compile the program with gcc -rdynamic).

Also, you can check the backtrace library, or the higher level stacktrace library.
Not exactly what you are asking, but they may prove useful.

这篇关于是否有一个库调用addr2line?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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