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]: Extend fortran testsuite


Hi,

while working on a bug in fortran language I wrote some fortran tests. Mostly these are extensions to the existing tests. One testfile is new: array-constr.exp This testsuite
tests some array specific things like constructors, field access, lower bound != 0, etc.


I noticed some bugs in DWARF code emitted by gcc compilers < 4.3. DWARF standard says that
a DW_TAG_subrange_type is emitted for each array dimension.

integer, dimension(2,3) :: mdim_array

should give s.th. like

<2><60>: Abbrev Number: 6 (DW_TAG_subrange_type)
    DW_AT_type        : <6d>­··
    DW_AT_upper_bound : 2­·····
<2><66>: Abbrev Number: 6 (DW_TAG_subrange_type)
    DW_AT_type        : <6d>­··
    DW_AT_upper_bound : 3­·····

but currently gives

<2><130>: Abbrev Number: 9 (DW_TAG_subrange_type)
    DW_AT_type        : <63>­··
    DW_AT_lower_bound : 0­·····
    DW_AT_upper_bound : 5­·····

On that accout GDB thinks of it as an one-dim. array:
$1 = (1, 2, 3, 4, 5, 6)
(gdb) ptype mdbnd
type = int4 (0:5)

instead of a multi-dim. array
(gdb) p mdbnd
$1 = (( 1, 2) ( 3, 4) ( 5, 6) )
(gdb) ptype mdbnd
type = integer(kind=4) (2,3)
(gdb)


This is the reason that some of the new tests will fail in an environment
emitting wrong DWARF code. For gcc this will be fixed with 4.3 release.

As I'm not a fortran guru it would be great if one could have a look at the tests.
Is this ok to commit?

ChangeLog:

	* gdb.fortran/array-constr.{f95, exp}: New fortran testcase to test
	array constructors and field access.
	* gdb.fortran/complex.exp: Add new tests.
	* gdb.fortran/exprs.exp: Likewise.
	* gdb.fortran/subarray.exp: Likewise.
	* gdb.fortran/types.exp: Likewise.


-- Markus Deuling GNU Toolchain for Linux on Cell BE deuling@de.ibm.com

