This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 1/2] Fixed indentation for printing Fortran types with pointers
- From: Tom Tromey <tromey at redhat dot com>
- To: Christoph Weinmann <christoph dot t dot weinmann at intel dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 24 Sep 2013 11:08:25 -0600
- Subject: Re: [PATCH 1/2] Fixed indentation for printing Fortran types with pointers
- Authentication-results: sourceware.org; auth=none
- References: <1380031929-22345-1-git-send-email-christoph dot t dot weinmann at intel dot com> <1380031929-22345-2-git-send-email-christoph dot t dot weinmann at intel dot com>
>>>>> "Christoph" == Christoph Weinmann <christoph.t.weinmann@intel.com> writes:
Christoph> Changelog:
Christoph> 2013-09-24 Frank Penczek <frank.penczek@intel.com>
Christoph> Christoph Weinmann <christoph.t.weinmann@intel.com>
Christoph> * f-typeprint.c (f_type_print_base): Use fprintfi_filtered to
Christoph> maintain proper indentation when printing pointers/refs.
Christoph> testsuite/
Christoph> * gdb.fortran/ptr-indentation.f90: Add Fortran example for
Christoph> testing the indentation when printing user-defined types
Christoph> with pointers.
Christoph> * gdb.fortran/ptr-indentation.exp: Add test case for the
Christoph> indentation when printing pointers in user-defined types.
This is ok. Thanks!
Christoph> Change-Id: I3bb607e3044e29b0a10fd6c6ea25c20e14882320
Christoph> Signed-off-by: Frank Penczek <frank.penczek@intel.com>
Christoph> ---
Christoph> gdb/f-typeprint.c | 4 +-
Christoph> gdb/testsuite/gdb.fortran/ptr-indentation.exp | 45 +++++++++++++++++++++++++
Christoph> gdb/testsuite/gdb.fortran/ptr-indentation.f90 | 36 ++++++++++++++++++++
Christoph> 3 files changed, 83 insertions(+), 2 deletions(-)
Christoph> create mode 100644 gdb/testsuite/gdb.fortran/ptr-indentation.exp
Christoph> create mode 100644 gdb/testsuite/gdb.fortran/ptr-indentation.f90
Christoph> diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
Christoph> index aa33231..71fe869 100644
Christoph> --- a/gdb/f-typeprint.c
Christoph> +++ b/gdb/f-typeprint.c
Christoph> @@ -290,12 +290,12 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show,
Christoph> break;
Christoph> case TYPE_CODE_PTR:
Christoph> - fprintf_filtered (stream, "PTR TO -> ( ");
Christoph> + fprintfi_filtered (level, stream, "PTR TO -> ( ");
Christoph> f_type_print_base (TYPE_TARGET_TYPE (type), stream, 0, level);
Christoph> break;
Christoph> case TYPE_CODE_REF:
Christoph> - fprintf_filtered (stream, "REF TO -> ( ");
Christoph> + fprintfi_filtered (level, stream, "REF TO -> ( ");
Christoph> f_type_print_base (TYPE_TARGET_TYPE (type), stream, 0, level);
Christoph> break;
Christoph> diff --git a/gdb/testsuite/gdb.fortran/ptr-indentation.exp b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
Christoph> new file mode 100644
Christoph> index 0000000..af9ae28
Christoph> --- /dev/null
Christoph> +++ b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
Christoph> @@ -0,0 +1,45 @@
Christoph> +# Copyright 2013 Free Software Foundation, Inc.
Christoph> +#
Christoph> +# Contributed by Intel Corp.<christoph.t.weinmann@intel.com>
Christoph> +#
Christoph> +# This program is free software; you can redistribute it and/or modify
Christoph> +# it under the terms of the GNU General Public License as published by
Christoph> +# the Free Software Foundation; either version 3 of the License, or
Christoph> +# (at your option) any later version.
Christoph> +#
Christoph> +# This program is distributed in the hope that it will be useful,
Christoph> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
Christoph> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Christoph> +# GNU General Public License for more details.
Christoph> +#
Christoph> +# You should have received a copy of the GNU General Public License
Christoph> +# along with this program. If not, see <http://www.gnu.org/licenses/>.
Christoph> +
Christoph> +if {[skip_fortran_tests]} {
Christoph> + return -1
Christoph> +}
Christoph> +
Christoph> +standard_testfile .f90
Christoph> +
Christoph> +if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
Christoph> + return -1
Christoph> +}
Christoph> +
Christoph> +if {![runto MAIN__]} then {
Christoph> + perror "couldn't run to breakpoint MAIN__"
Christoph> + continue
Christoph> +}
Christoph> +
Christoph> +# Depending on the compiler version being used, the name of the 4-byte integer
Christoph> +# types can be printed differently. For instance, gfortran-4.1 uses "int4"
Christoph> +# whereas gfortran-4.3 uses "int(kind=4)".
Christoph> +set int4 "(int4|integer\\(kind=4\\))"
Christoph> +
Christoph> +gdb_breakpoint [gdb_get_line_number "BP1"]
Christoph> +gdb_continue_to_breakpoint "BP1"
Christoph> +
Christoph> +# Check the indentation when using ptype on pointers in user-defined types.
Christoph> +gdb_test "ptype tinsta" \
Christoph> + ".*${int4} :: i\r\n PTR TO.*" \
Christoph> + "Test indentation of scalar and pointer inside a type."
Christoph> +
Christoph> diff --git a/gdb/testsuite/gdb.fortran/ptr-indentation.f90 b/gdb/testsuite/gdb.fortran/ptr-indentation.f90
Christoph> new file mode 100644
Christoph> index 0000000..0e62c20
Christoph> --- /dev/null
Christoph> +++ b/gdb/testsuite/gdb.fortran/ptr-indentation.f90
Christoph> @@ -0,0 +1,36 @@
Christoph> +! Test program for printing indentation of pointers in user-defined
Christoph> +! types.
Christoph> +!
Christoph> +! Copyright 2013 Free Software Foundation, Inc.
Christoph> +!
Christoph> +! Contributed by Intel Corp. <christoph.t.weinmann@intel.com>
Christoph> +!
Christoph> +! This program is free software; you can redistribute it and/or modify
Christoph> +! it under the terms of the GNU General Public License as published by
Christoph> +! the Free Software Foundation; either version 3 of the License, or
Christoph> +! (at your option) any later version.
Christoph> +!
Christoph> +! This program is distributed in the hope that it will be useful,
Christoph> +! but WITHOUT ANY WARRANTY; without even the implied warranty of
Christoph> +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Christoph> +! GNU General Public License for more details.
Christoph> +!
Christoph> +! You should have received a copy of the GNU General Public License
Christoph> +! along with this program. If not, see <http://www.gnu.org/licenses/>.
Christoph> +
Christoph> +program main
Christoph> + implicit none
Christoph> +
Christoph> + type tuserdef
Christoph> + integer :: i
Christoph> + real, pointer :: ptr
Christoph> + end type tuserdef
Christoph> + real, target :: rval
Christoph> +
Christoph> + type(tuserdef), target:: tinsta,tinstb,tinstc
Christoph> +
Christoph> + tinsta%i = 4
Christoph> + tinsta%ptr => rval !BP1
Christoph> +
Christoph> +end program main
Christoph> +
Christoph> --
Christoph> 1.7.0.7
Tom