Hello,
I am writing an application which involves obtaining a backtrace, so I tried to find an
easy way to get the backtrace for the running program. I used the glibc backtrace()
function to get the return addresses from the stack. However, I need to convert those
addresses into meaningful information (such as function name, file name and line number).
I tried to use the addr2line code, but ran into problems when using dynamically loaded
libraries, because the addresses (the one returned by backtrace(), and the actual address
in the library -- the one returned by gdb, for instance) didn't match.
I also noticed that the libbfd documentation suggested libdwarf as a better solution for
new programs, so I would like to use this library to get information from those addresses.
I looked over libdwfl.h, and saw that it contains functions which could make my work
easier. However, information about this library is pretty hard to find (at least for me),
so I was hoping you could point me in the right direction. If you don't know of a
tutorial either, could you please give some tips and starting points? I'd be happy to
write a tutorial about what I've learned once I figure it out, which could then help
other users.
Or maybe someone knows a better way to do this?
Thanks,
Mihai