diff -urpN src/gdb/testsuite/gdb.fortran/array-constr.exp dev/gdb/testsuite/gdb.fortran/array-constr.exp
--- src/gdb/testsuite/gdb.fortran/array-constr.exp	1970-01-01 01:00:00.000000000 +0100
+++ dev/gdb/testsuite/gdb.fortran/array-constr.exp	2008-03-10 10:26:39.000000000 +0100
@@ -0,0 +1,92 @@
+# Copyright 2005, 2007, 2008 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 3 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, see <http://www.gnu.org/licenses/>.
+
+# This file was contributed by Markus Deuling (deuling@de.ibm.com>
+
+# This file is part of the gdb testsuite.  It contains tests for array
+# constructors
+
+if $tracelevel then {
+	strace $tracelevel
+}
+
+set testfile "array-constr"
+set srcfile ${testfile}.f95
+set binfile ${objdir}/${subdir}/${testfile}
+
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug compiler=gfortran 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
+}
+
+gdb_breakpoint [gdb_get_line_number "stop"]
+gdb_continue_to_breakpoint "stop"
+
+gdb_test "ptype array" "type = int4 \\(0:2\\)" "ptype array"
+gdb_test "ptype array(1)" ".*type = int4.*" "ptype array(1)"
+gdb_test "print array" ".*\\(14, 15, 16\\)" "print array"
+gdb_test "print array(2)" ".*16.*" "print array(2)"
+gdb_test "print array(1:1)" ".*\\(15\\)" "print array(1:1)"
+
+# Now set values
+gdb_test "set array(1:1)=2" "" "set array(1:1)=2"
+gdb_test "p array(1:1)" ".*\\(2\\)" "p array(1:1)"
+gdb_test "print array" ".*\\(14, 2, 16\\)" "print array"
+
+gdb_test "set array(0)=7" "" "set array(0)=7"
+gdb_test "p array(0:0)" ".*\\(7\\)" "p array(0:0)"
+gdb_test "print array" ".*\\(7, 2, 16\\)" "print array"
+gdb_test "print array(0:1)" ".*\\(7, 2\\)" "print array(0:1)"
+
+# Test multi-dim array
+gdb_test "ptype mdim_array" \
+	 ".*type = integer\\(kind=4\\) \\(2,3\\).*" \
+	 "ptype mdim_array"
+gdb_test "p mdim_array" \
+	 "\\(\\( 1, 2\\) \\( 3, 4\\) \\( 5, 6\\) \\)" \
+	 "p mdim_array"
+gdb_test "p mdim_array(1:1)" \
+	 "\\(\\( 1, 2\\) \\)" \
+	 "p mdim_array(1:1)"
+gdb_test "p mdim_array(2:2)" \
+	 "\\(\\( 3, 4\\) \\)" \
+	 "p mdim_array(2:2)"
+gdb_test "p mdim_array(3:3)" \
+	 "\\(\\( 5, 6\\) \\)" \
+	 "p mdim_array(3:3)"
+gdb_test "p mdim_array(2:3)" \
+	 "\\(\\( 3, 4\\) \\( 5, 6\\) \\)" \
+	 "p mdim_array(2:3)"
+
+# Test lower bound != 0
+gdb_test "p bnd_array" ".*\\(1, 2, 3, 4\\).*" "p bnd_array"
+gdb_test "ptype bnd_array" \
+	 ".*type = integer\\(kind=4\\).*\\(-2:1\\)" \
+	 "ptype bnd_array"
+gdb_test "p bnd_array(-2)" ".*= 1.*" "p bnd_array(-2)"
+gdb_test "p bnd_array(-1)" ".*= 2.*" "p bnd_array(-1)"
+gdb_test "p bnd_array(0)" ".*= 3.*" "p bnd_array(0)"
+gdb_test "p bnd_array(1)" ".*= 4.*" "p bnd_array(1)"
+
diff -urpN src/gdb/testsuite/gdb.fortran/array-constr.f95 dev/gdb/testsuite/gdb.fortran/array-constr.f95
--- src/gdb/testsuite/gdb.fortran/array-constr.f95	1970-01-01 01:00:00.000000000 +0100
+++ dev/gdb/testsuite/gdb.fortran/array-constr.f95	2008-03-10 10:15:54.000000000 +0100
@@ -0,0 +1,14 @@
+        integer, dimension(3) :: array
+        integer, dimension(2,3) :: mdim_array
+        integer, dimension(-2:1) :: bnd_array
+
+        array = (/14,15,16/)
+        mdim_array = reshape( (/1, 2, 3, 4, 5, 6/), (/2, 3/) )
+        bnd_array = (/1, 2, 3, 4/)
+
+        write(*,*) array
+        write(*,*) mdim_array
+        write(*,*) bnd_array
+
+        stop
+        end
diff -urpN src/gdb/testsuite/gdb.fortran/complex.exp dev/gdb/testsuite/gdb.fortran/complex.exp
--- src/gdb/testsuite/gdb.fortran/complex.exp	2008-01-01 23:53:19.000000000 +0100
+++ dev/gdb/testsuite/gdb.fortran/complex.exp	2008-03-10 09:44:46.000000000 +0100
@@ -43,3 +43,7 @@ gdb_test "continue" \
     "continue to breakpoint"
 
 gdb_test "print c" "\\\$$decimal = \\(1000,-50\\)"
