public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/114186] New: Incorrect CTF generated for multidimensional array
@ 2024-03-01  6:34 ibhagat at gcc dot gnu.org
  2024-03-01 18:29 ` [Bug debug/114186] " ibhagat at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ibhagat at gcc dot gnu.org @ 2024-03-01  6:34 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114186
           Summary: Incorrect CTF generated for multidimensional array
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ibhagat at gcc dot gnu.org
  Target Milestone: ---

$ cat array.c 
int a[5][9][3];
$ gcc -O0 -gctf -dA -S array.c

Excerpt from array.s:

...        
        .long   0x17    # ctv_name
        .long   0x5     # ctv_typeidx

=> a variable of type id = 5

        .long   0x1     # ctt_name
        .long   0x6000000       # ctt_info
        .long   0x4     # ctt_size or ctt_type
        .long   0x1000020       # ctf_encoding_data

=> type id = 1, type = int

        .long   0x5     # ctt_name
        .long   0x6000000       # ctt_info
        .long   0x8     # ctt_size or ctt_type
        .long   0x40    # ctf_encoding_data

=> type id = 2, type = long unsigned int

        .long   0       # ctt_name
        .long   0x12000000      # ctt_info
        .long   0       # ctt_size or ctt_type
        .long   0x1     # cta_contents
        .long   0x2     # cta_index
        .long   0x5     # cta_nelems

=> type id = 3, nelems = 5, array contents (cta_contents) of type with type id
= 1

        .long   0       # ctt_name
        .long   0x12000000      # ctt_info
        .long   0       # ctt_size or ctt_type
        .long   0x3     # cta_contents
        .long   0x2     # cta_index
        .long   0x9     # cta_nelems

=> type id = 4, nelems = 9, array contents (cta_contents) of type with type id
= 3 

        .long   0       # ctt_name
        .long   0x12000000      # ctt_info
        .long   0       # ctt_size or ctt_type
        .long   0x4     # cta_contents
        .long   0x2     # cta_index
        .long   0x3     # cta_nelems

=> type id = 5, nelems = 3, array contents (cta_contents) of type with type id
= 4

In other words, the data type of the variable is being emitted as if it were
int a[3][9][5]

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

* [Bug debug/114186] Incorrect CTF generated for multidimensional array
  2024-03-01  6:34 [Bug debug/114186] New: Incorrect CTF generated for multidimensional array ibhagat at gcc dot gnu.org
@ 2024-03-01 18:29 ` ibhagat at gcc dot gnu.org
  2024-03-02  0:26 ` ibhagat at gcc dot gnu.org
  2024-03-05 23:40 ` cvs-commit at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: ibhagat at gcc dot gnu.org @ 2024-03-01 18:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Indu Bhagat <ibhagat at gcc dot gnu.org> ---
This in turn affects BTF generation too, because GCC internally uses the CTFC
(CTF container) to create BTF info.

 $ bpftool btf dump file array.o 
[1] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED
[2] INT 'long unsigned int' size=8 bits_offset=0 nr_bits=64 encoding=(none)
[3] ARRAY '(anon)' type_id=1 index_type_id=2 nr_elems=5
[4] ARRAY '(anon)' type_id=3 index_type_id=2 nr_elems=9
[5] ARRAY '(anon)' type_id=4 index_type_id=2 nr_elems=3
[6] VAR 'a' type_id=5, linkage=global
[7] DATASEC '.bss' size=0 vlen=1
        type_id=6 offset=0 size=540 (VAR 'a')

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

* [Bug debug/114186] Incorrect CTF generated for multidimensional array
  2024-03-01  6:34 [Bug debug/114186] New: Incorrect CTF generated for multidimensional array ibhagat at gcc dot gnu.org
  2024-03-01 18:29 ` [Bug debug/114186] " ibhagat at gcc dot gnu.org
@ 2024-03-02  0:26 ` ibhagat at gcc dot gnu.org
  2024-03-05 23:40 ` cvs-commit at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: ibhagat at gcc dot gnu.org @ 2024-03-02  0:26 UTC (permalink / raw)
  To: gcc-bugs

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

Indu Bhagat <ibhagat at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2024-03-02
     Ever confirmed|0                           |1

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

* [Bug debug/114186] Incorrect CTF generated for multidimensional array
  2024-03-01  6:34 [Bug debug/114186] New: Incorrect CTF generated for multidimensional array ibhagat at gcc dot gnu.org
  2024-03-01 18:29 ` [Bug debug/114186] " ibhagat at gcc dot gnu.org
  2024-03-02  0:26 ` ibhagat at gcc dot gnu.org
@ 2024-03-05 23:40 ` cvs-commit at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-03-05 23:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Indu Bhagat <ibhagat@gcc.gnu.org>:

https://gcc.gnu.org/g:5d24bf3afd1bea3e51b87fb7ff24c21e29913999

commit r14-9325-g5d24bf3afd1bea3e51b87fb7ff24c21e29913999
Author: Cupertino Miranda <cupertino.miranda@oracle.com>
Date:   Thu Feb 29 10:56:13 2024 -0800

    ctf: fix incorrect CTF for multi-dimensional array types

    PR debug/114186

    DWARF DIEs of type DW_TAG_subrange_type are linked together to represent
    the information about the subsequent dimensions.  The CTF processing was
    so far working through them in the opposite (incorrect) order.

    While fixing the issue, refactor the code a bit for readability.

    co-authored-By: Indu Bhagat <indu.bhagat@oracle.com>

    gcc/
            PR debug/114186
            * dwarf2ctf.cc (gen_ctf_array_type): Invoke the ctf_add_array ()
            in the correct order of the dimensions.
            (gen_ctf_subrange_type): Refactor out handling of
            DW_TAG_subrange_type DIE to here.

    gcc/testsuite/
            PR debug/114186
            * gcc.dg/debug/ctf/ctf-array-6.c: Add test.

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

end of thread, other threads:[~2024-03-05 23:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-01  6:34 [Bug debug/114186] New: Incorrect CTF generated for multidimensional array ibhagat at gcc dot gnu.org
2024-03-01 18:29 ` [Bug debug/114186] " ibhagat at gcc dot gnu.org
2024-03-02  0:26 ` ibhagat at gcc dot gnu.org
2024-03-05 23:40 ` cvs-commit 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).