[Bug c/58283] New: Incorrect debug info when precompilation is on

jengelh at inai dot de gcc-bugzilla@gcc.gnu.org
Fri Aug 30 16:02:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58283

            Bug ID: 58283
           Summary: Incorrect debug info when precompilation is on
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jengelh at inai dot de

Created attachment 30731
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30731&action=edit
testcase

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/4.7/lto-wrapper
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,java,ada
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.7
--enable-ssp --disable-libssp --disable-libitm --disable-plugin
--with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux'
--disable-libgcj --disable-libmudflap --with-slibdir=/lib64 --with-system-zlib
--enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch
--enable-version-specific-runtime-libs --enable-linker-build-id
--program-suffix=-4.7 --enable-linux-futex --without-system-libunwind
--with-arch-32=i586 --with-tune=generic --build=x86_64-suse-linux
Thread model: posix
gcc version 4.7.2 20130108 [gcc-4_7-branch revision 195012] (SUSE Linux) 

GNU ld (GNU Binutils; openSUSE 12.3) 2.23.1


Testcase is appended. What I observe with it:

$ make
gcc-4.8 -gdwarf-2 -g3 -O0 -DPRECOMP -o pc1.h.gch -c pc1.h
gcc-4.8 -gdwarf-2 -g3 -O0 -DPRECOMP -o x m.c
nm -C x | grep main
                 U __libc_start_main
0000000000400560 T main
addr2line -e x $(nm -C x | grep ' main$' | awk '{print $1}')
/usr/include/stdio.h:947

What I would have expected:
Have addr2line return m.c:3.

Additional information:
I do get addr2line to output "m.c:3" if I include "pc1.h" instead of "pc.h"
from m.c. So this problem seems to be related with headers including
(precompiled) headers. In fact, gcc-4.7.2 even ignored pc1.h.gch (itself a bug,
or a non-implemented feature) if m.c includes pc.h, which means I don't get
wrong line numbers on gcc-4.7.

The outputting of wrong line numbers also occurs if compiled as C++ code.



More information about the Gcc-bugs mailing list