[Bug debug/19192] New: Current development gcc generates incorrect line info for example code

gcc-bugzilla at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Wed Dec 29 17:42:00 GMT 2004



For the supplied example, the current development gcc generates
incorrect line number information for one instruction from the inlined
subroutine.  The Fedora Core 3 gcc, which identifies itself as "gcc
version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)", generates correct line
information.

Environment:
System: Linux toadfish.ninemoons.com 2.6.9-1.681_FC3.stk16 #1 Mon Nov 22 16:44:32 EST 2004 i686 i686 i386 GNU/Linux
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /src/sourceware/gcc/gcc/configure -v --prefix=/opt/local/sourceware --with-gcc-version-trigger=/src/sourceware/gcc/gcc/gcc/version.c --enable-languages=c,c++

How-To-Repeat:

For the follow code:

  /*  1 */  int add2 (int a, int b)
  /*  2 */  {
  /*  3 */    return (a + b);
  /*  4 */  }
  /*  5 */  
  /*  6 */  inline int add3 (int a, int b, int c)
  /*  7 */  {
  /*  8 */    return (a + add2 (b , c));
  /*  9 */  }
  /* 10 */  
  /* 11 */  main ()
  /* 12 */  {
  /* 13 */    printf ("%d\n", add3 (2, 3, 4));
  /* 14 */  }

Run:

  gcc -g -O2 --save-temps -o t t.c
  readelf --debug-dump t >t.dwarf
  objdump --disassemble t >t.dis

There relevant line table entries from t.dwarf are:

  Special opcode 36: advance Address by 2 to 0x80483a0 and Line by 3 to 12
  Special opcode 15: advance Address by 1 to 0x80483a1 and Line by -4 to 8
  Special opcode 79: advance Address by 5 to 0x80483a6 and Line by 4 to 12
  Special opcode 75: advance Address by 5 to 0x80483ab and Line by 0 to 12
  Special opcode 85: advance Address by 6 to 0x80483b1 and Line by -4 to 8
  Special opcode 234: advance Address by 16 to 0x80483c1 and Line by 5 to 13
  Advance PC by constant 17 to 0x80483d2
  Special opcode 34: advance Address by 2 to 0x80483d4 and Line by 1 to 14
  Advance PC by 2 to 80483d6

I've annotated the disassembly of main() with the line numbers given by
the above entries:

    12      080483a0 <main>:
    12       80483a0:       55                      push   %ebp
     8       80483a1:       b8 04 00 00 00          mov    $0x4,%eax
    12       80483a6:       89 e5                   mov    %esp,%ebp
    12       80483a8:       83 ec 08                sub    $0x8,%esp
    12       80483ab:       83 e4 f0                and    $0xfffffff0,%esp
    12       80483ae:       83 ec 10                sub    $0x10,%esp
     8       80483b1:       89 44 24 04             mov    %eax,0x4(%esp)
     8       80483b5:       c7 04 24 03 00 00 00    movl   $0x3,(%esp)
     8       80483bc:       e8 af ff ff ff          call   8048370 <add2>
    13       80483c1:       c7 04 24 c8 84 04 08    movl   $0x80484c8,(%esp)
 ** 13       80483c8:       83 c0 02                add    $0x2,%eax
    13       80483cb:       89 44 24 04             mov    %eax,0x4(%esp)
    13       80483cf:       e8 dc fe ff ff          call   80482b0 <printf@plt>
    14       80483d4:       c9                      leave  
    14       80483d5:       c3                      ret    

The "add $0x2,%eax" instruction, marked with '**', is supposed to be at
line 8, not line 13.      

If you go through the same exercise with the Fedora Core 3 compiler, it does
correctly identify this instruction as being at line 8.

-- 
           Summary: Current development gcc generates incorrect line info
                    for example code
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fnf at specifixinc dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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



More information about the Gcc-bugs mailing list