From 1f20c35ea4a0095e6a9d9b7819f6c437a0c4cfc1 Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Tue, 9 Jul 2019 15:47:19 +0100 Subject: gdb/fortran: Implement la_print_typedef for Fortran Implement an la_print_typedef method for Fortran, this allows 'info types' to work for Fortran. The implementation is just copied from ada_print_typedef (with the appropriate changes). To support the testing of this patch I added a new proc, fortran_character1, to lib/fortran.exp which returns a regexp to match a 1-byte character type. The regexp returned is correct for current versions of gFortran. All of the other regexp are guesses based on all of the other support procs in lib/fortran.exp, I haven't tested them myself. gdb/ChangeLog: * f-lang.c (f_language_defn): Use f_print_typedef. * f-lang.h (f_print_typedef): Declare. * f-typeprint.c (f_print_typedef): Define. gdb/testsuite/ChangeLog: * gdb.fortran/info-types.exp: New file. * gdb.fortran/info-types.f90: New file. * lib/fortran.exp (fortran_character1): New proc. --- gdb/testsuite/ChangeLog | 6 +++++ gdb/testsuite/gdb.fortran/info-types.exp | 45 ++++++++++++++++++++++++++++++++ gdb/testsuite/gdb.fortran/info-types.f90 | 25 ++++++++++++++++++ gdb/testsuite/lib/fortran.exp | 12 +++++++++ 4 files changed, 88 insertions(+) create mode 100644 gdb/testsuite/gdb.fortran/info-types.exp create mode 100644 gdb/testsuite/gdb.fortran/info-types.f90 (limited to 'gdb/testsuite') diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 7b6793b..02a3c01 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-08-28 Andrew Burgess + + * gdb.fortran/info-types.exp: New file. + * gdb.fortran/info-types.f90: New file. + * lib/fortran.exp (fortran_character1): New proc. + 2019-08-27 Andrew Burgess * gdb.base/info-fun.exp: Extend to test the -n flag for 'info diff --git a/gdb/testsuite/gdb.fortran/info-types.exp b/gdb/testsuite/gdb.fortran/info-types.exp new file mode 100644 index 0000000..9571dc4 --- /dev/null +++ b/gdb/testsuite/gdb.fortran/info-types.exp @@ -0,0 +1,45 @@ +# Copyright 2019 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 . + +# This file tests 'info types' for some Fortran types. + +load_lib "fortran.exp" + +if { [skip_fortran_tests] } { continue } + +standard_testfile .f90 + +if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] } { + return -1 +} + +if { ![runto MAIN__] } { + perror "Could not run to breakpoint `MAIN__'." + continue +} + +set integer4 [fortran_int4] +set logical4 [fortran_logical4] +set character1 [fortran_character1] + +gdb_test "info types" \ + [multi_line \ + "All defined types:" \ + "" \ + "File .*:" \ + "\[\t \]+${character1}" \ + "\[\t \]+${integer4}" \ + "\[\t \]+${logical4}" \ + "16:\[\t \]+Type s1;" ] diff --git a/gdb/testsuite/gdb.fortran/info-types.f90 b/gdb/testsuite/gdb.fortran/info-types.f90 new file mode 100644 index 0000000..21c9d9d --- /dev/null +++ b/gdb/testsuite/gdb.fortran/info-types.f90 @@ -0,0 +1,25 @@ +! Copyright 2019 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, see . + +program info_types_test + type :: s1 + integer :: a + end type s1 + + logical :: l + type (s1) :: var_a + var_a%a = 1 + l = .FALSE. +end program info_types_test diff --git a/gdb/testsuite/lib/fortran.exp b/gdb/testsuite/lib/fortran.exp index d3a35cd..81811db 100644 --- a/gdb/testsuite/lib/fortran.exp +++ b/gdb/testsuite/lib/fortran.exp @@ -88,3 +88,15 @@ proc fortran_logical4 {} { return "unknown" } } + +proc fortran_character1 {} { + if {[test_compiler_info {gcc-4-[012]-*}]} { + return "character1" + } elseif {[test_compiler_info {gcc-*}]} { + return "character\\(kind=1\\)" + } elseif {[test_compiler_info {icc-*}]} { + return "CHARACTER\\(1\\)" + } else { + return "unknown" + } +} -- cgit v1.1