public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/103315] New: Gfortran DW_AT_Rank expression not emitting correct rank value.
@ 2021-11-18 13:53 rupesh.potharla at amd dot com
  2021-11-18 14:26 ` [Bug debug/103315] " jakub at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: rupesh.potharla at amd dot com @ 2021-11-18 13:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103315
           Summary: Gfortran DW_AT_Rank expression not emitting correct
                    rank value.
           Product: gcc
           Version: og10 (devel/omp/gcc-10)
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rupesh.potharla at amd dot com
  Target Milestone: ---

I am working on to implement Assumed rank in gdb. Evaluating DW_AT_RANK
attribute expression provided by gcc is not emitting the correct rank value. Do
we have to manipulate the value returned by the expression in any way to get
the exact rank value? 

----------------------------------------------------------------------------
PROGRAM  arank

REAL :: a1(10)

call test_rank(a1)

CONTAINS
  SUBROUTINE test_rank(a)
    REAL :: a(..)
    PRINT *, RANK(a)
  END

END PROGRAM arank

------------------------------------------------------------------------------
gfortran -gdwarf-5 arank.f90 -o arank
------------------------------------------------------------------------------

DW_AT_rank      (DW_OP_push_object_address, DW_OP_plus_uconst 0x1c,
DW_OP_deref)

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

* [Bug debug/103315] Gfortran DW_AT_Rank expression not emitting correct rank value.
  2021-11-18 13:53 [Bug debug/103315] New: Gfortran DW_AT_Rank expression not emitting correct rank value rupesh.potharla at amd dot com
@ 2021-11-18 14:26 ` jakub at gcc dot gnu.org
  2021-11-21 20:08 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-11-18 14:26 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Would DW_OP_deref_size 1 instead of DW_OP_deref fix this?  dtype.rank field is
I think unsigned char.

I.e.:
2021-11-18  Jakub Jelinek  <jakub@redhat.com>

        PR debug/103315
        * trans-types.c (gfc_get_array_descr_info): Use DW_OP_deref_size 1
        instead of DW_OP_deref for DW_AT_rank.

--- gcc/fortran/trans-types.c.jj        2021-11-12 15:54:21.000000000 +0100
+++ gcc/fortran/trans-types.c   2021-11-18 15:13:45.131281198 +0100
@@ -3459,8 +3459,8 @@ gfc_get_array_descr_info (const_tree typ
       if (!integer_zerop (dtype_off))
        t = fold_build_pointer_plus (t, rank_off);

-      t = build1 (NOP_EXPR, build_pointer_type (gfc_array_index_type), t);
-      t = build1 (INDIRECT_REF, gfc_array_index_type, t);
+      t = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (field)), t);
+      t = build1 (INDIRECT_REF, TREE_TYPE (field), t);
       info->rank = t;
       t = build0 (PLACEHOLDER_EXPR, TREE_TYPE (dim_off));
       t = size_binop (MULT_EXPR, t, dim_size);

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

* [Bug debug/103315] Gfortran DW_AT_Rank expression not emitting correct rank value.
  2021-11-18 13:53 [Bug debug/103315] New: Gfortran DW_AT_Rank expression not emitting correct rank value rupesh.potharla at amd dot com
  2021-11-18 14:26 ` [Bug debug/103315] " jakub at gcc dot gnu.org
@ 2021-11-21 20:08 ` cvs-commit at gcc dot gnu.org
  2021-11-29  8:50 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-11-21 20:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:da17c304e22ba256eba0b03710aa329115163b08

