Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Walfred Tedeschi <walfred.tedeschi@intel.com>
To: Yao Qi <qiyaoltc@gmail.com>
Cc: Pedro Alves <palves@redhat.com>,
	gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH V2] Improve user experience in printing Fortran derived types.
Date: Mon, 02 May 2016 12:35:00 -0000	[thread overview]
Message-ID: <57274976.3000903@intel.com> (raw)
In-Reply-To: <8660vwnsb3.fsf@gmail.com>

Am 4/5/2016 um 2:39 PM schrieb Yao Qi:
> Walfred Tedeschi <walfred.tedeschi@intel.com> writes:
>
>> Here member functions, or methods of the derived type, are discarded.
>
> OK, so can we have a test case shown that methods of the derived type
> are discarded in printing?
>

Yao,

Given a sample like:

module class_Square
   implicit none
   private

   type, public :: Square
      real :: height
    contains
      procedure :: area => square_area
      procedure :: print_area => print_area
   end type Square
contains
   function square_area(this) result(area)
     class(Square), intent(in) :: this
     real :: area
     area = this%height**2
   end function square_area

   subroutine print_area(this)
     class(Square), intent(in) :: this
     real :: area
     area = this%area()
     print *, ' area = ', area
   end subroutine print_area
end module class_Square


program square_Test
   use class_Square
   implicit none

   type(Square) :: aSquare
   aSquare = Square(2.1)
   call aSquare%print_area

end program square_test



The readelf for the binary is:
<1><2e>: Abbrev Number: 2 (DW_TAG_module)
     <2f>   DW_AT_decl_line   : 1
     <30>   DW_AT_decl_file   : 1
     <31>   DW_AT_name        : (indirect string, offset: 0xd9): 
class_square
  <2><35>: Abbrev Number: 3 (DW_TAG_subprogram)
     <36>   DW_AT_decl_line   : 11
     <37>   DW_AT_decl_file   : 1
     <38>   DW_AT_name        : (indirect string, offset: 0xe6): 
CLASS_SQUARE
     <3c>   DW_AT_low_pc      : 0x402640
     <44>   DW_AT_high_pc     : 0x402646
     <4c>   DW_AT_external    : 1
  <2><4d>: Abbrev Number: 4 (DW_TAG_subprogram)
     <4e>   DW_AT_decl_line   : 12
     <4f>   DW_AT_decl_file   : 1
     <50>   DW_AT_type        : <0x126>
     <54>   DW_AT_name        : (indirect string, offset: 0xfb): square_area
     <58>   DW_AT_low_pc      : 0x402646
     <60>   DW_AT_high_pc     : 0x402688
     <68>   DW_AT_external    : 1
  <3><69>: Abbrev Number: 5 (DW_TAG_formal_parameter)
     <6a>   DW_AT_decl_line   : 12
     <6b>   DW_AT_decl_file   : 1
     <6c>   DW_AT_type        : <0x12d>
     <70>   DW_AT_name        : (indirect string, offset: 0x124): this
     <74>   DW_AT_location    : 3 byte block: 76 68 6 	(DW_OP_breg6 
(rbp): -24; DW_OP_deref)
  <3><78>: Abbrev Number: 6 (DW_TAG_structure_type)
     <79>   DW_AT_decl_line   : 5
     <7a>   DW_AT_decl_file   : 1
     <7b>   DW_AT_byte_size   : 4
     <7c>   DW_AT_name        : (indirect string, offset: 0xdf): square
  <4><80>: Abbrev Number: 7 (DW_TAG_member)
     <81>   DW_AT_decl_line   : 5
     <82>   DW_AT_decl_file   : 1
     <83>   DW_AT_data_member_location: 2 byte block: 23 0 
(DW_OP_plus_uconst: 0)
     <86>   DW_AT_name        : (indirect string, offset: 0x107): height
     <8a>   DW_AT_type        : <0x126>
  <4><8e>: Abbrev Number: 7 (DW_TAG_member)
     <8f>   DW_AT_decl_line   : 5
     <90>   DW_AT_decl_file   : 1
     <91>   DW_AT_data_member_location: 2 byte block: 23 0 
(DW_OP_plus_uconst: 0)
     <94>   DW_AT_name        : (indirect string, offset: 0x102): area
     <98>   DW_AT_type        : <0x138>
  <4><9c>: Abbrev Number: 7 (DW_TAG_member)
     <9d>   DW_AT_decl_line   : 5
     <9e>   DW_AT_decl_file   : 1
     <9f>   DW_AT_data_member_location: 2 byte block: 23 0 
