From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33920 invoked by alias); 28 Aug 2019 12:37:00 -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 33617 invoked by uid 89); 28 Aug 2019 12:37:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-wr1-f67.google.com Received: from mail-wr1-f67.google.com (HELO mail-wr1-f67.google.com) (209.85.221.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 28 Aug 2019 12:36:57 +0000 Received: by mail-wr1-f67.google.com with SMTP id j11so1524452wrp.11 for ; Wed, 28 Aug 2019 05:36:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=j2T4TASzXqmhXUjpbv3w92rC3JkznzNq38h9Tp++9Gk=; b=UDeJEvHganmOxPyJeOMaZTdaSvH88f9wDBk8YX4skJ+DUhxgVtoN9cX6sQ2pHeyX7S JqrJibTZ6IuX066HCd1igDs1j2a8w4HTCfo9zFl/NEpXZ8+6tFooT1LXWyVn8OGvqM4H FJ0NIMEpXKpRdWFBYCg9sxaosW1I4js6546qrLup1Xc2Uk8eHukkbZO/VgiipTS/jh36 71GtltCf7Ppv8diglMbrggHwgOxe9FtJzksCzg1YcOlG1LQ44j7dJCpNTRbk/zM5F80b 5c6IAqjE+xt+nbXrEfkaxV/2+qdMR3c5RW/PMF728VWcOA0GgObIOOUUJm1RSZ2CNocs dNPQ== Return-Path: Received: from localhost (host86-161-16-231.range86-161.btcentralplus.com. [86.161.16.231]) by smtp.gmail.com with ESMTPSA id t14sm2543721wrv.12.2019.08.28.05.36.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Aug 2019 05:36:54 -0700 (PDT) Date: Wed, 28 Aug 2019 12:37:00 -0000 From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Richard Bunt Subject: Re: [PATCH 4/7] gdb/fortran: Implement la_print_typedef for Fortran Message-ID: <20190828123654.GV6076@embecosm.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Fortune: 50% of the manual is in .pdf readme files X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes X-SW-Source: 2019-08/txt/msg00632.txt.bz2 * Andrew Burgess [2019-07-27 17:22:32 +0100]: > 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. I've now pushed this patch as it didn't depend on anything else in the series. Thanks, Andrew > --- > gdb/ChangeLog | 6 +++++ > gdb/f-lang.c | 2 +- > gdb/f-lang.h | 5 ++++ > gdb/f-typeprint.c | 11 ++++++++ > 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 +++++++++ > 8 files changed, 111 insertions(+), 1 deletion(-) > create mode 100644 gdb/testsuite/gdb.fortran/info-types.exp > create mode 100644 gdb/testsuite/gdb.fortran/info-types.f90 > > diff --git a/gdb/f-lang.c b/gdb/f-lang.c > index e93a5f34276..ce7f1471c52 100644 > --- a/gdb/f-lang.c > +++ b/gdb/f-lang.c > @@ -644,7 +644,7 @@ extern const struct language_defn f_language_defn = > f_printstr, /* function to print string constant */ > f_emit_char, /* Function to print a single character */ > f_print_type, /* Print a type using appropriate syntax */ > - default_print_typedef, /* Print a typedef using appropriate syntax */ > + f_print_typedef, /* Print a typedef using appropriate syntax */ > f_val_print, /* Print a value using appropriate syntax */ > c_value_print, /* FIXME */ > default_read_var_value, /* la_read_var_value */ > diff --git a/gdb/f-lang.h b/gdb/f-lang.h > index 1ba529d76c5..cf6024c4454 100644 > --- a/gdb/f-lang.h > +++ b/gdb/f-lang.h > @@ -28,6 +28,11 @@ struct parser_state; > > extern int f_parse (struct parser_state *); > > +/* Implement the la_print_typedef language method for Fortran. */ > + > +extern void f_print_typedef (struct type *type, struct symbol *new_symbol, > + struct ui_file *stream); > + > extern void f_print_type (struct type *, const char *, struct ui_file *, int, > int, const struct type_print_options *); > > diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c > index 17ac02f4ccf..92b50938740 100644 > --- a/gdb/f-typeprint.c > +++ b/gdb/f-typeprint.c > @@ -45,6 +45,17 @@ void f_type_print_varspec_prefix (struct type *, struct ui_file *, > void f_type_print_base (struct type *, struct ui_file *, int, int); > > > +/* See documentation in f-lang.h. */ > + > +void > +f_print_typedef (struct type *type, struct symbol *new_symbol, > + struct ui_file *stream) > +{ > + type = check_typedef (type); > + f_print_type (type, "", stream, 0, 0, &type_print_raw_options); > + fprintf_filtered (stream, "\n"); > +} > + > /* LEVEL is the depth to indent lines by. */ > > void > diff --git a/gdb/testsuite/gdb.fortran/info-types.exp b/gdb/testsuite/gdb.fortran/info-types.exp > new file mode 100644 > index 00000000000..9571dc45593 > --- /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 00000000000..21c9d9df63c > --- /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 d3a35cd291e..81811dbc3c9 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" > + } > +} > -- > 2.14.5 >