commit r12-5442-gda17c304e22ba256eba0b03710aa329115163b08
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sun Nov 21 21:08:04 2021 +0100

    fortran, debug: Fix up DW_AT_rank [PR103315]

    For DW_AT_rank we were emitting
            .uleb128 0x4    # DW_AT_rank
            .byte   0x97    # DW_OP_push_object_address
            .byte   0x23    # DW_OP_plus_uconst
            .uleb128 0x1c
            .byte   0x6     # DW_OP_deref
    on 64-bit and
            .uleb128 0x4    # DW_AT_rank
            .byte   0x97    # DW_OP_push_object_address
            .byte   0x23    # DW_OP_plus_uconst
            .uleb128 0x10
            .byte   0x6     # DW_OP_deref
    on 32-bit.  I think this is wrong, as dtype.rank field in the descriptor
    has unsigned char type, not pointer type nor pointer sized integral.
    E.g. if we have a
        REAL :: a(..)
    dummy argument, which is passed as a reference to the function descriptor,
    we want to evaluate a->dtype.rank.  The above DWARF expressions perform
    *(uintptr_t *)(a + 0x1c)
    and
    *(uintptr_t *)(a + 0x10)
    respectively.  The following patch changes those to:
            .uleb128 0x5    # DW_AT_rank
            .byte   0x97    # DW_OP_push_object_address
            .byte   0x23    # DW_OP_plus_uconst
            .uleb128 0x1c
            .byte   0x94    # DW_OP_deref_size
            .byte   0x1
    and
            .uleb128 0x5    # DW_AT_rank
            .byte   0x97    # DW_OP_push_object_address
            .byte   0x23    # DW_OP_plus_uconst
            .uleb128 0x10
            .byte   0x94    # DW_OP_deref_size
            .byte   0x1
    which perform
    *(unsigned char *)(a + 0x1c)
    and
    *(unsigned char *)(a + 0x10)
    respectively.

    2021-11-21  Jakub Jelinek  <jakub@redhat.com>

            PR debug/103315
            * trans-types.c (gfc_get_array_descr_info): Use DW_OP_deref_size 1
            instead of DW_OP_deref for DW_AT_rank.

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

* [Bug debug/103315] Gfortran DW_AT_Rank expression not emitting correct rank value.
  2021-11-18 13:53 [Bug debug/103315] New: Gfortran DW_AT_Rank expression not emitting correct rank value rupesh.potharla at amd dot com
  2021-11-18 14:26 ` [Bug debug/103315] " jakub at gcc dot gnu.org
  2021-11-21 20:08 ` cvs-commit at gcc dot gnu.org
@ 2021-11-29  8:50 ` cvs-commit at gcc dot gnu.org
  2022-05-10  8:21 ` [Bug fortran/103315] " cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-11-29  8:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:7230ae73c96dc7d19f072627e1f9c48e008e03b8

commit r11-9336-g7230ae73c96dc7d19f072627e1f9c48e008e03b8
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sun Nov 21 21:08:04 2021 +0100

    fortran, debug: Fix up DW_AT_rank [PR103315]

    For DW_AT_rank we were emitting
            .uleb128 0x4    # DW_AT_rank
            .byte   0x97    # DW_OP_push_object_address
            .byte   0x23    # DW_OP_plus_uconst
            .uleb128 0x1c
            .byte   0x6     # DW_OP_deref
    on 64-bit and
            .uleb128 0x4    # DW_AT_rank
            .byte   0x97    # DW_OP_push_object_address
            .byte   0x23    # DW_OP_plus_uconst
            .uleb128 0x10
            .byte   0x6     # DW_OP_deref
    on 32-bit.  I think this is wrong, as dtype.rank field in the descriptor
    has unsigned char type, not pointer type nor pointer sized integral.
    E.g. if we have a
        REAL :: a(..)
    dummy argument, which is passed as a reference to the function descriptor,
    we want to evaluate a->dtype.rank.  The above DWARF expressions perform
    *(uintptr_t *)(a + 0x1c)
    and
    *(uintptr_t *)(a + 0x10)
    respectively.  The following patch changes those to:
            .uleb128 0x5    # DW_AT_rank
            .byte   0x97    # DW_OP_push_object_address
            .byte   0x23    # DW_OP_plus_uconst
            .uleb128 0x1c
            .byte   0x94    # DW_OP_deref_size
            .byte   0x1
    and
            .uleb128 0x5    # DW_AT_rank
            .byte   0x97    # DW_OP_push_object_address
            .byte   0x23    # DW_OP_plus_uconst
            .uleb128 0x10
            .byte   0x94    # DW_OP_deref_size
            .byte   0x1
    which perform
    *(unsigned char *)(a + 0x1c)
    and
    *(unsigned char *)(a + 0x10)
    respectively.

    2021-11-21  Jakub Jelinek  <jakub@redhat.com>

            PR debug/103315
            * trans-types.c (gfc_get_array_descr_info): Use DW_OP_deref_size 1
            instead of DW_OP_deref for DW_AT_rank.

    (cherry picked from commit da17c304e22ba256eba0b03710aa329115163b08)

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

