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

问题描述

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



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



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



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

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



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

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


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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-07 15:37