public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: gdb and g77
@ 1999-06-12 10:08 Andrew Vaught
  1999-06-12 11:29 ` craig
                   ` (2 more replies)
  0 siblings, 3 replies; 52+ messages in thread
From: Andrew Vaught @ 1999-06-12 10:08 UTC (permalink / raw)
  To: egcs

>> I get wrong answers from gdb when printing elements of a 3-dimensional
>>Fortran (g77)
>> array.  Is this a known problem, or am I missing something?  My
>>versions of g77 and gdb came with RedHat Ver 6.0 Linux.
>
>It's hard to tell without an example.  Offhand, I don't think *that*
>particular problem is know, though other g77+gdb problems are, to
>varying degrees, known (e.g. gdb 4.18 seems to not print complex
>variables correctly), and one or more of these might be what you are,
>in fact, seeing.
>
>        tq vm, (burley)

  When g77 emits debug info for arrays, the dimensions are reversed.  If
your array is palindromic, ie "dimension a(10,20,10)", it will work OK,
but otherwise gdb will be looking at the wrong memory location for the
data.  I originally thought the problem was with gdb reversing the
dimensions, but after building gdb on an RS6K, it correctly read the
dimension info from the native RS6K compiler.  Ergo g77 is incorrect.

         Andy

^ permalink raw reply	[flat|nested] 52+ messages in thread
* Re: gdb and g77
@ 1999-06-15 10:08 Tim Schmielau
  1999-06-15 14:03 ` craig
  1999-06-30 15:43 ` Tim Schmielau
  0 siblings, 2 replies; 52+ messages in thread
From: Tim Schmielau @ 1999-06-15 10:08 UTC (permalink / raw)
  To: egcs

> Well, it looks like there's general doubt on this list regarding the
> statement that gdb works fine with "other" Fortran compilers.
> 
> 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?

Though I didn't make that assertment, I just tested Portland Group's PGF77
on Linux/Intel against gdb, and indeed found it working.
I used the following short program:

      IMPLICIT NONE
      REAL x(5,6)
      INTEGER i,j

      DO i=1,5
         DO j=1,6
            x(i,j) = i+j*0.1
         ENDDO
      ENDDO
      WRITE(*,*) "array filled."
      END

Debug session log follows:

  > pgf77 -g arrtest.f
  > gdb a.out 
  GNU gdb 4.17.0.11 with Linux support
  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 "i686-pc-linux-gnu"...
  (gdb) b MAIN
  Breakpoint 1 at 0x8048d46: file arrtest.f, line 5.
  (gdb) r
  Starting program: /users/hoptik2/tim/test/a.out 
  
  Breakpoint 1, MAIN () at arrtest.f:5
  5             DO i=1,5
  Current language:  auto; currently fortran
  (gdb) b 10
  Breakpoint 2 at 0x8048dbb: file arrtest.f, line 10.
  (gdb) c
  Continuing.
  
  Breakpoint 2, MAIN () at arrtest.f:10
  10            WRITE(*,*) "array filled."
  (gdb) ptype x
  type = real*4 (6,5)
  (gdb) print x(1,1)
  $1 = 1.10000002
  (gdb) print x(1,2)
  $2 = 1.20000005
  (gdb) print x(2,1)
  $3 = 2.0999999

while the same program, compiled with g77, gives

  > g77 -g arrtest.f
  > gdb a.out
      ...
  (gdb) ptype x
  type = real*4 (5,6)
  (gdb) print x(1,1)
  $1 = 1.10000002
  (gdb) print x(2,1)
  $2 = 2.0999999
  (gdb) print x(1,2)
  $3 = 2.20000005

with the last being wrong. Note also the different outputs from ptype.
Output from

  > pgf77 -g -S arrtest.f

is attached.

hope this helps,
Tim Schmielau (tim@physik3.uni-rostock.de)

