public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "antonio.mccarneiro at gmail dot com" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug fortran/26373] New: Printing members of parent type from an instance of an extended type Date: Tue, 11 Aug 2020 11:27:54 +0000 [thread overview] Message-ID: <bug-26373-4717@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=26373 Bug ID: 26373 Summary: Printing members of parent type from an instance of an extended type Product: gdb Version: 9.2 Status: UNCONFIRMED Severity: normal Priority: P2 Component: fortran Assignee: unassigned at sourceware dot org Reporter: antonio.mccarneiro at gmail dot com Target Milestone: --- * Scenario (see the code below): consider some Fortran module my_module which contains the definition of two derived types: test (parent) and sub_test (extends test, subclass). In addition to the two members a and b of the parent class, sub_test defines a new member c. Eventually, this module my_module is to used in some program my_program. ================================================================================ module my_module implicit none private public :: test, sub_test type :: test integer :: a = 1 integer :: b = 2 end type test type, extends(test) :: sub_test integer :: c = 3 contains procedure, public :: increment end type sub_test contains subroutine increment (this) class(sub_test) :: this this % a = this % a + 1 write(*, *) "Incrementation complete!" end subroutine increment end module my_module !--------------------------------------- program my_program use my_module implicit none type(test) :: parent type(sub_test) :: child write(*, *) "Printing parent members" write(*, *) parent % a, parent % b write(*, *) "Printing child members" write(*, *) child % a, child % b, child % c call child % increment end program my_program ================================================================================ * Objective: When debugging, using gdb, we want to print the values of the parent members a and b of some variable of the child (extended) type sub_test. In sum, we're looking for a successful completion of something like: ---------------------- (gdb) print child % a ---------------------- yet, apparently, it is not that trivial. What I have (unsuccessfully) tried so far: 1. Print directly the members from the child variable (member c prints flawlessly) ------------------------------------------------ Breakpoint 1, my_program () at test.f90:41 41 write(*, *) child % a, child % b, child % c (gdb) p child%a There is no member named a. (gdb) p child%b There is no member named b. (gdb) p child%c $1 = 3 ------------------------------------------------ 2. Print the test (parent) member of the child variable, as gdb shows it exists 3. Print the so-wanted members from the test member of child ------------------------------------------------ Breakpoint 1, my_program () at test.f90:41 41 write(*, *) child % a, child % b, child % c (gdb) p child $2 = ( test = ( a = 1, b = 2 ), c = 3 ) (gdb) p child%test A syntax error in expression, near `test'. (gdb) p child%test%a A syntax error in expression, near `test%a'. (gdb) p child%test%b A syntax error in expression, near `test%b'. ------------------------------------------------ More information: I am using gdb-9.2 and gfortran 7.5.0. -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2020-08-11 11:27 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-08-11 11:27 antonio.mccarneiro at gmail dot com [this message] 2020-08-11 11:29 ` [Bug fortran/26373] " antonio.mccarneiro at gmail dot com 2022-04-08 14:22 ` nils-christian.kempke at intel dot com
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=bug-26373-4717@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@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: linkBe 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).