public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/29842] New: Debugging variables with ALLOCATABLE attribute fails to read variable properties correctly
@ 2022-12-02 18:45 emr-gnu at hev dot psu.edu
  2022-12-05 19:01 ` [Bug fortran/29842] " emr-gnu at hev dot psu.edu
  0 siblings, 1 reply; 2+ messages in thread
From: emr-gnu at hev dot psu.edu @ 2022-12-02 18:45 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29842

            Bug ID: 29842
           Summary: Debugging variables with ALLOCATABLE attribute fails
                    to read variable properties correctly
           Product: gdb
           Version: HEAD
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
          Assignee: unassigned at sourceware dot org
          Reporter: emr-gnu at hev dot psu.edu
  Target Milestone: ---

Created attachment 14476
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14476&action=edit
Reproducer

In the attached program, gdb version ac57bf55 (current HEAD as of this
writing), GDB fails to debug the contents (or even the size/address) of Fortran
variables marked with the ALLOCATABLE attribute when built with the Intel ifort
compiler.  I have not checked LLVM (gfortran-12.1 works fine).

----------------

gfortran-12.1 -ffixed-line-length-none -g -O0 -o main main.for
ifort -g -O0 -o main main.for

Expected behavior (correct with gfortran):

(gdb) b 29
(gdb) r
(gdb) whatis string1
type = PTR TO -> ( character*(*) )
(gdb) p string1
$1 = (PTR TO -> ( character*(*) )) 0x0
(gdb) n
(gdb) p string1
$2 = (PTR TO -> ( character*(*) )) 0x55555555c680
(gdb) p *string1
$3 = '\000' <repeats 41 times>

----------------
Incorrect behavior (as experienced with ifort-generated executable):

(gdb) b 29
(gdb) r
(gdb) whatis string1
type = character*(*)
(gdb) p string1
Location address is not set.
(gdb) n
(gdb) whatis string1
type = character (0)
(gdb) p string1
$1 = ''
(gdb) n
(gdb) whatis string1
type = character (5053124857890819657)
(gdb) p string1
value requires 5053124857890819657 bytes, which is more than max-value-size

----------------

Based on the above, it looks like gdb is possibly not interpreting variables
with the ALLOCATABLE attribute as being a pointer, so any gdb operations on
that variable are going to be incorrect.  And this seems to be limited to only
code generated with ifort; code generated with IFX and gfortran is correctly
interpreted.  I am unable to test LLVM at this time.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-12-05 19:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-02 18:45 [Bug fortran/29842] New: Debugging variables with ALLOCATABLE attribute fails to read variable properties correctly emr-gnu at hev dot psu.edu
2022-12-05 19:01 ` [Bug fortran/29842] " emr-gnu at hev dot psu.edu

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).