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]

binutils line number change causes grief for gdb test suite


Gas has a line number change, and the gdb test suite has a lot
of regression failures.

Here is the change:

  http://sources.redhat.com/ml/binutils-cvs/2002-05/msg00110.html
  Do not reset loc_directive_seen in dwarf2_emit_insn.

Before the change, the gas code is this (comments removed)

  void
  dwarf2_emit_insn (size)
       int size;
  {
    struct dwarf2_line_info loc;

    if (debug_type != DEBUG_DWARF2 && ! loc_directive_seen)
      return;
    loc_directive_seen = false;
    loc = current;

    dwarf2_gen_line_info (frag_now_fix () - size, &loc);
  }

After the change, the code is this:

  void
  dwarf2_emit_insn (size)
       int size;
  {
    struct dwarf2_line_info loc;

    if (loc_directive_seen)
      loc = current;
    else if (debug_type != DEBUG_DWARF2)
      return;
    else
      dwarf2_where (& loc);

    dwarf2_gen_line_info (frag_now_fix () - size, &loc);
  }

This changes the line number records for the start of functions.

My configuration is:

  # before
  target = native, host = i686-pc-linux-gnu%rh-7.2, gdb=5.2,
  gcc=HEAD%2002-05-13, binutils=HEAD%2002-05-13, goption=-gdwarf-2

  # after
  target = native, host = i686-pc-linux-gnu%rh-7.2, gdb=5.2,
  gcc=HEAD%2002-05-13, binutils=HEAD%2002-05-14, goption=-gdwarf-2

In other words, it's native linux, stock gdb 5.2, gcc mainline
 (same version both times), binutils mainline separated by one day,
with "-gdwarf-2" debugging option.

