I was not able to find how to find the triplets requested when running on a Gentoo Linux system. Running uname -a gives Linux mon 2.6.32-gentoo #1 SMP Thu Dec 3 13:59:59 PST 2009 x86_64 AMD Opteron(tm) Processor 242 AuthenticAMD GNU/Linux Try this Fortran code ==== program test c Testing gdb for printing arrays double precision C(4,4) do J = 1, 4 do I = 1, 4 C(I,J) = dble(I+J) end do end do print '(''C(1,1), C(4,4):'', 1P, 2E12.5)', C(1,1), C(4,4) stop end ====== gfortran -ggdb -o test test.f gdb test b 9 r p c(1,2) And I get no such vector element
Just tried gdb-7.0.1 on my gentoo system, and it has the same problem, this time noticed for a one-dimensional array. The error message is the same. Version 6.8 works.
Confirming on version 7.1
Created attachment 4976 [details] Proposed patch Fortran multi-dimensional arrays are of type: ARRAY of ( ARRAY of ( BASETYPE ) ) Nested to the required depth. The code used to fetch a single element out of an array could previously only handle (ARRAY of BASETYPE), and so before calling this we would modify the type of the array. However, this was leading to other problems when we try to bounds check the array access. This patch changes the array access code so that is can peel off all the layers of ARRAY of ARRAY of ... to get to the BASETYPE.
Created attachment 4977 [details] Test for this issue. The multi-dim.tar.bz2 contains a new test that should cover this issue. It would need adding to gdb/testsuite/gdb.fortran. The only thing is, I've not been able to run any of the Fortran tests myself as I'm struggling to get them to compile, I don't know if this is just my setup or a general issue. I'm working with gdb-7.2 & gcc 4.4.3. I've checked that this new test works using a dirty hack :) but someone who can actually get the Fortran tests running should check this works correctly before it's committed into the tree.
Created attachment 4986 [details] Updated patch This should apply to the current CVS head.
Created attachment 4987 [details] Updated testcase Finally got the Fortran tests running, slight update to the test case.
Created attachment 5068 [details] Support for multi-dimensional fortran arrays Minor updates to patch to meeting coding standards. Changelog message removed from patch file: 2010-10-19 Andrew Burgess <aburgess@broadcom.com> * valarith.c (value_subscripted_rvalue) Walk through multi-dimensional arrays to find the element type for the array. Allows the upper bound check to work with multi-dimensional arrays. Fix PR gdb/11104. * eval.c (evaluate_subexp_standard) Remove hack from multi_f77_subscript case now that multi-dimensional arrays are supported. Fix PR gdb/11104.
Created attachment 5069 [details] New test in patch format Test for this issue in patch format. ChangeLog message included before patch.
Created attachment 5070 [details] Support for multi-dimensional fortran arrays Updated to include the ChangeLog entry as text before the patch content.
CVSROOT: /cvs/src Module name: src Changes by: jkratoch@sourceware.org 2011-01-12 16:16:25 Modified files: gdb : ChangeLog dwarf2read.c eval.c gdb/testsuite : ChangeLog Added files: gdb/testsuite/gdb.fortran: multi-dim.exp multi-dim.f90 Log message: gdb/ PR fortran/11104 and DWARF unbound arrays detection. * dwarf2read.c (read_subrange_type): Set zero length on unspecified upper bound. Set TYPE_HIGH_BOUND_UNDEFINED if not language_ada on unspecified upper bound. * eval.c (evaluate_subexp_standard) <multi_f77_subscript>: Remove variables array_size_array, tmp_type and offset_item. New variable array. Remove call to f77_get_upperbound. New variables array_type and index. Call value_subscripted_rvalue for each dimenasion. Remove the final call to deprecated_set_value_type. gdb/testsuite/ PR fortran/11104 and DWARF unbound arrays detection. * gdb.fortran/multi-dim.exp: New file. * gdb.fortran/multi-dim.f90: New file. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.12463&r2=1.12464 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/dwarf2read.c.diff?cvsroot=src&r1=1.494&r2=1.495 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/eval.c.diff?cvsroot=src&r1=1.145&r2=1.146 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2549&r2=1.2550 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.fortran/multi-dim.exp.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.fortran/multi-dim.f90.diff?cvsroot=src&r1=NONE&r2=1.1
Fixed by the commit based on Andrew Burgess's patch.
gdb gives wrong results in case when one-dimensional array is passed as argument to subroutine and is treated as multidimensional array with dimensions which were passed as arguments. Please see this Fortran code: test.f90 === program test_array integer foo(4) do I=1,4 foo(I)=I enddo call test(foo,2) end subroutine test(M,N) integer N integer M(N,N) do J=1,N do I=1,N write(*,*) "I,J,M = ",I,J,M(I,J) enddo enddo end === This is output: $ gfortran -ggdb -o test test.f90 $ ./test I,J,M = 1 1 1 I,J,M = 2 1 2 I,J,M = 1 2 3 I,J,M = 2 2 4 This is debugging: $ gdb test ... (gdb) break test Breakpoint 1 at 0x804863e: file test.f90, line 11. (gdb) run Starting program: /home/????/test Breakpoint 1, test (m=..., n=2) at test.f90:11 11 subroutine test(M,N) (gdb) print M(2,2) $1 = 2 I use gdb 7.3.50.20110405
This bug is temporary fixed in archer-jankratochvil-vla branch