* [Bug fortran/103315] Gfortran DW_AT_Rank expression not emitting correct rank value.
  2021-11-18 13:53 [Bug debug/103315] New: Gfortran DW_AT_Rank expression not emitting correct rank value rupesh.potharla at amd dot com
                   ` (2 preceding siblings ...)
  2021-11-29  8:50 ` cvs-commit at gcc dot gnu.org
@ 2022-05-10  8:21 ` cvs-commit at gcc dot gnu.org
  2022-05-11  6:23 ` cvs-commit at gcc dot gnu.org
  2022-05-11  6:36 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-10  8:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:d91c501fd705de0d4ca4b89021878d0133258fd4

commit r10-10656-gd91c501fd705de0d4ca4b89021878d0133258fd4
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sun Nov 21 21:08:04 2021 +0100

    fortran, debug: Fix up DW_AT_rank [PR103315]

    For DW_AT_rank we were emitting
            .uleb128 0x4    # DW_AT_rank
            .byte   0x97    # DW_OP_push_object_address
            .byte   0x23    # DW_OP_plus_uconst
            .uleb128 0x1c
            .byte   0x6     # DW_OP_deref
    on 64-bit and
            .uleb128 0x4    # DW_AT_rank
            .byte   0x97    # DW_OP_push_object_address
            .byte   0x23    # DW_OP_plus_uconst
            .uleb128 0x10
            .byte   0x6     # DW_OP_deref
    on 32-bit.  I think this is wrong, as dtype.rank field in the descriptor
    has unsigned char type, not pointer type nor pointer sized integral.
    E.g. if we have a
        REAL :: a(..)
    dummy argument, which is passed as a reference to the function descriptor,
    we want to evaluate a->dtype.rank.  The above DWARF expressions perform
    *(uintptr_t *)(a + 0x1c)
    and
    *(uintptr_t *)(a + 0x10)
    respectively.  The following patch changes those to:
            .uleb128 0x5    # DW_AT_rank
            .byte   0x97    # DW_OP_push_object_address
            .byte   0x23    # DW_OP_plus_uconst
            .uleb128 0x1c
            .byte   0x94    # DW_OP_deref_size
            .byte   0x1
    and
            .uleb128 0x5    # DW_AT_rank
            .byte   0x97    # DW_OP_push_object_address
            .byte   0x23    # DW_OP_plus_uconst
            .uleb128 0x10
            .byte   0x94    # DW_OP_deref_size
            .byte   0x1
    which perform
    *(unsigned char *)(a + 0x1c)
    and
    *(unsigned char *)(a + 0x10)
    respectively.

    2021-11-21  Jakub Jelinek  <jakub@redhat.com>

            PR debug/103315
            * trans-types.c (gfc_get_array_descr_info): Use DW_OP_deref_size 1
            instead of DW_OP_deref for DW_AT_rank.

    (cherry picked from commit da17c304e22ba256eba0b03710aa329115163b08)

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