^ permalink raw reply	[flat|nested] 52+ messages in thread
* Re: gdb and g77
@ 1999-06-15  2:46 Dave Love
  1999-06-15 11:38 ` Stan Shebs
  1999-06-30 15:43 ` Dave Love
  0 siblings, 2 replies; 52+ messages in thread
From: Dave Love @ 1999-06-15  2:46 UTC (permalink / raw)
  To: egcs

>>>>> "JCB" == craig  <craig@jcb-sc.com> writes:

 JCB> But we now have info suggesting that gdb interprets debug records
 JCB> from Fortran compilers *other* than g77 (with back ends other than
 JCB> gcc, I assume) *correctly*.

The gdb support was written for a compiler with different conventions
from g77.  (I sent a copy of the paper on it a while back.)  I started
working on changes long ago but couldn't get a response from bug-gdb
about incorporating changes and no-one else seemed interested, so I
dropped it and probably no longer have the work.

 JCB> Yup.  I don't know what various debug formats should look like,
 JCB> especially in the area of multi-dimensional arrays.

I can't remember the details, but array references are quite
broken, particularly for dummy args.  They're interpreted as function
calls in Fortran mode and can crash gdb in C mode with assumed-size
arrays; e.g. in something like this, look at a and b in foo with
`print' and `whatis'.

      real a(3)
      data a /1,2,3/
      call foo(a, a)
      end
      subroutine foo(a, b)
      real a(3), b(*)
      print *, a(1), b(1)
      end

 >> We should also review the stabs & dwarf2 specs to make sure they
 >> do not specify something dumb like requiring the compiler to emit
 >> records with reversed subscripts :-)

 JCB> Indeed.  Reviewing the specs is one of the requirements for
 JCB> working on this -- which is why I haven't just dived into the
 JCB> code yet, I've got too many *other* things to review at the
 JCB> moment!

Generally there are Fortran-specific stabs and DWARFism which should
probably be emitted but aren't (for COMMON in particular).  Also
name-mangling needs treating.

For stabs, the online ( http://docs.sun.com/ ) Sun Fortran docs explain
how they deal with Fortran and one can generate sample assembler.
AFAIR, gdb works reasonably well with SunPro f77 (stabs) but doesn't
with MIPSpro (DWARF, at least now).

 JCB> So I'd very much appreciate anyone with some understanding (and
 JCB> time) helping find the culprit....

I don't know about this case, but I think the job needs doing
properly, and that's a fair amount of work.  I presume that changes
could now be got into gdb, at least.

^ permalink raw reply	[flat|nested] 52+ messages in thread
* Re: gdb and g77
@ 1999-06-13 16:10 Andrew Vaught
  1999-06-13 16:27 ` craig
  1999-06-30 15:43 ` Andrew Vaught
  0 siblings, 2 replies; 52+ messages in thread
From: Andrew Vaught @ 1999-06-13 16:10 UTC (permalink / raw)
  To: egcs

>>  When g77 emits debug info for arrays, the dimensions are reversed.  If
>>your array is palindromic, ie "dimension a(10,20,10)", it will work OK,
>>but otherwise gdb will be looking at the wrong memory location for the
>>data.  I originally thought the problem was with gdb reversing the
>>dimensions, but after building gdb on an RS6K, it correctly read the
>>dimension info from the native RS6K compiler.  Ergo g77 is incorrect.


>Sounds reasonable, though the likely cause of the problem is the gcc
>back end.  The g77 front end (presumably) passes to the back end
>the proper info on the array, else there'd be *huge* problems, either
>in correctness or performance.  What is probably happening, then, is
>that the back end's debug modules (sdbout.c, dbxout.c, dwarfout.c,
>dwarf2out.c, etc.) aren't coping properly with multi-dimensional
>arrays.
>
>But I'm speaking on this without actually looking at any of the code,
>or -g output, etc.  I'm real busy this weekend, but will try to catch
>up on things like this shortly, though the fact that nobody else seems
>to have found the problem already suggests that it isn't an easy problem
>to spot!
>
>        tq vm, (burley)

  As far as I could tell, the problem is in ffecom_sym_transform(), right