(DW_OP_plus_uconst: 0)
     <a2>   DW_AT_name        : (indirect string, offset: 0x119): print_area
     <a6>   DW_AT_type        : <0x143>
  <4><aa>: Abbrev Number: 0
  <3><ab>: Abbrev Number: 8 (DW_TAG_variable)
     <ac>   DW_AT_decl_line   : 12
     <ad>   DW_AT_decl_file   : 1
     <ae>   DW_AT_name        : (indirect string, offset: 0x102): area
     <b2>   DW_AT_type        : <0x126>
     <b6>   DW_AT_location    : 2 byte block: 76 64 	(DW_OP_breg6 (rbp): 
-28)
  <3><b9>: Abbrev Number: 0
  <2><ba>: Abbrev Number: 9 (DW_TAG_subprogram)
     <bb>   DW_AT_decl_line   : 18
     <bc>   DW_AT_decl_file   : 1
     <bd>   DW_AT_name        : (indirect string, offset: 0x119): print_area
     <c1>   DW_AT_low_pc      : 0x402688
     <c9>   DW_AT_high_pc     : 0x40274a
     <d1>   DW_AT_external    : 1
  <3><d2>: Abbrev Number: 5 (DW_TAG_formal_parameter)
     <d3>   DW_AT_decl_line   : 18
     <d4>   DW_AT_decl_file   : 1
     <d5>   DW_AT_type        : <0x14a>
     <d9>   DW_AT_name        : (indirect string, offset: 0x124): this
     <dd>   DW_AT_location    : 4 byte block: 76 88 7f 6 	(DW_OP_breg6 
(rbp): -120; DW_OP_deref)
  <3><e2>: Abbrev Number: 6 (DW_TAG_structure_type)
     <e3>   DW_AT_decl_line   : 5
     <e4>   DW_AT_decl_file   : 1
     <e5>   DW_AT_byte_size   : 4
     <e6>   DW_AT_name        : (indirect string, offset: 0xdf): square
  <4><ea>: Abbrev Number: 7 (DW_TAG_member)
     <eb>   DW_AT_decl_line   : 5
     <ec>   DW_AT_decl_file   : 1
     <ed>   DW_AT_data_member_location: 2 byte block: 23 0 
(DW_OP_plus_uconst: 0)
     <f0>   DW_AT_name        : (indirect string, offset: 0x107): height
     <f4>   DW_AT_type        : <0x126>
  <4><f8>: Abbrev Number: 7 (DW_TAG_member)
     <f9>   DW_AT_decl_line   : 5
     <fa>   DW_AT_decl_file   : 1
     <fb>   DW_AT_data_member_location: 2 byte block: 23 0 
(DW_OP_plus_uconst: 0)
     <fe>   DW_AT_name        : (indirect string, offset: 0x102): area
     <102>   DW_AT_type        : <0x155>
  <4><106>: Abbrev Number: 7 (DW_TAG_member)
     <107>   DW_AT_decl_line   : 5
     <108>   DW_AT_decl_file   : 1
     <109>   DW_AT_data_member_location: 2 byte block: 23 0 
(DW_OP_plus_uconst: 0)
     <10c>   DW_AT_name        : (indirect string, offset: 0x119): 
print_area
     <110>   DW_AT_type        : <0x160>
  <4><114>: Abbrev Number: 0
  <3><115>: Abbrev Number: 8 (DW_TAG_variable)
     <116>   DW_AT_decl_line   : 20
     <117>   DW_AT_decl_file   : 1
     <118>   DW_AT_name        : (indirect string, offset: 0x102): area
     <11c>   DW_AT_type        : <0x126>
     <120>   DW_AT_location    : 3 byte block: 76 84 7f 	(DW_OP_breg6 
(rbp): -124)
  <3><124>: Abbrev Number: 0
  <2><125>: Abbrev Number: 0
  <1><126>: Abbrev Number: 10 (DW_TAG_base_type)
     <127>   DW_AT_byte_size   : 4
     <128>   DW_AT_encoding    : 4	(float)
     <129>   DW_AT_name        : (indirect string, offset: 0xf3): REAL(4)
  <1><12d>: Abbrev Number: 11 (DW_TAG_pointer_type)
     <12e>   DW_AT_type        : <0x78>
     <132>   DW_AT_associated  : 5 byte block: 97 6 10 0 2e 
(DW_OP_push_object_address; DW_OP_deref; DW_OP_constu: 0; DW_OP_ne)
  <1><138>: Abbrev Number: 12 (DW_TAG_subroutine_type)
     <139>   DW_AT_decl_line   : 8
     <13a>   DW_AT_decl_file   : 1
     <13b>   DW_AT_name        : (indirect string, offset: 0x114): AREA
     <13f>   DW_AT_type        : <0x126>
  <1><143>: Abbrev Number: 13 (DW_TAG_subroutine_type)
     <144>   DW_AT_decl_line   : 9
     <145>   DW_AT_decl_file   : 1
     <146>   DW_AT_name        : (indirect string, offset: 0x10e): 
PRINT_AREA
  <1><14a>: Abbrev Number: 11 (DW_TAG_pointer_type)
     <14b>   DW_AT_type        : <0xe2>
     <14f>   DW_AT_associated  : 5 byte block: 97 6 10 0 2e 
