This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug debug/13974] New: [3.4/3.5 regression] bad line marker in debug info


A line marker moved to a bad place in the instruction stream (or, relatively, an
instruction moved to a bad place with respect to the line numbers).  This is a
regression from gcc 3.3.2 to gcc gcc-3_4-branch / gcc HEAD.

The test program is:

  void foo ()
  {
    ;
  }

  int main ()
  {
    int a = 1;
    foo ();
    a += 2;
    return 0;
  }

My compile command is "gcc -gdwarf-2 -S".

With gcc 3.3.2, the output is:

        .loc 1 8 0
  .LBB2:
        movl    $1, -4(%ebp)
        .loc 1 9 0
        call    foo
        .loc 1 10 0
        leal    -4(%ebp), %eax
        addl    $2, (%eax)

With gcc HEAD, the output is:

        .loc 1 8 0
        movl    $1, -4(%ebp)
        .loc 1 9 0
        call    foo
        leal    -4(%ebp), %eax
        .loc 1 10 0
        addl    $2, (%eax)

The leal instruction has migrated before the ".loc 1 10 0" location marker.

If the user executes "jump 10" in gdb, then the gcc HEAD version will fail.
Like this:

  gdb a.out
  (gdb) break 9
  (gdb) break 11
  (gdb) run
  (gdb) jump 10
  (gdb) print a

The "jump 10" will fail with gcc HEAD because the "leal" instruction is in the
wrong place with respect to the start of line number 10.

This happens with both dwarf-2 and stabs+.

This may seem contrived, but the gcc documentation does say:

  Without `-O', the compiler's goal is to reduce the cost of
  compilation and to make debugging produce the expected results.
  Statements are independent: if you stop the program with a
  breakpoint between statements, you can then assign a new value to
  any variable or change the program counter to any other statement
  in the function and get exactly the results you would expect from
  the source code.

I narrowed the problem down to this patch:

  http://gcc.gnu.org/ml/gcc-patches/2003-06/msg00430.html

This is a regression from gcc 3.3.2 so I'm marking it P1.

-- 
           Summary: [3.4/3.5 regression] bad line marker in debug info
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P1
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mec dot gnu at mindspring dot com
                CC: gcc-bugs at gcc dot gnu dot org,hubicka at ucw dot cz
 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=13974


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