This is the mail archive of the gdb-patches@sourceware.org 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]

[RFC]: Testcase for gdb's handling of Fortran's column-first array


As we all might know, the memory layout of Fortran's multi-dimension array 
is different than that of C language.  This testcase is intended to verify 
whether gdb could correctly handle Fortran's column-first array.  It 
defines two 2-dimension array, one of type integer and the other type 
real.  Then it will verify that gdb's could inteprete the arrays in the 
same layout.  It also makes some changes to some specified element, and 
then verify that it changed the correct element in the memory.

OK.  With all these said, here is the patch.  I had tested it on FC4, it 
reported no failure.  But however I _did_ found a old gdb (6.1 maybe) 
handle this incorrectly.  So this testcase still make senses.  OK to 
commit?

2005-11-02  Wu Zhou  <woodzltc@cn.ibm.com>

	* gdb.fortran/dim-order.f: New file.
	* gdb.fortran/dim-order.exp: New testcase.

Index: gdb.fortran/dim-order.f
===================================================================
RCS file: gdb.fortran/dim-order.f
diff -N gdb.fortran/dim-order.f
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gdb.fortran/dim-order.f	2 Nov 2005 05:37:02 -0000
***************
*** 0 ****
--- 1,45 ----
+ c Copyright 2005 Free Software Foundation, Inc.
+ 
+ c This program is free software; you can redistribute it and/or modify
+ c it under the terms of the GNU General Public License as published by
+ c the Free Software Foundation; either version 2 of the License, or
+ c (at your option) any later version.
+ c
+ c This program is distributed in the hope that it will be useful,
+ c but WITHOUT ANY WARRANTY; without even the implied warranty of
+ c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ c GNU General Public License for more details.
+ c
+ c You should have received a copy of the GNU General Public License
+ c along with this program; if not, write to the Free Software
+ c Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ 
+ c Ihis file is the F77 source file for dim-order.exp.  It was written
+ c by Wu Zhou. (woodzltc@cn.ibm.com)
+ 
+       program dimorder 
+ 
+       integer aa, aaa
+       dimension aa(3,4)
+       real bb
+       dimension bb(3,4)
+ 
+ c To initialize the above multi-dimension arrays.
+       do j = 1,4
+         do i = 1,3
+           aa(i,j) = j * i
+           bb(i,j) = j * i
+         end do 
+       end do
+ 
+ c To transfer aa as parameter into subroutine sub.
+       call sub(aa)
+ 
+       end program 
+ 
+       subroutine sub(a)
+       integer a
+       dimension a(12)
+         print *, "This is in the subroutine"
+         print *,(a(i),i=1,12)
+       end
Index: gdb.fortran/dim-order.exp
===================================================================
RCS file: gdb.fortran/dim-order.exp
diff -N gdb.fortran/dim-order.exp
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gdb.fortran/dim-order.exp	2 Nov 2005 05:37:02 -0000
***************
*** 0 ****
--- 1,71 ----
+ # Copyright 2005 Free Software Foundation, Inc.
+ 
+ # This program is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+ # the Free Software Foundation; either version 2 of the License, or
+ # (at your option) any later version.
+ # 
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ # GNU General Public License for more details.
+ # 
+ # You should have received a copy of the GNU General Public License
+ # along with this program; if not, write to the Free Software
+ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+ 
+ # This file was written by Wu Zhou. (woodzltc@cn.ibm.com)
+ 
+ # This file is part of the gdb testsuite.  It contains test for verifying
+ # whether gdb can handle Fortran's column-first multi-dimensions array.
+ 
+ if $tracelevel then {
+ 	strace $tracelevel
+ }
+ 
+ set testfile "dim-order"
+ set srcfile ${testfile}.f
+ set binfile ${objdir}/${subdir}/${testfile}
+ 
+ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
+     untested "Couldn't compile ${srcfile}"
+     return -1
+ }
+ 
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+ gdb_load ${binfile}
+ 
+ if ![runto MAIN__] then {
+     perror "couldn't run to breakpoint MAIN__"
+     continue
+ }
+ 
+ set bp_location [gdb_get_line_number "call"]
+ gdb_test "break $bp_location" \
+     "Breakpoint.*at.* file .*$srcfile, line $bp_location\\." \
+     "breakpoint at subroutine call"
+ gdb_test "continue" \
+     "Continuing\\..*Breakpoint.*" \
+     "continue to the breakpoint at call"
+ 
+ gdb_test "print aa" ".*1 =.+1, 2, 3.+2, 4, 6.+3, 6, 9.+4, 8, 12.+" "print two-dimensions integer array aa"
+ gdb_test "print bb" ".*2 =.+1, 2, 3.+2, 4, 6.+3, 6, 9.+4, 8, 12.+" "print two-dimensions float array bb"
+ 
+ send_gdb "set var aa(3,2)=32\n"
+ gdb_expect {
+     -re "$gdb_prompt $" { pass "set aa(3,2) to 32" }
+     timeout	{fail "set aa(3,2) to 32" }
+   }
+ gdb_test "print aa" ".*3 =.*1, 2, 3.+2, 4, 32.+3, 6, 9.+4, 8, 12.+" "check array aa after the above change"
+ 
+ send_gdb "set var bb(3,2)=32.0\n"
+ gdb_expect {
+     -re "$gdb_prompt $"	{ pass "set bb(3,2) to 32.0" }
+     timeout	{fail "set bb(3,2) to 32.0" }
+   }
+ gdb_test "print bb" ".*4 = .*1, 2, 3.+2, 4, 32.+3, 6, 9.+4, 8, 12.+" "check array bb after the above change"
+ 
+ gdb_test "step" ".*This is in the subroutine.*" "step into subroutine sub"
+ gdb_test "print *a" ".*5 = .*1, 2, 3, 2, 4, 32, 3, 6, 9, 4, 8, 12.*" "print one-dimension array a"


Regards
- Wu Zhou


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