From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8707C383E822; Wed, 11 May 2022 08:07:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8707C383E822 From: "nils-christian.kempke at intel dot com" To: gdb-prs@sourceware.org Subject: [Bug fortran/29139] New: Emit pointer attribute when printing type of Fortran pointers Date: Wed, 11 May 2022 08:07:18 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: fortran X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: nils-christian.kempke at intel dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 May 2022 08:07:18 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D29139 Bug ID: 29139 Summary: Emit pointer attribute when printing type of Fortran pointers Product: gdb Version: HEAD Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: fortran Assignee: unassigned at sourceware dot org Reporter: nils-christian.kempke at intel dot com Target Milestone: --- Currently, printing the type of a Fortran pointer (so an object with the pointer attribute) and printing the type of an object of the same type with= out the pointer attribute does not show any difference within GDB. Consider the Fortran program =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D program MAIN Integer, target :: var Integer, pointer :: pvar pvar =3D> var var =3D 1 print *, var, pvar end program =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D compiled with =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> gfortran --version GNU Fortran (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 Copyright (C) 2019 Free Software Foundation, Inc. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Running a GDB session and breaking at line 7 (the print statement) we get =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 7 print *, var, pvar (gdb) p pvar $1 =3D (1, 1, 1) (gdb) ptype pvar type =3D integer(kind=3D4) (3) (gdb) p var $2 =3D (1, 1, 1) (gdb) ptype var type =3D integer(kind=3D4) (3) (gdb) p associated(var) ASSOCIATED can only be applied to pointers (gdb) p associated(pvar) $3 =3D .TRUE. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D The only way to find out if something is a pointer or not is via the Fortran intrinsics. I think this could be improved and one could add the 'pointer' attribute also to the type-print of pvar. The pointer attributed can be der= ived from the emitted DWARF and the DW_AT_associated for the respective DIEs (as= is already done for the ASSOCIATED intrinsic) In this case gfortran generates DWARF like: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ... <2>: Abbrev Number: 8 (DW_TAG_variable) DW_AT_name : (indirect string, offset: 0x56): pvar DW_AT_decl_file : 1 DW_AT_decl_line : 3 DW_AT_type : <0xca> DW_AT_location : 3 byte block: 91 80 7f (DW_OP_fbreg: -128) ... <1>: Abbrev Number: 10 (DW_TAG_array_type) DW_AT_data_location: 2 byte block: 97 6=20=20=20=20=20 (DW_OP_push_object_address; DW_OP_deref) DW_AT_associated : 4 byte block: 97 6 30 2e=20=20=20=20=20=20= =20=20 (DW_OP_push_object_address; DW_OP_deref; DW_OP_lit0; DW_OP_ne) DW_AT_type : <0x74> DW_AT_sibling : <0xf1> ... =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D with the additional DW_AT_associated attribute. Something like =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (gdb) p pvar type =3D interger(kind=3D4) (3) pointer =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D would give more insight here. --=20 You are receiving this mail because: You are on the CC list for the bug.=