From: Bernhard Heckel <bernhard.heckel@intel.com>
To: qiyaoltc@gmail.com
Cc: gdb-patches@sourceware.org, Bernhard Heckel <bernhard.heckel@intel.com>
Subject: [PATCH V2 4/7] Fortran, typeprint: Decrease level of details when printing elements of a structure.
Date: Fri, 13 May 2016 09:35:00 -0000 [thread overview]
Message-ID: <1463132086-17451-5-git-send-email-bernhard.heckel@intel.com> (raw)
In-Reply-To: <1463132086-17451-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 :: 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.fortran/derived-type.exp: Adapt expected output.
* gdb.fortran/vla-type.exp: Adapt expected output.
---
gdb/f-typeprint.c | 6 +++---
gdb/testsuite/gdb.fortran/derived-type.exp | 4 ++--
gdb/testsuite/gdb.fortran/type.f90 | 21 ++++++++++++++++++++-
gdb/testsuite/gdb.fortran/vla-type.exp | 24 ++++++------------------
gdb/testsuite/gdb.fortran/whatis_type.exp | 16 ++++++++++++++++
5 files changed, 47 insertions(+), 24 deletions(-)
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index f38a3a0..350def0 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -371,12 +371,12 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show,
fputs_filtered ("\n", stream);
for (index = 0; index < TYPE_NFIELDS (type); index++)
{
- f_type_print_base (TYPE_FIELD_TYPE (type, index), stream, show,
- level + 4);
+ f_type_print_base (TYPE_FIELD_TYPE (type, index), stream,
+ show - 1, level + 4);
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/derived-type.exp b/gdb/testsuite/gdb.fortran/derived-type.exp
index 017c6b1..73eb1f4 100644
--- a/gdb/testsuite/gdb.fortran/derived-type.exp
+++ b/gdb/testsuite/gdb.fortran/derived-type.exp
@@ -40,10 +40,10 @@ gdb_test "ptype p" "type = Type bar\r\n *$int :: c\r\n *$real :: d\r\n *End Type
set test "type-printing for derived type"
gdb_test_multiple "ptype q" $test {
- -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 $" {
+ -re "type = Type foo\r\n *$real :: a\r\n *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 *$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 $" {
+ -re "type = Type foo\r\n *$real :: a\r\n *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/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/vla-type.exp b/gdb/testsuite/gdb.fortran/vla-type.exp
index 23c287f..e1a5db1 100755
--- a/gdb/testsuite/gdb.fortran/vla-type.exp
+++ b/gdb/testsuite/gdb.fortran/vla-type.exp
@@ -99,9 +99,7 @@ gdb_test "print fivev%tone%ivla(1, 2, 3)" " = 123"
gdb_test "print fivev%tone%ivla(3, 2, 1)" " = 321"
gdb_test "ptype fivev" \
[multi_line "type = Type five" \
- "\\s+Type one" \
- "\\s+$int :: ivla\\\(10,10,10\\\)" \
- "\\s+End Type one :: tone" \
+ "\\s+Type one :: tone" \
"End Type five" ]
# Check array of types containing a VLA
@@ -114,15 +112,11 @@ gdb_test "print fivearr(2)%tone%ivla(12, 14, 16)" " = 2"
gdb_test "print fivearr(2)%tone%ivla(6, 7, 8)" " = 678"
gdb_test "ptype fivearr(1)" \
[multi_line "type = Type five" \
- "\\s+Type one" \
- "\\s+$int :: ivla\\\(2,4,6\\\)" \
- "\\s+End Type one :: tone" \
+ "\\s+Type one :: tone" \
"End Type five" ]
gdb_test "ptype fivearr(2)" \
[multi_line "type = Type five" \
- "\\s+Type one" \
- "\\s+$int :: ivla\\\(12,14,16\\\)" \
- "\\s+End Type one :: tone" \
+ "\\s+Type one :: tone" \
"End Type five" ]
# Check allocation status of dynamic array and it's dynamic members
@@ -130,9 +124,7 @@ gdb_test "ptype fivedynarr" "type = <not allocated>"
gdb_test "next" ""
gdb_test "ptype fivedynarr(2)" \
[multi_line "type = Type five" \
- "\\s+Type one" \
- "\\s+$int :: ivla\\\(<not allocated>\\\)" \
- "\\s+End Type one :: tone" \
+ "\\s+Type one :: tone" \
"End Type five" ]
# Check dynamic array of types containing a VLA
@@ -145,13 +137,9 @@ gdb_test "print fivedynarr(2)%tone%ivla(12, 14, 16)" " = 2"
gdb_test "print fivedynarr(2)%tone%ivla(6, 7, 8)" " = 678"
gdb_test "ptype fivedynarr(1)" \
[multi_line "type = Type five" \
- "\\s+Type one" \
- "\\s+$int :: ivla\\\(2,4,6\\\)" \
- "\\s+End Type one :: tone" \
+ "\\s+Type one :: tone" \
"End Type five" ]
gdb_test "ptype fivedynarr(2)" \
[multi_line "type = Type five" \
- "\\s+Type one" \
- "\\s+$int :: ivla\\\(12,14,16\\\)" \
- "\\s+End Type one :: tone" \
+ "\\s+Type one :: tone" \
"End Type five" ]
diff --git a/gdb/testsuite/gdb.fortran/whatis_type.exp b/gdb/testsuite/gdb.fortran/whatis_type.exp
index 0b7a1b7..955f853 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" \
@@ -53,3 +57,15 @@ gdb_test "ptype t1v" \
" $t1_r" \
"End Type t1"] \
"ptype t1v"
+
+gdb_test "ptype t2v" \
+ [multi_line "type = Type t2" \
+ " $int :: t2_i" \
+ " Type t1 :: t1_n" \
+ "End Type t2"]
+
+gdb_test "ptype t3v" \
+ [multi_line "type = Type t3" \
+ " $int :: t3_i" \
+ " Type t2 :: t2_n" \
+ "End Type t3"]
--
2.7.1.339.g0233b80
next prev parent reply other threads:[~2016-05-13 9:35 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-13 9:34 [PATCH V2 0/7] Fortran, typeprint Bernhard Heckel
2016-05-13 9:35 ` [PATCH V2 2/7] Fortran, typeprint: Fix wrong indentation when ptype nested structures Bernhard Heckel
2016-05-13 14:05 ` Yao Qi
2016-05-13 9:35 ` [PATCH V2 1/7] Fortran, testsuite: Use multi_line in whatis_type testcase Bernhard Heckel
2016-05-13 14:01 ` Yao Qi
2016-05-13 9:35 ` Bernhard Heckel [this message]
2016-05-13 14:12 ` [PATCH V2 4/7] Fortran, typeprint: Decrease level of details when printing elements of a structure Yao Qi
2016-05-13 9:35 ` [PATCH V2 7/7] Fortran, typeprint: Forward level of details to be printed for pointers Bernhard Heckel
2016-05-13 15:57 ` Yao Qi
2016-05-13 9:35 ` [PATCH V2 5/7] Fortran, testsuite: Add testcases for nested structures Bernhard Heckel
2016-05-13 14:17 ` Yao Qi
2016-05-13 9:35 ` [PATCH V2 6/7] Fortran, testsuite: Fix duplicate testcase name Bernhard Heckel
2016-05-13 14:20 ` Yao Qi
2016-05-17 12:53 ` Bernhard Heckel
2016-05-18 13:29 ` Bernhard Heckel
2016-05-23 11:15 ` [PING][PATCH " Bernhard Heckel
2016-05-23 13:22 ` [PATCH " Yao Qi
2016-05-13 9:35 ` [PATCH V2 3/7] Fortran, typeprint: Take level of details into account when printing elements of a structure Bernhard Heckel
2016-05-13 15:58 ` Yao Qi
2016-05-25 7:13 ` [PUSHED][PATCH V2 0/7] Fortran, typeprint Bernhard Heckel
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=1463132086-17451-5-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).