From: Tim Wiederhake <tim.wiederhake@intel.com>
To: gdb-patches@sourceware.org
Cc: Bernhard Heckel <bernhard.heckel@intel.com>
Subject: [PATCH 3/6] Fortran: Ptype, print type extension.
Date: Fri, 21 Jul 2017 09:25:00 -0000 [thread overview]
Message-ID: <1500629040-12972-4-git-send-email-tim.wiederhake@intel.com> (raw)
In-Reply-To: <1500629040-12972-1-git-send-email-tim.wiederhake@intel.com>
From: Bernhard Heckel <bernhard.heckel@intel.com>
Print base-class of an extended type when doing a ptype.
xxxx-yy-zz Bernhard Heckel <bernhard.heckel@intel.com>
gdb/ChangeLog:
* gdb/f-typeprint.c (f_type_print_derivation_info): New function.
(f_type_print_base): Print baseclass info.
gdb/testsuite/ChangeLog:
* gdb.fortran/oop_extend_type.exp: Adapt expected results.
---
gdb/f-typeprint.c | 31 ++++++++++++++++++++++++---
gdb/testsuite/gdb.fortran/oop_extend_type.exp | 30 ++++++++++++++++++++------
2 files changed, 51 insertions(+), 10 deletions(-)
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index 7dbe093..64b2f92 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -256,6 +256,26 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
}
}
+/* If TYPE is an extended type, then print out derivation information.
+
+ A typical output could look like this:
+ "Type, extends(point) :: waypoint"
+ " Type point :: point"
+ " real(kind=4) :: angle"
+ "End Type waypoint"
+ */
+
+static void
+f_type_print_derivation_info (struct type *type, struct ui_file *stream)
+{
+ /* Fortran doesn't support multiple inheritance. */
+ int i = 0;
+
+ if (TYPE_N_BASECLASSES (type) > 0)
+ fprintf_filtered (stream, ", extends(%s) ::",
+ type_name_no_tag (TYPE_BASECLASS (type, i)));
+}
+
/* Print the name of the type (or the ultimate pointer target,
function value or array element), or the description of a
structure or union.
@@ -362,10 +382,15 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show,
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
if (TYPE_CODE (type) == TYPE_CODE_UNION)
- fprintfi_filtered (level, stream, "Type, C_Union :: ");
+ fprintfi_filtered (level, stream, "Type, C_Union ::");
else
- fprintfi_filtered (level, stream, "Type ");
- fputs_filtered (TYPE_TAG_NAME (type), stream);
+ fprintfi_filtered (level, stream, "Type");
+
+ if (show > 0)
+ f_type_print_derivation_info (type, stream);
+
+ fprintf_filtered (stream, " %s", TYPE_TAG_NAME (type));
+
/* According to the definition,
we only print structure elements in case show > 0. */
if (show > 0)
diff --git a/gdb/testsuite/gdb.fortran/oop_extend_type.exp b/gdb/testsuite/gdb.fortran/oop_extend_type.exp
index a880414..200ce7b 100644
--- a/gdb/testsuite/gdb.fortran/oop_extend_type.exp
+++ b/gdb/testsuite/gdb.fortran/oop_extend_type.exp
@@ -50,11 +50,23 @@ gdb_test "p wp%point" " = \\( coo = \\(1, 2, 1\\) \\)"
gdb_test "p wp" " = \\( point = \\( coo = \\(1, 2, 1\\) \\), angle = 100 \\)"
gdb_test "whatis wp" "type = Type waypoint"
-gdb_test "ptype wp" \
- [multi_line "type = Type waypoint" \
+set output_pass [multi_line "type = Type, extends\\(point\\) :: waypoint" \
" Type point :: point" \
" $real :: angle" \
"End Type waypoint"]
+set output_kfail [multi_line "type = Type waypoint" \
+ " Type point :: point" \
+ " $real :: angle" \
+ "End Type waypoint"]
+set test "ptype wp"
+gdb_test_multiple $test %test {
+ -re "$output_pass\r\n$gdb_prompt $" {
+ pass "$test"
+ }
+ -re "$output_kfail\r\n$gdb_prompt $" {
+ kfail "gcc/49475" "$test"
+ }
+}
set test "ptype wp%coo"
gdb_test_multiple "$test" "$test" {
-re "$real \\(3\\)\r\n$gdb_prompt $" {
@@ -80,11 +92,15 @@ gdb_test "p wp_vla(1)%point" " = \\( coo = \\(10, 12, 10\\) \\)"
gdb_test "p wp_vla(1)" " = \\( point = \\( coo = \\(10, 12, 10\\) \\), angle = 101 \\)"
gdb_test "whatis wp_vla" "type = Type waypoint \\(3\\)"
-gdb_test "ptype wp_vla" \
- [multi_line "type = Type waypoint" \
- " Type point :: point" \
- " $real :: angle" \
- "End Type waypoint \\(3\\)"]
+set test "ptype wp_vla"
+gdb_test_multiple $test %test {
+ -re "$output_pass \\(3\\)\r\n$gdb_prompt $" {
+ pass "$test"
+ }
+ -re "$output_kfail \\(3\\)\r\n$gdb_prompt $" {
+ kfail "gcc/49475" "$test"
+ }
+}
set test "ptype wp_vla(1)%coo"
gdb_test_multiple "$test" "$test" {
-re "$real \\(3\\)\r\n$gdb_prompt $" {
--
2.7.4
next prev parent reply other threads:[~2017-07-21 9:25 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-21 9:25 [PATCH 0/6] Some Fortran patches Tim Wiederhake
2017-07-21 9:25 ` [PATCH 6/6] Fortran: Nested functions, add scope parameter Tim Wiederhake
2017-07-21 9:25 ` [PATCH 1/6] DWARF: Don't add nameless modules to partial symbol table Tim Wiederhake
2017-07-31 22:09 ` Yao Qi
2017-08-01 12:47 ` Wiederhake, Tim
2017-08-02 11:16 ` Yao Qi
2017-08-04 11:03 ` Wiederhake, Tim
2017-07-21 9:25 ` [PATCH 2/6] Fortran: Accessing fields of inherited types via fully qualified name Tim Wiederhake
2017-07-21 9:25 ` Tim Wiederhake [this message]
2017-08-07 12:08 ` [PATCH 3/6] Fortran: Ptype, print type extension Yao Qi
2017-07-21 9:25 ` [PATCH 4/6] Dwarf: Fortran, support DW_TAG_entry_point Tim Wiederhake
2017-07-31 22:20 ` Yao Qi
2017-08-02 13:14 ` Yao Qi
[not found] ` <9676A094AF46E14E8265E7A3F4CCE9AF5AC20F28@irsmsx105.ger.corp.intel.com>
2017-08-07 8:46 ` Wiederhake, Tim
2017-08-07 11:29 ` Yao Qi
2017-08-08 14:36 ` Wiederhake, Tim
2017-07-21 9:25 ` [PATCH 5/6] Fortran: Enable setting breakpoint on nested functions Tim Wiederhake
2017-07-28 8:19 ` [PATCH 0/6] Some Fortran patches Wiederhake, Tim
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=1500629040-12972-4-git-send-email-tim.wiederhake@intel.com \
--to=tim.wiederhake@intel.com \
--cc=bernhard.heckel@intel.com \
--cc=gdb-patches@sourceware.org \
/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