before and possibly after that 130-line comment.  The procedure that
generates the code for array references appears to be in another section
of code, while ffecom_sym_transform() looks like it is packaging symbols
so that the back end can write the debug information. 

  I'm not surprised that no one has complained about this.  My experience
with people who do numerical computing is that they aren't that
sophisticated when it comes to debugging-- print statements are generally
what they do.  You can blow them away by attaching to a running process
with the debugger and printing out the values of variables...

(it looks like my return address is messed up.  It is andy@xena.eas.asu.edu)

    Andy


^ permalink raw reply	[flat|nested] 52+ messages in thread
* gdb and g77
@ 1999-06-01 13:20 Peter Hirsch
  1999-06-03  3:07 ` craig
  1999-06-30 15:43 ` Peter Hirsch
  0 siblings, 2 replies; 52+ messages in thread
From: Peter Hirsch @ 1999-06-01 13:20 UTC (permalink / raw)
  To: egcs

 I get wrong answers from gdb when printing elements of a 3-dimensional
Fortran (g77)
 array.  Is this a known problem, or am I missing something?  My
versions of g77 and gdb came with RedHat Ver 6.0 Linux.

^ permalink raw reply	[flat|nested] 52+ messages in thread

end of thread, other threads:[~1999-06-30 15:43 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-06-12 10:08 gdb and g77 Andrew Vaught
1999-06-12 11:29 ` craig
1999-06-30 15:43   ` craig
1999-06-15  5:12 ` craig
1999-06-30 15:43   ` craig
1999-06-30 15:43 ` Andrew Vaught
  -- strict thread matches above, loose matches on Subject: below --
1999-06-15 10:08 Tim Schmielau
1999-06-15 14:03 ` craig
1999-06-15 15:59   ` Tim Schmielau
1999-06-30 15:43     ` Tim Schmielau
1999-06-30 15:43   ` craig
1999-06-30 15:43 ` Tim Schmielau
1999-06-15  2:46 Dave Love
1999-06-15 11:38 ` Stan Shebs
1999-06-17 12:23   ` Dave Love
1999-06-17 12:48     ` Stan Shebs
1999-06-30 15:43       ` Stan Shebs
1999-06-30 15:43     ` Dave Love
1999-06-30 15:43   ` Stan Shebs
1999-06-30 15:43 ` Dave Love
1999-06-13 16:10 Andrew Vaught
1999-06-13 16:27 ` craig
1999-06-14  0:03   ` Jeffrey A Law
1999-06-14  7:39     ` craig
1999-06-30 15:43       ` craig
1999-06-14  8:36     ` David Edelsohn
1999-06-14 11:00       ` Jeffrey A Law
1999-06-14 11:52         ` Per Bothner
1999-06-14 22:17           ` Jeffrey A Law
1999-06-30 15:43             ` Jeffrey A Law
1999-06-30 15:43           ` Per Bothner
1999-06-14 16:22         ` craig
1999-06-30 15:43           ` craig
1999-06-30 15:43         ` Jeffrey A Law
1999-06-30 15:43       ` David Edelsohn
1999-06-14 10:58     ` Richard Henderson
1999-06-30 15:43       ` Richard Henderson
1999-06-30 15:43     ` Jeffrey A Law
1999-06-14 12:02   ` Joern Rennecke
1999-06-14 16:22     ` craig
1999-06-14 16:37       ` Joern Rennecke
1999-06-30 15:43         ` Joern Rennecke
1999-06-14 16:50       ` Per Bothner
1999-06-30 15:43         ` Per Bothner
1999-06-30 15:43       ` craig
1999-06-30 15:43     ` Joern Rennecke
1999-06-30 15:43   ` craig
1999-06-30 15:43 ` Andrew Vaught
1999-06-01 13:20 Peter Hirsch
1999-06-03  3:07 ` craig
1999-06-30 15:43   ` craig
1999-06-30 15:43 ` Peter Hirsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).