From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22797 invoked by alias); 18 Apr 2016 10:07:49 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 22689 invoked by uid 89); 18 Apr 2016 10:07:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mga03.intel.com Received: from mga03.intel.com (HELO mga03.intel.com) (134.134.136.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 18 Apr 2016 10:07:35 +0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP; 18 Apr 2016 03:07:35 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 18 Apr 2016 03:07:32 -0700 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u3IA7VES000589; Mon, 18 Apr 2016 11:07:32 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id u3IA7VgX001335; Mon, 18 Apr 2016 12:07:31 +0200 Received: (from heckel@localhost) by ulvlx001.iul.intel.com with œ id u3IA7Vd9001331; Mon, 18 Apr 2016 12:07:31 +0200 From: Bernhard Heckel To: qiyaoltc@gmail.com Cc: gdb-patches@sourceware.org, brobecker@adacore.com, Bernhard Heckel Subject: [PATCH V4 3/3] fortran: Testsuite, fix different type naming across compilers. Date: Mon, 18 Apr 2016 10:07:00 -0000 Message-Id: <1460974046-1281-4-git-send-email-bernhard.heckel@intel.com> In-Reply-To: <1460974046-1281-1-git-send-email-bernhard.heckel@intel.com> References: <1460974046-1281-1-git-send-email-bernhard.heckel@intel.com> X-IsSubscribed: yes X-SW-Source: 2016-04/txt/msg00389.txt.bz2 Gfortran and ifort have different names for data types. Encapsulate type names in a library to increase number of supported compilers. gfortran -4.2 : int4 gfortran>=4.3 : integer(kind=4) ifort : INTEGER(4) 2016-03-22 Bernhard Heckel gdb/testsuite/Changelog: * gdb.fortran/common-block.exp: Use type naming defined in lib fortran. * gdb.fortran/derived-type.exp: Use type naming defined in lib fortran. * gdb.fortran/multi-dim.exp: Use type naming defined in lib fortran. * gdb.fortran/vla-datatypes.exp: Use type naming defined in lib fortran. * gdb.fortran/vla-ptype-sub.exp: Use type naming defined in lib fortran. * gdb.fortran/vla-ptype.exp: Use type naming defined in lib fortran. * gdb.fortran/whatis_type.exp: Use type naming defined in lib fortran. * lib/fortran.exp: Add type definition for gfortran and ifort compiler. --- gdb/testsuite/gdb.fortran/common-block.exp | 8 ++-- gdb/testsuite/gdb.fortran/derived-type.exp | 15 ++++---- gdb/testsuite/gdb.fortran/multi-dim.exp | 9 ++--- gdb/testsuite/gdb.fortran/vla-datatypes.exp | 15 ++++++-- gdb/testsuite/gdb.fortran/vla-ptype-sub.exp | 37 ++++++++++-------- gdb/testsuite/gdb.fortran/vla-ptype.exp | 24 +++++++----- gdb/testsuite/gdb.fortran/whatis_type.exp | 9 ++++- gdb/testsuite/lib/fortran.exp | 60 +++++++++++++++++++++++++++++ 8 files changed, 129 insertions(+), 48 deletions(-) diff --git a/gdb/testsuite/gdb.fortran/common-block.exp b/gdb/testsuite/gdb.fortran/common-block.exp index abdc50a..167e34d 100644 --- a/gdb/testsuite/gdb.fortran/common-block.exp +++ b/gdb/testsuite/gdb.fortran/common-block.exp @@ -21,6 +21,7 @@ if {[skip_fortran_tests]} { } standard_testfile .f90 +load_lib "fortran.exp" if {[prepare_for_testing ${testfile}.exp ${testfile} \ $srcfile {debug f90 quiet}]} { @@ -42,9 +43,10 @@ gdb_continue_to_breakpoint "stop-here-out" #set suffix "_" set suffix "" -set int4 {(integer\(kind=4\)|INTEGER\(4\))} -set real4 {(real\(kind=4\)|REAL\(4\))} -set real8 {(real\(kind=8\)|REAL\(8\))} +# Depending on the compiler being used, the type names can be printed differently. +set int4 [fortran_int4] +set real4 [fortran_real4] +set real8 [fortran_real8] gdb_test "whatis foo$suffix" "No symbol \"foo$suffix\" in current context." gdb_test "ptype foo$suffix" "No symbol \"foo$suffix\" in current context." diff --git a/gdb/testsuite/gdb.fortran/derived-type.exp b/gdb/testsuite/gdb.fortran/derived-type.exp index f7f10b5..017c6b1 100644 --- a/gdb/testsuite/gdb.fortran/derived-type.exp +++ b/gdb/testsuite/gdb.fortran/derived-type.exp @@ -21,6 +21,7 @@ if { [skip_fortran_tests] } { return -1 } standard_testfile .f90 +load_lib "fortran.exp" if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} { return -1 @@ -31,20 +32,18 @@ if ![runto MAIN__] then { continue } -# Depending on the compiler version being used, the name of the 4-byte integer -# and real types can be printed differently. For instance, gfortran-4.1 uses -# "int4" whereas gfortran-4.3 uses "int(kind=4)". -set int4 "(int4|integer\\(kind=4\\))" -set real4 "(real4|real\\(kind=4\\))" +# Depending on the compiler being used, the type names can be printed differently. +set int [fortran_int4] +set real [fortran_real4] -gdb_test "ptype p" "type = Type bar\r\n *${int4} :: c\r\n *${real4} :: d\r\n *End Type bar" +gdb_test "ptype p" "type = Type bar\r\n *$int :: c\r\n *$real :: d\r\n *End Type bar" set test "type-printing for derived type" gdb_test_multiple "ptype q" $test { - -re "type = Type foo\r\n *${real4} :: a\r\n *Type bar\r\n *${int4} :: c\r\n *${real4} :: d\r\n *End Type bar :: x\r\n *character\\*7 :: b\r\n *End Type foo\r\n$gdb_prompt $" { + -re "type = Type foo\r\n *$real :: a\r\n *Type bar\r\n *$int :: c\r\n *$real :: d\r\n *End Type bar :: x\r\n *character\\*7 :: b\r\n *End Type foo\r\n$gdb_prompt $" { pass $test } - -re "type = Type foo\r\n *${real4} :: a\r\n *Type bar\r\n *${int4} :: c\r\n *${real4} :: d\r\n *End Type bar :: x\r\n *character :: b\\(7\\)\r\n *End Type foo\r\n$gdb_prompt $" { + -re "type = Type foo\r\n *$real :: a\r\n *Type bar\r\n *$int :: c\r\n *$real :: d\r\n *End Type bar :: x\r\n *character :: b\\(7\\)\r\n *End Type foo\r\n$gdb_prompt $" { # Compiler should produce string, not an array of characters. setup_xfail "*-*-*" fail $test diff --git a/gdb/testsuite/gdb.fortran/multi-dim.exp b/gdb/testsuite/gdb.fortran/multi-dim.exp index abe37b8..e448f30 100644 --- a/gdb/testsuite/gdb.fortran/multi-dim.exp +++ b/gdb/testsuite/gdb.fortran/multi-dim.exp @@ -19,6 +19,7 @@ if { [skip_fortran_tests] } { return -1 } standard_testfile .f90 +load_lib "fortran.exp" if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } { return -1 @@ -29,10 +30,8 @@ if ![runto MAIN__] { continue } -# Depending on the compiler version being used, the name of the 4-byte integer -# and real types can be printed differently. For instance, gfortran-4.1 uses -# "int4" whereas gfortran-4.3 uses "int(kind=4)". -set int4 "(int4|integer\\(kind=4\\))" +# Depending on the compiler being used, the type names can be printed differently. +set int [fortran_int4] gdb_breakpoint [gdb_get_line_number "break-static"] gdb_continue_to_breakpoint "break-static" ".*break-static.*" @@ -69,7 +68,7 @@ gdb_test "print varbound(4)" \ "print valid variable bound array element" gdb_test "ptype unbound" \ - "type = $int4 \\(\\*\\)" \ + "type = $int \\(\\*\\)" \ "print type of unbound array" gdb_test "print unbound(4)" \ diff --git a/gdb/testsuite/gdb.fortran/vla-datatypes.exp b/gdb/testsuite/gdb.fortran/vla-datatypes.exp index ed74fa9..26bf0a2 100644 --- a/gdb/testsuite/gdb.fortran/vla-datatypes.exp +++ b/gdb/testsuite/gdb.fortran/vla-datatypes.exp @@ -14,6 +14,7 @@ # along with this program. If not, see . standard_testfile ".f90" +load_lib "fortran.exp" if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ {debug f90 quiet}] } { @@ -28,6 +29,12 @@ if ![runto_main] { return -1 } +# Depending on the compiler being used, the type names can be printed differently. +set int [fortran_int4] +set real [fortran_real4] +set complex [fortran_complex4] +set logical [fortran_logical4] + gdb_breakpoint [gdb_get_line_number "vlas-allocated"] gdb_continue_to_breakpoint "vlas-allocated" gdb_test "next" " = allocated\\\(realvla\\\)" \ @@ -48,13 +55,13 @@ gdb_test "print l" " = \\.TRUE\\." "charactervla allocated" gdb_breakpoint [gdb_get_line_number "vlas-initialized"] gdb_continue_to_breakpoint "vlas-initialized" -gdb_test "ptype intvla" "type = integer\\\(kind=4\\\) \\\(11,22,33\\\)" \ +gdb_test "ptype intvla" "type = $int \\\(11,22,33\\\)" \ "ptype intvla" -gdb_test "ptype realvla" "type = real\\\(kind=4\\\) \\\(11,22,33\\\)" \ +gdb_test "ptype realvla" "type = $real \\\(11,22,33\\\)" \ "ptype realvla" -gdb_test "ptype complexvla" "type = complex\\\(kind=4\\\) \\\(11,22,33\\\)" \ +gdb_test "ptype complexvla" "type = $complex \\\(11,22,33\\\)" \ "ptype complexvla" -gdb_test "ptype logicalvla" "type = logical\\\(kind=4\\\) \\\(11,22,33\\\)" \ +gdb_test "ptype logicalvla" "type = $logical \\\(11,22,33\\\)" \ "ptype logicalvla" gdb_test "ptype charactervla" "type = character\\\*1 \\\(11,22,33\\\)" \ "ptype charactervla" diff --git a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp index 7c98eed..e7a0a7e 100644 --- a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp +++ b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp @@ -14,6 +14,7 @@ # along with this program. If not, see . standard_testfile "vla-sub.f90" +load_lib "fortran.exp" if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ {debug f90 quiet}] } { @@ -25,27 +26,31 @@ if ![runto_main] { return -1 } +# Depending on the compiler being used, the type names can be printed differently. +set int [fortran_int4] +set real [fortran_real4] + # Pass fixed array to function and handle them as vla in function. gdb_breakpoint [gdb_get_line_number "not-filled"] gdb_continue_to_breakpoint "not-filled (1st)" -gdb_test "ptype array1" "type = integer\\\(kind=4\\\) \\\(42,42\\\)" \ +gdb_test "ptype array1" "type = $int \\\(42,42\\\)" \ "ptype array1 (passed fixed)" -gdb_test "ptype array2" "type = real\\\(kind=4\\\) \\\(42,42,42\\\)" \ +gdb_test "ptype array2" "type = $real \\\(42,42,42\\\)" \ "ptype array2 (passed fixed)" -gdb_test "ptype array1(40, 10)" "type = integer\\\(kind=4\\\)" \ +gdb_test "ptype array1(40, 10)" "type = $int" \ "ptype array1(40, 10) (passed fixed)" -gdb_test "ptype array2(13, 11, 5)" "type = real\\\(kind=4\\\)" \ +gdb_test "ptype array2(13, 11, 5)" "type = $real" \ "ptype array2(13, 11, 5) (passed fixed)" # Pass sub arrays to function and handle them as vla in function. gdb_continue_to_breakpoint "not-filled (2nd)" -gdb_test "ptype array1" "type = integer\\\(kind=4\\\) \\\(6,6\\\)" \ +gdb_test "ptype array1" "type = $int \\\(6,6\\\)" \ "ptype array1 (passed sub-array)" -gdb_test "ptype array2" "type = real\\\(kind=4\\\) \\\(6,6,6\\\)" \ +gdb_test "ptype array2" "type = $real \\\(6,6,6\\\)" \ "ptype array2 (passed sub-array)" -gdb_test "ptype array1(3, 3)" "type = integer\\\(kind=4\\\)" \ +gdb_test "ptype array1(3, 3)" "type = $int" \ "ptype array1(3, 3) (passed sub-array)" -gdb_test "ptype array2(4, 4, 4)" "type = real\\\(kind=4\\\)" \ +gdb_test "ptype array2(4, 4, 4)" "type = $real" \ "ptype array2(4, 4, 4) (passed sub-array)" # Check ptype outside of bounds. This should not crash GDB. @@ -56,13 +61,13 @@ gdb_test "ptype array2(100, 100, 100)" "no such vector element" \ # Pass vla to function. gdb_continue_to_breakpoint "not-filled (3rd)" -gdb_test "ptype array1" "type = integer\\\(kind=4\\\) \\\(20,20\\\)" \ +gdb_test "ptype array1" "type = $int \\\(20,20\\\)" \ "ptype array1 (passed vla)" -gdb_test "ptype array2" "type = real\\\(kind=4\\\) \\\(10,10,10\\\)" \ +gdb_test "ptype array2" "type = $real \\\(10,10,10\\\)" \ "ptype array2 (passed vla)" -gdb_test "ptype array1(3, 3)" "type = integer\\\(kind=4\\\)" \ +gdb_test "ptype array1(3, 3)" "type = $int" \ "ptype array1(3, 3) (passed vla)" -gdb_test "ptype array2(4, 4, 4)" "type = real\\\(kind=4\\\)" \ +gdb_test "ptype array2(4, 4, 4)" "type = $real" \ "ptype array2(4, 4, 4) (passed vla)" # Check ptype outside of bounds. This should not crash GDB. @@ -76,12 +81,12 @@ gdb_test "ptype array2(100, 100, 100)" "no such vector element" \ gdb_breakpoint [gdb_get_line_number "end-of-bar"] gdb_continue_to_breakpoint "end-of-bar" gdb_test "ptype array1" \ - "type = (PTR TO -> \\( )?integer(\\(kind=4\\)|\\*4) \\(\\*\\)\\)?" \ + "type = (PTR TO -> \\( )?$int \\(\\*\\)\\)?" \ "ptype array1 (arbitrary length)" gdb_test "ptype array2" \ - "type = (PTR TO -> \\( )?integer(\\(kind=4\\)|\\*4) \\(4:9,10:\\*\\)\\)?" \ + "type = (PTR TO -> \\( )?$int \\(4:9,10:\\*\\)\\)?" \ "ptype array2 (arbitrary length)" -gdb_test "ptype array1(100)" "type = integer\\\(kind=4\\\)" \ +gdb_test "ptype array1(100)" "type = $int" \ "ptype array1(100) (arbitrary length)" -gdb_test "ptype array2(4,100)" "type = integer\\\(kind=4\\\)" \ +gdb_test "ptype array2(4,100)" "type = $int" \ "ptype array2(4,100) (arbitrary length)" diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp b/gdb/testsuite/gdb.fortran/vla-ptype.exp index 51da229..175661f 100644 --- a/gdb/testsuite/gdb.fortran/vla-ptype.exp +++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp @@ -14,6 +14,7 @@ # along with this program. If not, see . standard_testfile "vla.f90" +load_lib "fortran.exp" if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ {debug f90 quiet}] } { @@ -25,6 +26,9 @@ if ![runto_main] { return -1 } +# Depending on the compiler being used, the type names can be printed differently. +set real [fortran_real4] + # Check the ptype of various VLA states and pointer to VLA's. gdb_breakpoint [gdb_get_line_number "vla1-init"] gdb_continue_to_breakpoint "vla1-init" @@ -39,40 +43,40 @@ gdb_test "ptype vla2(5, 45, 20)" \ gdb_breakpoint [gdb_get_line_number "vla1-allocated"] gdb_continue_to_breakpoint "vla1-allocated" -gdb_test "ptype vla1" "type = real\\\(kind=4\\\) \\\(10,10,10\\\)" \ +gdb_test "ptype vla1" "type = $real \\\(10,10,10\\\)" \ "ptype vla1 allocated" gdb_breakpoint [gdb_get_line_number "vla2-allocated"] gdb_continue_to_breakpoint "vla2-allocated" -gdb_test "ptype vla2" "type = real\\\(kind=4\\\) \\\(7,42:50,13:35\\\)" \ +gdb_test "ptype vla2" "type = $real \\\(7,42:50,13:35\\\)" \ "ptype vla2 allocated" gdb_breakpoint [gdb_get_line_number "vla1-filled"] gdb_continue_to_breakpoint "vla1-filled" -gdb_test "ptype vla1" "type = real\\\(kind=4\\\) \\\(10,10,10\\\)" \ +gdb_test "ptype vla1" "type = $real \\\(10,10,10\\\)" \ "ptype vla1 filled" -gdb_test "ptype vla1(3, 6, 9)" "type = real\\\(kind=4\\\)" \ +gdb_test "ptype vla1(3, 6, 9)" "type = $real" \ "ptype vla1(3, 6, 9)" gdb_breakpoint [gdb_get_line_number "vla2-filled"] gdb_continue_to_breakpoint "vla2-filled" -gdb_test "ptype vla2" "type = real\\\(kind=4\\\) \\\(7,42:50,13:35\\\)" \ +gdb_test "ptype vla2" "type = $real \\\(7,42:50,13:35\\\)" \ "ptype vla2 filled" -gdb_test "ptype vla2(5, 45, 20)" "type = real\\\(kind=4\\\)" \ +gdb_test "ptype vla2(5, 45, 20)" "type = $real" \ "ptype vla1(5, 45, 20) filled" gdb_breakpoint [gdb_get_line_number "pvla-associated"] gdb_continue_to_breakpoint "pvla-associated" -gdb_test "ptype pvla" "type = real\\\(kind=4\\\) \\\(10,10,10\\\)" \ +gdb_test "ptype pvla" "type = $real \\\(10,10,10\\\)" \ "ptype pvla associated" -gdb_test "ptype pvla(3, 6, 9)" "type = real\\\(kind=4\\\)" \ +gdb_test "ptype pvla(3, 6, 9)" "type = $real" \ "ptype pvla(3, 6, 9)" gdb_breakpoint [gdb_get_line_number "pvla-re-associated"] gdb_continue_to_breakpoint "pvla-re-associated" -gdb_test "ptype pvla" "type = real\\\(kind=4\\\) \\\(7,42:50,13:35\\\)" \ +gdb_test "ptype pvla" "type = $real \\\(7,42:50,13:35\\\)" \ "ptype pvla re-associated" -gdb_test "ptype vla2(5, 45, 20)" "type = real\\\(kind=4\\\)" \ +gdb_test "ptype vla2(5, 45, 20)" "type = $real" \ "ptype vla1(5, 45, 20) re-associated" gdb_breakpoint [gdb_get_line_number "pvla-deassociated"] diff --git a/gdb/testsuite/gdb.fortran/whatis_type.exp b/gdb/testsuite/gdb.fortran/whatis_type.exp index b0e37e6..af897a6 100644 --- a/gdb/testsuite/gdb.fortran/whatis_type.exp +++ b/gdb/testsuite/gdb.fortran/whatis_type.exp @@ -16,6 +16,7 @@ if { [skip_fortran_tests] } { continue } standard_testfile type.f90 +load_lib "fortran.exp" if { [prepare_for_testing ${testfile}.exp ${testfile} \ ${srcfile} {debug f90}] } { @@ -27,11 +28,15 @@ if ![runto MAIN__] { return } +# Depending on the compiler being used, the type names can be printed differently. +set int [fortran_int4] +set real [fortran_real4] + gdb_breakpoint [gdb_get_line_number "bp1"] gdb_continue_to_breakpoint "bp1" -set t1_i "integer\\\(kind=4\\\) :: t1_i" -set t1_r "real\\\(kind=4\\\) :: t1_r" +set t1_i "$int :: t1_i" +set t1_r "$real :: t1_r" gdb_test "whatis t1" \ "type = Type t1\r\n${t1_i}\r\n${t1_r}\r\nEnd Type t1" \ diff --git a/gdb/testsuite/lib/fortran.exp b/gdb/testsuite/lib/fortran.exp index 04011b9..872d99d 100644 --- a/gdb/testsuite/lib/fortran.exp +++ b/gdb/testsuite/lib/fortran.exp @@ -28,3 +28,63 @@ proc set_lang_fortran {} { } return 1 } + +proc fortran_int4 {} { + if {[test_compiler_info {gcc-4-[012]-*}]} { + return "int4" + } elseif {[test_compiler_info {gcc-*}]} { + return "integer\\(kind=4\\)" + } elseif {[test_compiler_info {icc-*}]} { + return "INTEGER\\(4\\)" + } else { + return "unknown" + } +} + +proc fortran_real4 {} { + if {[test_compiler_info {gcc-4-[012]-*}]} { + return "real4" + } elseif {[test_compiler_info {gcc-*}]} { + return "real\\(kind=4\\)" + } elseif {[test_compiler_info {icc-*}]} { + return "REAL\\(4\\)" + } else { + return "unknown" + } +} + +proc fortran_real8 {} { + if {[test_compiler_info {gcc-4-[012]-*}]} { + return "real8" + } elseif {[test_compiler_info {gcc-*}]} { + return "real\\(kind=8\\)" + } elseif {[test_compiler_info {icc-*}]} { + return "REAL\\(8\\)" + } else { + return "unknown" + } +} + +proc fortran_complex4 {} { + if {[test_compiler_info {gcc-4-[012]-*}]} { + return "complex4" + } elseif {[test_compiler_info {gcc-*}]} { + return "complex\\(kind=4\\)" + } elseif {[test_compiler_info {icc-*}]} { + return "COMPLEX\\(4\\)" + } else { + return "unknown" + } +} + +proc fortran_logical4 {} { + if {[test_compiler_info {gcc-4-[012]-*}]} { + return "logical4" + } elseif {[test_compiler_info {gcc-*}]} { + return "logical\\(kind=4\\)" + } elseif {[test_compiler_info {icc-*}]} { + return "LOGICAL\\(4\\)" + } else { + return "unknown" + } +} -- 2.7.1.339.g0233b80