+gdb_test "ptype c" "type = double complex" "ptype c"
+gdb_test "ptype (2.34,-3.45)" "type = complex\\*16" "ptype (2.34,-3.45)"
+gdb_test "set variable c=(2.34,-3.45)" "" "set variable c=(2.34,-3.45)"
+gdb_test "print c" "\\\$$decimal = \\(2.3.*,-3.4.*\\)"
diff -urpN src/gdb/testsuite/gdb.fortran/exprs.exp dev/gdb/testsuite/gdb.fortran/exprs.exp
--- src/gdb/testsuite/gdb.fortran/exprs.exp	2008-01-01 23:53:19.000000000 +0100
+++ dev/gdb/testsuite/gdb.fortran/exprs.exp	2008-03-10 09:44:46.000000000 +0100
@@ -79,7 +79,9 @@ proc test_logical_literals_accepted {} {
     # Test the only possible values for a logical, TRUE and FALSE.
 
     gdb_test "p .TRUE." " = .TRUE."
+    gdb_test "p .true." " = .TRUE."
     gdb_test "p .FALSE." " = .FALSE."
+    gdb_test "p .false." " = .FALSE."
 }
 
 proc test_float_literals_accepted {} {
diff -urpN src/gdb/testsuite/gdb.fortran/subarray.exp dev/gdb/testsuite/gdb.fortran/subarray.exp
--- src/gdb/testsuite/gdb.fortran/subarray.exp	2008-01-01 23:53:19.000000000 +0100
+++ dev/gdb/testsuite/gdb.fortran/subarray.exp	2008-03-10 09:44:46.000000000 +0100
@@ -51,15 +51,24 @@ gdb_test "continue" \
     "Continuing\\..*Breakpoint.*" \
     "continue to breakpoint"
 
-# Test four different kinds of subarray expression evaluation.
+# Test ptype for arrays
+gdb_test "ptype str" ".*type = character \\(7\\).*" "ptype str"
 
-gdb_test "print str(2:4)" ".*1 = \\(98 'b', 99 'c', 100 'd'\\).*" "print str(2:4)"
-gdb_test "print str(:3)" ".*2 = \\(97 'a', 98 'b', 99 'c'\\).*" "print str(:3)"
-gdb_test "print str(5:)" ".*3 = \\(101 'e', 102 'f', 103 'g'\\).*" "print str(5:)"
-gdb_test "print str(:)" ".*4 = \\(97 'a', 98 'b', 99 'c', 100 'd', 101 'e', 102 'f', 103 'g'\\).*" "print str(:)"
+# Test different kinds of subarray expression evaluation.
 
-gdb_test "print array(2:4)" ".*5 = \\(2, 3, 4\\).*" "print array(2:4)"
-gdb_test "print array(:3)" ".*6 = \\(1, 2, 3\\).*" "print array(:3)"
-gdb_test "print array(5:)" ".*7 = \\(5, 6, 7\\).*" "print array(5:)"
-gdb_test "print array(:)" ".*8 = \\(1, 2, 3, 4, 5, 6, 7\\).*" "print array(:)"
+gdb_test "print str(2:4)" ".* = \\(98 'b', 99 'c', 100 'd'\\).*" "print str(2:4)"
+gdb_test "print str(:3)" ".* = \\(97 'a', 98 'b', 99 'c'\\).*" "print str(:3)"
+gdb_test "print str(5:)" ".* = \\(101 'e', 102 'f', 103 'g'\\).*" "print str(5:)"
+gdb_test "print str(:)" ".* = \\(97 'a', 98 'b', 99 'c', 100 'd', 101 'e', 102 'f', 103 'g'\\).*" "print str(:)"
+gdb_test "print str(1)" ".* = 97 'a'.*" "print str(1)"
+gdb_test "print str(7)" ".* = 103 'g'.*" "print str(7)"
+
+gdb_test "print array(2:4)" ".* = \\(2, 3, 4\\).*" "print array(2:4)"
+gdb_test "print array(:3)" ".* = \\(1, 2, 3\\).*" "print array(:3)"
+gdb_test "print array(5:)" ".* = \\(5, 6, 7\\).*" "print array(5:)"
+gdb_test "print array(:)" ".* = \\(1, 2, 3, 4, 5, 6, 7\\).*" "print array(:)"
+gdb_test "print array" ".*\\(1, 2, 3, 4, 5, 6, 7\\).*" "print array"
+for {set idx 1} {$idx < 8} {incr idx} {
+  gdb_test "p array($idx)" ".* = $idx.*" "p array($idx)"
+}
 
diff -urpN src/gdb/testsuite/gdb.fortran/types.exp dev/gdb/testsuite/gdb.fortran/types.exp
--- src/gdb/testsuite/gdb.fortran/types.exp	2008-01-01 23:53:19.000000000 +0100
+++ dev/gdb/testsuite/gdb.fortran/types.exp	2008-03-10 09:44:46.000000000 +0100
@@ -71,7 +71,9 @@ proc test_logical_literal_types_accepted
     # Test the only possible values for a logical, TRUE and FALSE.
 
     gdb_test "pt .TRUE." "type = logical\\*2"
+    gdb_test "pt .true." "type = logical\\*2"
     gdb_test "pt .FALSE." "type = logical\\*2"
+    gdb_test "pt .false." "type = logical\\*2"
 }
 
 proc test_float_literal_types_accepted {} {

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