This is the mail archive of the mailing list for the elfutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

bfd_find_inliner_info reports different (wrong) information compared to GDB - off-by-one?


I'm trying to improve Linux perf report by adding inliner information to the 
callstacks it reports, to make the output more easily interpretable when 
looking at complicated C++ applications.

I have a proof of concept locally using bfd_find_inliner_info, but have 
noticed the following seemingly broken behavior:

Input file:
#include <cstdlib>
#include <iostream>
#include <complex>

int main(int argc, char** argv)
    double a = 0;
    double b = 0;
    if (argc > 1)
        a = atof(argv[1]);
    if (argc > 2)
        b = atof(argv[2]);
    auto c = std::complex<double>(a, b);
    std::cout << std::abs(c) << std::endl;

I build it with:

$ g++ -g -O2 -o test test.cpp

Then I get a "good" backtrace using GDB:

$ gdb ./test
(gdb) break hypot
Function "hypot" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (hypot) pending.
(gdb) run
Starting program: /tmp/test 

Breakpoint 1, 0x00007ffff776e910 in hypot () from /usr/lib/
(gdb) bt
#0  0x00007ffff776e910 in hypot () from /usr/lib/
#1  0x00000000004007f4 in std::__complex_abs (__z=<optimized out>) at /usr/
#2  std::abs<double> (__z=<synthetic pointer>) at /usr/include/c++/6.2.1/
#3  main (argc=<optimized out>, argv=<optimized out>) at test.cpp:14

Note what inliners it reports for the address 0x00000000004007f4. Let's try 
bfd_find_inliner_info via eu-addr2line -i:

eu-addr2line -i -a 0x00000000004007f4 -e ./test

This is wrong and seems to be off-by-one:

eu-addr2line -i -a 0x00000000004007f3 -e ./test

Can someone with more knowledge in this area sched some light on what is going 
on here please? Is it a bug, or is this fuzzy behavior and GDB happens to be 
better at guessing the "right" thing?

Some system info:
linux 4.7.2-1-ARCH
eu-addr2line 0.167
g++ 6.2.1
gdb 7.11.1


Milian Wolff

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]