This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB 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]

gcc HEAD moves line number directives -- gcc bug?


This looks like another bug in gcc HEAD.  If you guys agree, I'll
file a bug report against gcc.

Here is some source code from gdb.mi/until.c:

  /* 20 */ main ()
  /* 21 */ {
  /* 22 */   int a = 1;
  /* 23 */   foo ();
  /* 24 */   a += 2;
  /* 25 */   return 0;
  /* 26 */ }

Here is the assembly code, gcc 3.3.1 -gdwarf-2 -S,
native i686-pc-linux-gnu:

  .globl main
          .type main, @function
  main:
  .LFB5:
          .loc 1 21 0
          pushl %ebp
  .LCFI3:
          movl  %esp, %ebp
  .LCFI4:
          subl  $8, %esp
  .LCFI5:
          andl  $-16, %esp
          movl  $0, %eax
          subl  %eax, %esp
          .loc 1 22 0
  .LBB3:
          movl  $1, -4(%ebp)
          .loc 1 23 0
          call  foo
          .loc 1 24 0
          leal  -4(%ebp), %eax
          addl  $2, (%eax)
          .loc 1 25 0
          movl  $0, %eax
          .loc 1 26 0
          leave
          ret
  .LBE3:
  .LFE5:
          .size main, .-main

Here is the assembly code, gcc HEAD -gdwarf-2 -S,
native i686-pc-linux-gnu:

  .globl main
          .type main, @function
  main:
  .LFB5:
          .loc 1 21 0
          pushl %ebp
  .LCFI3:
          movl  %esp, %ebp
  .LCFI4:
          subl  $8, %esp
  .LCFI5:
          andl  $-16, %esp
          movl  $0, %eax
          subl  %eax, %esp
          .loc 1 22 0
          movl  $1, -4(%ebp)
          .loc 1 23 0
          call  foo
          leal  -4(%ebp), %eax
          .loc 1 24 0
          addl  $2, (%eax)
          .loc 1 25 0
          movl  $0, %eax
          .loc 1 26 0
          leave
          ret
  .LFE5:
          .size main, .-main

Look at the code near 'call foo'.  In gcc 3.3.1, the .loc lines
match the source code.  In gcc HEAD, the .loc line for line 24
has migrated.

Source code:

  /* 23 */   foo ();
  /* 24 */   a += 2;

gcc 3.3.1 output:

          .loc 1 23 0
          call  foo
          .loc 1 24 0
          leal  -4(%ebp), %eax
          addl  $2, (%eax)

gcc HEAD output:

          .loc 1 23 0
          call  foo
          leal  -4(%ebp), %eax          // this insn is part of line 24
          .loc 1 24 0                   // this moved!
          addl  $2, (%eax)

This happens with explicit "-O0" in the command line.

This causes some mild confusion with gdb.  Specifically, an 'until'
command on foo returns and says it is on line 24 with gcc 3.3.1,
but on line 23 with gcc HEAD.

I isolated the patch that caused this:

  http://gcc.gnu.org/ml/gcc-patches/2003-06/msg00430.html
  Jan Hubicka - Line number handling in RTL reorganization

Do you think this is a bug in gcc?  I do, but I need to check here
before filing a bug report with gcc.

Michael C


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