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?
A backtrace is a summary of how your program got where it is. It shows one line per frame, for many frames, starting with the currently executing frame (frame zero), followed by its caller (frame one), and on up the stack. To print a backtrace of the entire stack, use the backtrace command, or its alias bt .
Check the source code of bsd implementation of addr2line, it has only about 400 lines code. Change the source to a library function should be very easy. http://sourceforge.net/p/elftoolchain/code/HEAD/tree/trunk/addr2line/addr2line.c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With