From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1921 invoked by alias); 2 Nov 2005 06:06:59 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 1897 invoked by uid 22791); 2 Nov 2005 06:06:55 -0000 Received: from ausmtp01.au.ibm.com (HELO ausmtp01.au.ibm.com) (202.81.18.186) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Wed, 02 Nov 2005 06:06:55 +0000 Received: from sd0208e0.au.ibm.com (d23rh904.au.ibm.com [202.81.18.202]) by ausmtp01.au.ibm.com (8.12.10/8.12.10) with ESMTP id jA269rug187570 for ; Wed, 2 Nov 2005 17:09:55 +1100 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.250.243]) by sd0208e0.au.ibm.com (8.12.10/NCO/VERS6.7) with ESMTP id jA269gAr163370 for ; Wed, 2 Nov 2005 17:09:42 +1100 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.12.11/8.13.3) with ESMTP id jA266e3V021883 for ; Wed, 2 Nov 2005 17:06:40 +1100 Received: from [9.181.133.252] ([9.181.133.252]) by d23av02.au.ibm.com (8.12.11/8.12.11) with ESMTP id jA266Ycw021779 for ; Wed, 2 Nov 2005 17:06:37 +1100 Date: Wed, 02 Nov 2005 07:42:00 -0000 From: Wu Zhou To: gdb-patches@sources.redhat.com Subject: [RFC]: Testcase for gdb's handling of Fortran's column-first array Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2005-11/txt/msg00030.txt.bz2 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 * 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