This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: addr2line ends up off by 1 line numbers when -O0 is used
- From: Britton Kerin <britton dot kerin at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 17 Mar 2016 14:43:20 -0800
- Subject: Re: addr2line ends up off by 1 line numbers when -O0 is used
- Authentication-results: sourceware.org; auth=none
- References: <CAC4O8c9ET7xbvfYA5J1dgineV3611ZbU00yLuDCeJyvF3uWdPQ at mail dot gmail dot com>
On Thu, Mar 17, 2016 at 2:15 PM, Britton Kerin <britton.kerin@gmail.com> wrote:
> I'm not sure whether to blame libc (backtrace() function) or gcc or
> addr2line, but
> if I dump the pointers from backtrace() to address_file then use
>
> addr2line -e my_exe -f -i <address_file >call_locations
>
> to recover the line numbers, the line numbers are off by 1 statement
> for some stack frames when -O0 has been used, but not if -O2 has been
> used at compile time.
>
> The documentation for backtrace() suggests that things should work
> better with -O0 but I seem
> to get the opposite.
>
> I'm on gcc 4.8.1, addr2lines binutils 2.26 and libc 2.11.3-4 debian package:
> $ ldd --version
> ldd (Debian EGLIBC 2.11.3-4) 2.11.3
One addtional bit of info: this issue doesn't seem to be
-fomit-frame-pointer related. I thought it might be after more
searching around, since -O>0 apparently activates this feature, making
stack unwinding more complex. But adding -fomit-frame-pointer neither
fixes the problem when -O0 is used, nor causes it when -O2 is used.
Britton