This is the mail archive of the gcc@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]

Re: gdb bug in Fortran langauge mode




>Could whoever asserted that gdb works with "other" Fortran's please
>submit a complete example of this working, including the source code
>for a small Fortran program, the gdb session showing it working, and
>the assembler output of the "other" compiler when compiling that
>program, so we can see for ourselves just what "working" means in this
>case?


Start with the test program:

---------------
      program foo
      dimension array(3,4,5)

      array(1,1,1) = 1

      end
---------------

On i86, I compiled with: 'g77 -c -g badsym.f'

'objdump --stabs badsym.o' gives, in part:

57     LSYM   0      3      ffffff10 2373   array:(0,47)=ar(0,20);1;5;(0,48)=ar(0,20);1;4;(0,49)=ar(0,20);1;3;(0,32)

You can see that the last array element is first in the stab.  Now try
it on an RS6K, using the XLF compiler.  'objdump --syms badsym.o'
produces:


[ 15](sec -2)(fl 0x00)(ty   0)(scl 142) (nx 0) 0x00000000 foo:F-11
[ 16](sec  1)(fl 0x00)(ty   0)(scl 101) (nx 1) 0x00000014 .bf
AUX lnno 5 size 0x0 tagndx 0
[ 18](sec  3)(fl 0x00)(ty   0)(scl 143) (nx 0) 0x0000001e .bs
[ 19](sec -2)(fl 0x00)(ty   0)(scl 140) (nx 0) 0x00000000 :t5=ar0;1;3;ar0;1;4;ar0;1;5;-12
[ 20](sec -2)(fl 0x00)(ty   0)(scl 133) (nx 0) 0x00000000 array:V5
[ 21](sec  3)(fl 0x00)(ty   0)(scl 144) (nx 0) 0x00000000 .es
[ 22](sec  1)(fl 0x00)(ty   0)(scl 101) (nx 1) 0x00000030 .ef

Here we see that the first array element is emitted first, and so on.


Craig notes that the 'whatis' command of gdb produces the correct
result.  This is because gdb's 'whatis' command is buggy-- it prints
the array elements in the wrong order!

Looking at the gdb code that calculates the addresses of array
elements shows that they are computed in reverse order of how the
'whatis' commands prints them.  If we start from here, gdb is clearly
wrong at some point-- either the 'whatis' is backwards or address
calculation is backwards.

To resolve the problem, I ran gdb on a program compiled by IBM's XLF
compiler.  The array printing works fine and the 'whatis' was backwards. 
On an i86 with g77, the array printing doesn't work and 'whatis' does. 

The answer is that gcc/g77 is emitting the debug info for array elements
in the wrong order.  The reason the 'whatis' works on a g77 program is
because things are reversed twice. 

The debugging dump between the XLF and g77 programs show that the array
info is being emitted in opposite orders.  Since XLF and gdb work fine
together (and XLF also works with the bundled dbx debugger), it follows
that g77/gcc is the one emitting debug info in the wrong order, and that
gdb's 'whatis' command prints them in the wrong order. 


        Andy

-----------------                        XOLD(K,IC,I)=
Andy Vaught               ....        DO ITERS=1, 10  XOLD(K,IC,I)
andy@maxwell.la.asu.edu   |  |   /CALLMSOLVE(A,B,X,I,ITERS,TOL)+(RANNYU(0)
Arizona State University  ======|WRITE(6,'(I5,2X,F12.6)')ITERS,TOL -HALF)
Tempe, Arizona USA        OOOOOO \ENDDORETURN PARAMETER(ZERO=1.D0)*TENTH*DELTA



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