public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "nils-christian.kempke at intel dot com" <sourceware-bugzilla@sourceware.org>
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 [thread overview]
Message-ID: <bug-29139-4717@http.sourceware.org/bugzilla/> (raw)
https://sourceware.org/bugzilla/show_bug.cgi?id=29139
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 without
the pointer attribute does not show any difference within GDB.
Consider the Fortran program
==============================================
program MAIN
Integer, target :: var
Integer, pointer :: pvar
pvar => var
var = 1
print *, var, pvar
end program
==============================================
compiled with
==============================================
>> gfortran --version
GNU Fortran (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
==============================================
Running a GDB session and breaking at line 7 (the print statement) we get
==============================================
7 print *, var, pvar
(gdb) p pvar
$1 = (1, 1, 1)
(gdb) ptype pvar
type = integer(kind=4) (3)
(gdb) p var
$2 = (1, 1, 1)
(gdb) ptype var
type = integer(kind=4) (3)
(gdb) p associated(var)
ASSOCIATED can only be applied to pointers
(gdb) p associated(pvar)
$3 = .TRUE.
==============================================
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 derived
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:
==============================================
...
<2><ab>: Abbrev Number: 8 (DW_TAG_variable)
<ac> DW_AT_name : (indirect string, offset: 0x56): pvar
<b0> DW_AT_decl_file : 1
<b1> DW_AT_decl_line : 3
<b2> DW_AT_type : <0xca>
<b6> DW_AT_location : 3 byte block: 91 80 7f (DW_OP_fbreg: -128)
...
<1><ca>: Abbrev Number: 10 (DW_TAG_array_type)
<cb> DW_AT_data_location: 2 byte block: 97 6
(DW_OP_push_object_address; DW_OP_deref)
<ce> DW_AT_associated : 4 byte block: 97 6 30 2e
(DW_OP_push_object_address; DW_OP_deref; DW_OP_lit0; DW_OP_ne)
<d3> DW_AT_type : <0x74>
<d7> DW_AT_sibling : <0xf1>
...
==============================================
with the additional DW_AT_associated attribute.
Something like
==============================================
(gdb) p pvar
type = interger(kind=4) (3) pointer
==============================================
would give more insight here.
--
You are receiving this mail because:
You are on the CC list for the bug.
next reply other threads:[~2022-05-11 8:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-11 8:07 nils-christian.kempke at intel dot com [this message]
2022-05-11 8:07 ` [Bug fortran/29139] " nils-christian.kempke at intel dot com
2022-05-11 8:11 ` nils-christian.kempke at intel dot com
2023-10-18 18:46 ` levraiphilippeblain at gmail 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-29139-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: 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).