* [Bug fortran/103315] Gfortran DW_AT_Rank expression not emitting correct rank value.
  2021-11-18 13:53 [Bug debug/103315] New: Gfortran DW_AT_Rank expression not emitting correct rank value rupesh.potharla at amd dot com
                   ` (3 preceding siblings ...)
  2022-05-10  8:21 ` [Bug fortran/103315] " cvs-commit at gcc dot gnu.org
@ 2022-05-11  6:23 ` cvs-commit at gcc dot gnu.org
  2022-05-11  6:36 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-11  6:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:4a3c9aabb05d823e5e459a8ccefc1b18c0817eec

commit r9-10112-g4a3c9aabb05d823e5e459a8ccefc1b18c0817eec
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sun Nov 21 21:08:04 2021 +0100

    fortran, debug: Fix up DW_AT_rank [PR103315]

    For DW_AT_rank we were emitting
            .uleb128 0x4    # DW_AT_rank
            .byte   0x97    # DW_OP_push_object_address
            .byte   0x23    # DW_OP_plus_uconst
            .uleb128 0x1c
            .byte   0x6     # DW_OP_deref
    on 64-bit and
            .uleb128 0x4    # DW_AT_rank
            .byte   0x97    # DW_OP_push_object_address
            .byte   0x23    # DW_OP_plus_uconst
            .uleb128 0x10
            .byte   0x6     # DW_OP_deref
    on 32-bit.  I think this is wrong, as dtype.rank field in the descriptor
    has unsigned char type, not pointer type nor pointer sized integral.
    E.g. if we have a
        REAL :: a(..)
    dummy argument, which is passed as a reference to the function descriptor,
    we want to evaluate a->dtype.rank.  The above DWARF expressions perform
    *(uintptr_t *)(a + 0x1c)
    and
    *(uintptr_t *)(a + 0x10)
    respectively.  The following patch changes those to:
            .uleb128 0x5    # DW_AT_rank
            .byte   0x97    # DW_OP_push_object_address
            .byte   0x23    # DW_OP_plus_uconst
            .uleb128 0x1c
            .byte   0x94    # DW_OP_deref_size
            .byte   0x1
    and
            .uleb128 0x5    # DW_AT_rank
            .byte   0x97    # DW_OP_push_object_address
            .byte   0x23    # DW_OP_plus_uconst
            .uleb128 0x10
            .byte   0x94    # DW_OP_deref_size
            .byte   0x1
    which perform
    *(unsigned char *)(a + 0x1c)
    and
    *(unsigned char *)(a + 0x10)
    respectively.

    2021-11-21  Jakub Jelinek  <jakub@redhat.com>

            PR debug/103315
            * trans-types.c (gfc_get_array_descr_info): Use DW_OP_deref_size 1
            instead of DW_OP_deref for DW_AT_rank.

    (cherry picked from commit da17c304e22ba256eba0b03710aa329115163b08)

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

* [Bug fortran/103315] Gfortran DW_AT_Rank expression not emitting correct rank value.
  2021-11-18 13:53 [Bug debug/103315] New: Gfortran DW_AT_Rank expression not emitting correct rank value rupesh.potharla at amd dot com
                   ` (4 preceding siblings ...)
  2022-05-11  6:23 ` cvs-commit at gcc dot gnu.org
@ 2022-05-11  6:36 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-05-11  6:36 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2022-05-11  6:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-18 13:53 [Bug debug/103315] New: Gfortran DW_AT_Rank expression not emitting correct rank value rupesh.potharla at amd dot com
2021-11-18 14:26 ` [Bug debug/103315] " jakub at gcc dot gnu.org
2021-11-21 20:08 ` cvs-commit at gcc dot gnu.org
2021-11-29  8:50 ` cvs-commit at gcc dot gnu.org
2022-05-10  8:21 ` [Bug fortran/103315] " cvs-commit at gcc dot gnu.org
2022-05-11  6:23 ` cvs-commit at gcc dot gnu.org
2022-05-11  6:36 ` jakub at gcc dot gnu.org

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