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]

Stepping over functions in gdb fails on alphaev56-dec-osf5.0


I'm not positive this is a bug in gcc; it might be a bug in gdb.

Stepping over functions that call other functions doesn't work when
the code is compiled with gcc.  It works just fine with Compaq cc
V6.1-011.  This problem also exists on alphaev56-dec-osf4.0f.

$ cat t.c
void
bar(void)
{
}

void
foo(void)
{
  bar();
}

int
main(int argc, char *argv[])
{
  bar(); /* next fine */
  foo(); /* next broken */
  return 0;
}
$ gcc -v --save-temps -g  t.c -o t
Reading specs from /usr/local/lib/gcc-lib/alphaev56-dec-osf5.0/2.96/specs
gcc version 2.96 20000207 (experimental)
 /usr/local/lib/gcc-lib/alphaev56-dec-osf5.0/2.96/cpp -lang-c -v -D__GNUC__=2 -D__GNUC_MINOR__=96 -Dunix -D__osf__ -D_LONGLONG -DSYSTYPE_BSD -D_SYSTYPE_BSD -D__unix__ -D__osf__ -D_LONGLONG -D__SYSTYPE_BSD__ -D_SYSTYPE_BSD -D__unix -D__SYSTYPE_BSD -Asystem(unix) -Asystem(xpg4) -g -D__LANGUAGE_C__ -D__LANGUAGE_C -DLANGUAGE_C -Acpu(alpha) -Amachine(alpha) -D__alpha -D__alpha__ -D__alpha_ev5__ -Acpu(ev5) -D__alpha_bwx__ -Acpu(bwx) t.c t.i
GNU CPP version 2.96 20000207 (experimental) (cpplib)

#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/alphaev56-dec-osf5.0/include
 /usr/local/lib/gcc-lib/alphaev56-dec-osf5.0/2.96/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/alphaev56-dec-osf5.0/2.96/cc1 t.i -quiet -dumpbase t.c -g -version -o t.s
GNU C version 2.96 20000207 (experimental) (alphaev56-dec-osf5.0) compiled by GNU C version 2.96 20000207 (experimental).
 as -g -nocpp -O0 -o t.o t.s
 /usr/local/lib/gcc-lib/alphaev56-dec-osf5.0/2.96/mips-tfile -v -I t.o~ -o t.o t.s
mips-tfile version 2.96 20000207 (experimental)
 /usr/local/lib/gcc-lib/alphaev56-dec-osf5.0/2.96/collect2 -G 8 -O1 -call_shared -o t /usr/lib/cmplrs/cc/crt0.o -L/usr/local/lib/gcc-lib/alphaev56-dec-osf5.0/2.96 -L/usr/lib/cmplrs/cc -L/usr/local/lib/gcc-lib/alphaev56-dec-osf5.0/2.96/../../.. t.o -lgcc -lc -lgcc

$ gdb t                           
GNU gdb 20000204
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "alphaev56-dec-osf5.0"...
(gdb) b main
Breakpoint 1 at 0x1200011e4: file t.c, line 15.
(gdb) r
Starting program: /var/cluster/members/member0/tmp/t 

Breakpoint 1, main (argc=1, argv=0x11fffc018) at t.c:15
15        bar(); /* next fine */
(gdb) n
16        foo(); /* next broken */
(gdb) n
foo () at t.c:9
9         bar();
(gdb) n

Program exited normally.
(gdb) q


The assembly code looks like this:

[snip]

bar:
        .frame $15,16,$26,0
        .mask 0x4008000,-16
$bar..ng:
$LM1:
         #.stabn 68,0,3,$LM1
$LM2:
         #.stabn 68,0,4,$LM2

[snip]

foo:
        .frame $15,16,$26,0
        .mask 0x4008000,-16
        ldgp $29,0($27)
$foo..ng:
$LM3:
         #.stabn 68,0,8,$LM3
$LM4:
         #.stabn 68,0,9,$LM4

[snip]

$LM7:
         #.stabn 68,0,15,$LM7
        bsr $26,$bar..ng
$LM8:
         #.stabn 68,0,16,$LM8
        bsr $26,$foo..ng

[snip]



Notice that the subroutine call branches to $foo..ng instead of foo.

If I hand edit the assembly to:

$LM7:
         #.stabn 68,0,15,$LM7
        bsr $26,bar
$LM8:
         #.stabn 68,0,16,$LM8
        bsr $26,foo

... then gdb works as expected.


$ as -g -nocpp -O0 -o t.o t-fix.s
$ /usr/local/lib/gcc-lib/alphaev56-dec-osf5.0/2.96/mips-tfile -v -I t.o~ -o t.o t-fix.s
mips-tfile version 2.96 20000207 (experimental)
$ /usr/local/lib/gcc-lib/alphaev56-dec-osf5.0/2.96/collect2 -G 8 -O1 -call_shared -o t /usr/lib/cmplrs/cc/crt0.o -L/usr/local/lib/gcc-lib/alphaev56-dec-osf5.0/2.96 -L/usr/lib/cmplrs/cc -L/usr/local/lib/gcc-lib/alphaev56-dec-osf5.0/2.96/../../.. t.o -lgcc -lc -lgcc



$ gdb t                           
GNU gdb 20000204
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "alphaev56-dec-osf5.0"...
(gdb) b main
Breakpoint 1 at 0x1200011e4: file t.c, line 15.
(gdb) r
Starting program: /var/cluster/members/member0/tmp/t 

Breakpoint 1, main (argc=1, argv=0x11fffc018) at t.c:15
15        bar(); /* next fine */
(gdb) n
16        foo(); /* next broken */
(gdb) n
17        return 0;
(gdb) n
18      }
(gdb) n
0x1200010ec in __start ()
(gdb) n
Single stepping until exit from function __start, 
which has no line number information.

Program exited normally.
(gdb) q


The edited assembly is similar to the assembly that Compaq CC
produces:


[snip]

 #      2 bar(void)
bar:                                                                            
                                           # 000002
        .frame  $sp, 0, $26
        .prologue 0
        .loc 1 4

[snip]

 #      7 foo(void)
foo:                                                                            
                                           # 000007
        mov     $26, $1
        .frame  $sp, 0, $26
        .save_ra $1
        .prologue 0
        .loc 1 9

[snip]
        .loc 1 15
 #     15   bar(); /* next fine */
        bsr     $26, bar                                                        
                                           # 000015
        .loc 1 16
 #     16   foo(); /* next broken */
        bsr     $26, foo                                                        
[snip]


Thank you for any help you can provide.

Drew

P.S. The cpp output isn't included becuase it's the same as the C code
included above.

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