(DW_OP_push_object_address; DW_OP_deref; DW_OP_constu: 0; DW_OP_ne)
  <1><155>: Abbrev Number: 12 (DW_TAG_subroutine_type)
     <156>   DW_AT_decl_line   : 8
     <157>   DW_AT_decl_file   : 1
     <158>   DW_AT_name        : (indirect string, offset: 0x114): AREA
     <15c>   DW_AT_type        : <0x126>
  <1><160>: Abbrev Number: 13 (DW_TAG_subroutine_type)
     <161>   DW_AT_decl_line   : 9
     <162>   DW_AT_decl_file   : 1
     <163>   DW_AT_name        : (indirect string, offset: 0x10e): 
PRINT_AREA
  <1><167>: Abbrev Number: 14 (DW_TAG_subprogram)
     <168>   DW_AT_decl_line   : 27
     <169>   DW_AT_decl_file   : 1
     <16a>   DW_AT_name        : (indirect string, offset: 0x129): 
square_test
     <16e>   DW_AT_calling_convention: 2	(program)
     <16f>   DW_AT_low_pc      : 0x40274a
     <177>   DW_AT_high_pc     : 0x402842
     <17f>   DW_AT_external    : 1
  <2><180>: Abbrev Number: 8 (DW_TAG_variable)
     <181>   DW_AT_decl_line   : 31
     <182>   DW_AT_decl_file   : 1
     <183>   DW_AT_name        : (indirect string, offset: 0x135): asquare
     <187>   DW_AT_type        : <0x195>
     <18b>   DW_AT_location    : 9 byte block: 3 b0 33 6b 0 0 0 0 0 
(DW_OP_addr: 6b33b0)
  <2><195>: Abbrev Number: 6 (DW_TAG_structure_type)
     <196>   DW_AT_decl_line   : 0
     <197>   DW_AT_decl_file   : 1
     <198>   DW_AT_byte_size   : 4
     <199>   DW_AT_name        : (indirect string, offset: 0xdf): square
  <3><19d>: Abbrev Number: 7 (DW_TAG_member)
     <19e>   DW_AT_decl_line   : 0
     <19f>   DW_AT_decl_file   : 1
     <1a0>   DW_AT_data_member_location: 2 byte block: 23 0 
(DW_OP_plus_uconst: 0)
     <1a3>   DW_AT_name        : (indirect string, offset: 0x107): height
     <1a7>   DW_AT_type        : <0x126>
  <3><1ab>: Abbrev Number: 7 (DW_TAG_member)
     <1ac>   DW_AT_decl_line   : 0
     <1ad>   DW_AT_decl_file   : 1
     <1ae>   DW_AT_data_member_location: 2 byte block: 23 0 
(DW_OP_plus_uconst: 0)
     <1b1>   DW_AT_name        : (indirect string, offset: 0x102): area
     <1b5>   DW_AT_type        : <0x1c9>
  <3><1b9>: Abbrev Number: 7 (DW_TAG_member)
     <1ba>   DW_AT_decl_line   : 0
     <1bb>   DW_AT_decl_file   : 1
     <1bc>   DW_AT_data_member_location: 2 byte block: 23 0 
(DW_OP_plus_uconst: 0)
     <1bf>   DW_AT_name        : (indirect string, offset: 0x119): 
print_area
     <1c3>   DW_AT_type        : <0x1d4>
  <3><1c7>: Abbrev Number: 0
  <2><1c8>: Abbrev Number: 0
  <1><1c9>: Abbrev Number: 12 (DW_TAG_subroutine_type)
     <1ca>   DW_AT_decl_line   : 27
     <1cb>   DW_AT_decl_file   : 1
     <1cc>   DW_AT_name        : (indirect string, offset: 0x114): AREA
     <1d0>   DW_AT_type        : <0x126>
  <1><1d4>: Abbrev Number: 13 (DW_TAG_subroutine_type)
     <1d5>   DW_AT_decl_line   : 27
     <1d6>   DW_AT_decl_file   : 1
     <1d7>   DW_AT_name        : (indirect string, offset: 0x10e): 
PRINT_AREA
  <1><1db>: Abbrev Number: 0



You can see that in the declaration in the module and in the declaration 
in the program itself there is also the functions as members.

Thus the result of the print of asquare is today:

(gdb) print asquare
$1 = ( 0, {REAL(4) ()} 0x6716253 <square_test_$ASQUARE>, {void ()} 
0x6716253 <square_test_$ASQUARE> )

In this sense I suppose you would like to see that as a test added to 
the fortran testsuite, right?

With that would it be ok to commit, of course after review of the test? :)


Thanks and regards,
-Fred



Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

  parent reply	other threads:[~2016-05-02 12:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-18 10:26 Walfred Tedeschi
2016-04-05 11:47 ` Yao Qi
2016-04-05 12:17   ` Walfred Tedeschi
     [not found]     ` <8660vwnsb3.fsf@gmail.com>
2016-05-02 12:35       ` Walfred Tedeschi [this message]
2016-05-03 16:14         ` 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=57274976.3000903@intel.com \
    --to=walfred.tedeschi@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --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