getting the line of a function when walking the stack with libbfd
Vincent Torri
vincent.torri@gmail.com
Sat Mar 24 09:43:00 GMT 2012
Hey
On Fri, Mar 23, 2012 at 10:24 AM, Alan Modra <amodra@gmail.com> wrote:
> On Fri, Mar 23, 2012 at 08:47:25AM +0100, Vincent Torri wrote:
>> Is there a way to get the frames with libbfd?
>
> No. It's not hard to write for one ABI. For example, see
> glibc/debug/backtrace.c.
I have modified the code a bit to create a shared lib and a test
program (see attached archive). All the tests below are done in linux
(arch: i686, in case it's important)
i've tested a bit, using addr2line with the addresses that the glibc
code returns. It's not perfect, it even depends on the optimization
flag I pass.
In the test program (it's actually the backtrace test program of
glibc) , there are 2 functions: compress() (which calls the backtrace
function) and main() which calls compare()
If I pass no optimization flag:
1) the line returned by addr2line with the first address is the line
where the backtrace function is called, so it's good.
2) the line returned by addr2line with the second address is *not* the
line where the compress() function is called (compress() is called 2
line below.)
If I pass -O2:
1) the line returned by addr2line with the first address is *not* the
line where the backtrace function is called (backtrace() is called 1
line below.)
2) the line returned by addr2line with the second address is the line
where the compress() function is called, so it's good.
Is it normal to not get the correct lines ?
Vincent
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bt.tar.bz2
Type: application/x-bzip2
Size: 2089 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20120324/22e1ee7a/attachment.bz2>
More information about the Binutils
mailing list