public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Bernhard Heckel <bernhard.heckel@intel.com>
To: qiyaoltc@gmail.com
Cc: gdb-patches@sourceware.org, Bernhard Heckel <bernhard.heckel@intel.com>
Subject: [PATCH 3/4] Fortran, typeprint: Decrease level of details when printing elements of a structure.
Date: Tue, 10 May 2016 14:16:00 -0000	[thread overview]
Message-ID: <1462889739-30359-4-git-send-email-bernhard.heckel@intel.com> (raw)
In-Reply-To: <1462889739-30359-1-git-send-email-bernhard.heckel@intel.com>

According to the typeprint's description, the level of details is
decreased by one for the typeprint of elements of a structure.

Before:
(gdb) ptype t3v
type = Type t3
    integer(kind=4) :: t3_i
    Type t2
        integer(kind=4) :: t2_i
        Type t1
            integer(kind=4) :: t1_i
            real(kind=4) :: t1_r
        End Type t1 :: t1_n
    End Type t2 :: t2_n
End Type t3

After:
(gdb) ptype t3v
type = Type t3
    integer(kind=4) :: t3_i
    Type t2
        integer(kind=4) :: t2_i
        Type t1 :: t1_n
    End Type t2 :: t2_n
End Type t3

2016-05-09  Bernhard Heckel  <bernhard.heckel@intel.com>

gdb/Changelog:
	* f-typeprint.c (f_type_print_base): Decrease show by one.

gdb/testsuite/Changelog:
	* gdb.fortran/type.f90: Add nested structures.
	* gdb.fortran/whatis_type.exp: Whatis/ptype nested structures.

---
 gdb/f-typeprint.c                         |  2 +-
 gdb/testsuite/gdb.fortran/type.f90        | 21 ++++++++++++++++++++-
 gdb/testsuite/gdb.fortran/whatis_type.exp | 22 ++++++++++++++++++++++
 3 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index 49f374a..0389c14 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -376,7 +376,7 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show,
 	      fputs_filtered (" :: ", stream);
 	      fputs_filtered (TYPE_FIELD_NAME (type, index), stream);
 	      f_type_print_varspec_suffix (TYPE_FIELD_TYPE (type, index),
-					   stream, 0, 0, 0, 0);
+					   stream, show - 1, 0, 0, 0);
 	      fputs_filtered ("\n", stream);
 	    }
 	  fprintfi_filtered (level, stream, "End Type ");
diff --git a/gdb/testsuite/gdb.fortran/type.f90 b/gdb/testsuite/gdb.fortran/type.f90
index b3ae693..00dc650 100644
--- a/gdb/testsuite/gdb.fortran/type.f90
+++ b/gdb/testsuite/gdb.fortran/type.f90
@@ -21,8 +21,27 @@ program type
     real    :: t1_r
   end type t1
 
+  type :: t2
+    integer :: t2_i
+    type (t1) :: t1_n
+  end type t2
+
+  type :: t3
+    integer :: t3_i
+    type (t2) :: t2_n
+  end type t3
+
   type (t1) :: t1v
+  type (t2) :: t2v
+  type (t3) :: t3v
 
   t1v%t1_i = 42
-  t1v%t1_r = 42.24    ! bp1
+  t1v%t1_r = 42.24
+
+  t2v%t2_i = 2
+  t2v%t1_n%t1_i = 21
+  t3v%t3_i = 3
+  t3v%t2_n%t2_i = 32
+  t3v%t2_n%t1_n%t1_i = 321    ! bp1
+
 end program type
diff --git a/gdb/testsuite/gdb.fortran/whatis_type.exp b/gdb/testsuite/gdb.fortran/whatis_type.exp
index 2caebe6..c1e2745 100644
--- a/gdb/testsuite/gdb.fortran/whatis_type.exp
+++ b/gdb/testsuite/gdb.fortran/whatis_type.exp
@@ -40,6 +40,10 @@ set t1_r "$real :: t1_r"
 
 gdb_test "whatis t1" "type = Type t1"
 gdb_test "whatis t1v" "type = Type t1"
+gdb_test "whatis t2" "type = Type t2"
+gdb_test "whatis t2v" "type = Type t2"
+gdb_test "whatis t3" "type = Type t3"
+gdb_test "whatis t3v" "type = Type t3"
 
 gdb_test "ptype t1" \
     [multi_line "type = Type t1" \
@@ -52,3 +56,21 @@ gdb_test "ptype t1v" \
 	"    $t1_i" \
 	"    $t1_r" \
 	"End Type t1"]
+
+gdb_test "ptype t2v" \
+    [multi_line "type = Type t2" \
+                "    $int :: t2_i" \
+                "    Type t1" \
+                "        $int :: t1_i" \
+                "        $real :: t1_r" \
+                "    End Type t1 :: t1_n" \
+                "End Type t2"]
+
+gdb_test "ptype t3v" \
+    [multi_line "type = Type t3" \
+                "    $int :: t3_i" \
+                "    Type t2" \
+                "        $int :: t2_i" \
+                "        Type t1 :: t1_n" \
+                "    End Type t2 :: t2_n" \
+                "End Type t3"]
-- 
2.7.1.339.g0233b80

  reply	other threads:[~2016-05-10 14:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-10 14:16 [PATCH 0/4] Fortran, typeprint Bernhard Heckel
2016-05-10 14:16 ` Bernhard Heckel [this message]
2016-05-11 13:40   ` [PATCH 3/4] Fortran, typeprint: Decrease level of details when printing elements of a structure Yao Qi
2016-05-12  8:00     ` Bernhard Heckel
2016-05-12 12:45       ` Yao Qi
2016-05-10 14:16 ` [PATCH 1/4] Fortran, typeprint: Fix wrong indentation when ptype nested structures Bernhard Heckel
2016-05-11 11:58   ` Yao Qi
2016-05-11 11:59   ` Yao Qi
2016-05-10 14:16 ` [PATCH 2/4] Fortran, typeprint: Take level of details into account when printing elements of a structure Bernhard Heckel
2016-05-11 12:09   ` Yao Qi
2016-05-12 12:06   ` Yao Qi
2016-05-12 12:42     ` Bernhard Heckel
2016-05-10 14:18 ` [PATCH 4/4] Fortran, typeprint: Forward level of details to be printed for pointers Bernhard Heckel
2016-05-11 13:42   ` Yao Qi
2016-05-13 14:27   ` Yao Qi
2016-05-13 15:55     ` Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1462889739-30359-4-git-send-email-bernhard.heckel@intel.com \
    --to=bernhard.heckel@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=qiyaoltc@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).