public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/101826] New: GFORTRAN: Debug info missing DW_TAG_string_type for array of variable length string
@ 2021-08-09  9:27 abdul.b.ijaz at intel dot com
  2021-08-09 13:00 ` [Bug fortran/101826] " rguenth at gcc dot gnu.org
  2021-08-09 13:20 ` abdul.b.ijaz at intel dot com
  0 siblings, 2 replies; 3+ messages in thread
From: abdul.b.ijaz at intel dot com @ 2021-08-09  9:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101826

            Bug ID: 101826
           Summary: GFORTRAN: Debug info missing DW_TAG_string_type for
                    array of variable length string
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: abdul.b.ijaz at intel dot com
  Target Milestone: ---

Using GFortran 11.1.0 or older versions it is seen that dwarf debug info does
not contain DW_TAG_string_type for array of variable length strings like shown
in reproducer below and instead it contains DW_TAG_structure_type. As per dwarf
spec there should have been DW_TAG_string_type for string type object.

Reproducer program:

subroutine str_arr (arr1)
  character (len=*):: arr1(:)

  print *, arr1
end subroutine str_arr

program main
interface
  subroutine str_arr (arr1)
    character (len=*):: arr1 (:)
  end subroutine str_arr
end interface
  character (len=10) :: arr (5)

  arr = 'fortranarr'

  call str_arr (arr)

end program main


Dwarf info:

 <1><de>: Abbrev Number: 14 (DW_TAG_subprogram)
    <df>   DW_AT_external    : 1
    <df>   DW_AT_name        : (indirect string, offset: 0x12): str_arr
    <e3>   DW_AT_decl_file   : 1
    <e4>   DW_AT_decl_line   : 1
    <e5>   DW_AT_decl_column : 18
    <e6>   DW_AT_linkage_name: (indirect string, offset: 0x4b): str_arr_
    <ea>   DW_AT_low_pc      : 0x7d5
    <f2>   DW_AT_high_pc     : 0x19f
    <fa>   DW_AT_frame_base  : 1 byte block: 9c         (DW_OP_call_frame_cfa)
    <fc>   DW_AT_GNU_all_tail_call_sites: 1
    <fc>   DW_AT_sibling     : <0x12c>
 <2><100>: Abbrev Number: 15 (DW_TAG_formal_parameter)
    <101>   DW_AT_name        : (indirect string, offset: 0x1): arr1
    <105>   DW_AT_type        : <0x12c>
    <109>   DW_AT_artificial  : 1
    <109>   DW_AT_location    : 4 byte block: 91 f8 7a 6        (DW_OP_fbreg:
-648; DW_OP_deref)
 <2><10e>: Abbrev Number: 15 (DW_TAG_formal_parameter)
    <10f>   DW_AT_name        : (indirect string, offset: 0x0): _arr1
    <113>   DW_AT_type        : <0x35>
    <117>   DW_AT_artificial  : 1
    <117>   DW_AT_location    : 3 byte block: 91 f0 7a  (DW_OP_fbreg: -656)
 <2><11b>: Abbrev Number: 16 (DW_TAG_variable)
    <11c>   DW_AT_type        : <0x2e>
    <120>   DW_AT_artificial  : 1
    <120>   DW_AT_location    : 2 byte block: 91 50     (DW_OP_fbreg: -48)
 <2><123>: Abbrev Number: 16 (DW_TAG_variable)
    <124>   DW_AT_type        : <0x14d>
    <128>   DW_AT_artificial  : 1
    <128>   DW_AT_location    : 2 byte block: 91 58     (DW_OP_fbreg: -40)
 <2><12b>: Abbrev Number: 0
 <1><12c>: Abbrev Number: 17 (DW_TAG_structure_type)
    <12d>   DW_AT_declaration : 1

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

* [Bug fortran/101826] GFORTRAN: Debug info missing DW_TAG_string_type for array of variable length string
  2021-08-09  9:27 [Bug fortran/101826] New: GFORTRAN: Debug info missing DW_TAG_string_type for array of variable length string abdul.b.ijaz at intel dot com
@ 2021-08-09 13:00 ` rguenth at gcc dot gnu.org
  2021-08-09 13:20 ` abdul.b.ijaz at intel dot com
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-08-09 13:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101826

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-08-09
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed on trunk.  The DW_TAG_structure_type contains the DW_AT_string_type:

 <1><126>: Abbrev Number: 17 (DW_TAG_structure_type)
    <127>   DW_AT_declaration : 1
 <1><127>: Abbrev Number: 6 (DW_TAG_array_type)
    <128>   DW_AT_type        : <0x13a>
    <12c>   DW_AT_sibling     : <0x13a>
 <2><130>: Abbrev Number: 18 (DW_TAG_subrange_type)
    <131>   DW_AT_type        : <0x2f>
    <135>   DW_AT_upper_bound : <0x115>
 <2><139>: Abbrev Number: 0
 <1><13a>: Abbrev Number: 19 (DW_TAG_string_type)
    <13b>   DW_AT_string_length: <0x108>

so appearantly we leak some implementation detail into the DWARF?

When debugging with gdb I see

(gdb) s
str_arr (arr1=<incomplete type>, _arr1=10) at t.f90:1
1       subroutine str_arr (arr1)
(gdb) ptype arr1
type = Type 
End Type 

and the function looks like

void str_arr (struct array01_character(kind=1) & restrict arr1, integer(kind=8)
_arr1)

thus the parametrized string is passed as a reference to a structure plus
a separate length argument.

  character(kind=1)[0:D.3976][1:_arr1] * restrict arr1.0;
...
  arr1.0_23 = arr1_18(D)->data;

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

* [Bug fortran/101826] GFORTRAN: Debug info missing DW_TAG_string_type for array of variable length string
  2021-08-09  9:27 [Bug fortran/101826] New: GFORTRAN: Debug info missing DW_TAG_string_type for array of variable length string abdul.b.ijaz at intel dot com
  2021-08-09 13:00 ` [Bug fortran/101826] " rguenth at gcc dot gnu.org
@ 2021-08-09 13:20 ` abdul.b.ijaz at intel dot com
  1 sibling, 0 replies; 3+ messages in thread
From: abdul.b.ijaz at intel dot com @ 2021-08-09 13:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101826

--- Comment #2 from Abdul Basit Ijaz <abdul.b.ijaz at intel dot com> ---
I tried with GFortran 11.1.0 version so if you already see DW_TAG_string_type
in trunk then it means it was already fixed. Do you happen to know any issue
related to it then this issue can be duplicated to know which release will have
the fix.

Regarding GDB it also has a issue for such case and it also need a fix for such
cases to handle DW_TAG_string_type for array type appropriately.

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

end of thread, other threads:[~2021-08-09 13:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-09  9:27 [Bug fortran/101826] New: GFORTRAN: Debug info missing DW_TAG_string_type for array of variable length string abdul.b.ijaz at intel dot com
2021-08-09 13:00 ` [Bug fortran/101826] " rguenth at gcc dot gnu.org
2021-08-09 13:20 ` abdul.b.ijaz at intel dot com

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