Look at the behavior of gdb when setting a breakpoint at the beginning
of a function.

  # before
  (gdb) break main^M
  Breakpoint 1 at 0x8048318: file /berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c, line 35.^M
  (gdb) run ^M
  Starting program: /berman/fsf/_today_/berman/test/gdb.base/all-types ^M
  ^M
  Breakpoint 1, main () at /berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c:35^M
  35          dummy();^M
  (gdb) next^M
  36          return 0;^M
  (gdb) PASS: gdb.base/all-bin.exp: continuing after dummy()

  # after
  (gdb) break main^M
  Breakpoint 1 at 0x804830e: file /berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c, line 29.^M
  (gdb) run ^M
  Starting program: /berman/fsf/_today_/berman/test/gdb.base/all-types ^M
  ^M
  Breakpoint 1, main () at /berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c:29^M
  29      {^M
  (gdb) next^M
  35          dummy();^M
  (gdb) FAIL: gdb.base/all-bin.exp: continuing after dummy()

Here is the source code of the function.  It is the same before and
after, of course.

  # before and after
  (gdb) list 28,38
  28      int main ()
  29      {
  30          extern void dummy();
  31      #ifdef usestubs
  32          set_debug_traps();
  33          breakpoint();
  34      #endif
  35          dummy();
  36          return 0;
  37
  38      }

Here is a dump of assembler code.  It is the same in both executables.

  # before and after
  (gdb) disass main
  Dump of assembler code for function main:
  0x8048308 <main>:       push   %ebp
  0x8048309 <main+1>:     mov    %esp,%ebp
  0x804830b <main+3>:     sub    $0x8,%esp
  0x804830e <main+6>:     and    $0xfffffff0,%esp
  0x8048311 <main+9>:     mov    $0x0,%eax
  0x8048316 <main+14>:    sub    %eax,%esp
  0x8048318 <main+16>:    call   0x8048324 <dummy>
  0x804831d <main+21>:    mov    $0x0,%eax
  0x8048322 <main+26>:    leave
  0x8048323 <main+27>:    ret
  End of assembler dump.

Note that the breakpoint on "main" falls in different places.  In the
"before" case, the breakpoint falls on 0x8048318, the first line of
the function.  In the "after" case, the breakpoint falls on 0x804830e,
which is in the middle of the prologue.  It looks fell back on its
prologue reader and that the prologue reader is incomplete.

Here are the line number records:

  # before
  Line 28 of "/berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c"
     is at address 0x8048308 <main> but contains no code.
  (gdb) info line 29
  Line 29 of "/berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c"
     starts at address 0x8048308 <main> and ends at 0x8048318 <main+16>.
  (gdb) info line 30
  Line 30 of "/berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c"
     is at address 0x8048318 <main+16> but contains no code.
  (gdb) info line 31
  Line 31 of "/berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c"
     is at address 0x8048318 <main+16> but contains no code.
  (gdb) info line 32
  Line 32 of "/berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c"
     is at address 0x8048318 <main+16> but contains no code.
  (gdb) info line 33
  Line 33 of "/berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c"
     is at address 0x8048318 <main+16> but contains no code.
  (gdb) info line 34
  Line 34 of "/berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c"
     is at address 0x8048318 <main+16> but contains no code.
  (gdb) info line 35
  Line 35 of "/berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c"
     starts at address 0x8048318 <main+16> and ends at 0x804831d <main+21>.
  (gdb) info line 36
  Line 36 of "/berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c"
     starts at address 0x804831d <main+21> and ends at 0x8048322 <main+26>.
  (gdb) info line 37
  Line 37 of "/berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c"
     is at address 0x8048322 <main+26> but contains no code.
  (gdb) info line 38
  Line 38 of "/berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c"
     starts at address 0x8048322 <main+26> and ends at 0x8048324 <dummy>.

  # after
  (gdb) info line 28
  Line 28 of "/berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c"
     is at address 0x8048308 <main> but contains no code.
  (gdb) info line 29
  Line 29 of "/berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c"
     starts at address 0x8048308 <main> and ends at 0x8048309 <main+1>.
  (gdb) info line 30
  Line 30 of "/berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c"
     is at address 0x8048318 <main+16> but contains no code.
  (gdb) info line 31
  Line 31 of "/berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c"
     is at address 0x8048318 <main+16> but contains no code.
  (gdb) info line 32
  Line 32 of "/berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c"
     is at address 0x8048318 <main+16> but contains no code.
  (gdb) info line 33
  Line 33 of "/berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c"
     is at address 0x8048318 <main+16> but contains no code.
  (gdb) info line 34
  Line 34 of "/berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c"
     is at address 0x8048318 <main+16> but contains no code.
  (gdb) info line 35
  Line 35 of "/berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c"
     starts at address 0x8048318 <main+16> and ends at 0x804831d <main+21>.
  (gdb) info line 36
  Line 36 of "/berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c"
     starts at address 0x804831d <main+21> and ends at 0x8048322 <main+26>.
  (gdb) info line 37
  Line 37 of "/berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c"
     is at address 0x8048322 <main+26> but contains no code.
  (gdb) info line 38
  Line 38 of "/berman/migchain/source/gdb-5.2/gdb/testsuite/gdb.base/all-types.c"
     starts at address 0x8048322 <main+26> and ends at 0x8048323 <main+27>.

Look in particular at the first two lines of code:

  # before
  Line 29 ... starts at address 0x8048308 <main> and ends at 0x8048318 <main+16>.
  Line 35 ... starts at address 0x8048318 <main+16> and ends at 0x804831d <main+21>.
  # after
  Line 29 ... starts at address 0x8048308 <main> and ends at 0x8048309 <main+1>.
  Line 35 ... starts at address 0x8048318 <main+16> and ends at 0x804831d <main+21>.

I'm not positive, but line 29 in the "after" case looks incorrect to me.

This test works fine with -gstabs+ instead of -gdwarf-2.  Here are the line
numbers.  There were no changes from "before" to "after" in the gas stabs
emitter code.

  # before, with -gstabs+
  # after, with -gstabs+
  Line 29 ... starts at address 0x8048308 <main> and ends at 0x8048318 <main+16>.
  Line 35 ... starts at address 0x8048318 <main+16> and ends at 0x804831d <main+21>.

Michael C


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