Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a library call to addr2line? [closed]

Tags:

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?

like image 792
steffen Avatar asked Jul 19 '12 07:07

steffen


People also ask

How do you analyze Backtrace?

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 .


1 Answers

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

like image 58
user416983 Avatar answered Jan 18 '23 18:01

user416983