public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/116663] New: CTF array dimensions dumped backwards
@ 2024-09-10 16:33 bruce.mcculloch at oracle dot com
  2024-09-10 16:45 ` [Bug debug/116663] " sjames at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: bruce.mcculloch at oracle dot com @ 2024-09-10 16:33 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 116663
           Summary: CTF array dimensions dumped backwards
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bruce.mcculloch at oracle dot com
  Target Milestone: ---

Created attachment 59088
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59088&action=edit
Patch that fixes backwards multidimensional array dumping, plus tests

$ cat array.c
int a[1][2][3]
$ gcc -gctf -o array.o -c array.c
$ objdump --ctf array.o

array.o:     file format elf64-x86-64

Contents of CTF section .ctf:

  Header:
    Magic number: 0xdff2
    Version: 4 (CTF_VERSION_3)
    Flags: 0x2 (CTF_F_NEWFUNCINFO)
    Compilation unit name: //array.c
    Data object section:        0x0 -- 0x3 (0x4 bytes)
    Object index section:       0x4 -- 0x7 (0x4 bytes)
    Variable section:   0x8 -- 0xf (0x8 bytes)
    Type section:       0x10 -- 0x77 (0x68 bytes)
    String section:     0x78 -- 0x9b (0x24 bytes)

  Labels:

  Data objects:
    a -> 0x5: (kind 4) int [3][2][1] (size 0x18) (aligned at 0x4) -> 0x4: (kind
4) int [3][2] (size 0x18) (aligned at 0x4) -> 0x3: (kind 4) int [3] (size 0xc)
(aligned at 0x4) -> 0x1: (kind 1) int (format 0x1) (size 0x4) (aligned at 0x4)

  Function objects:

  Variables:
    a -> 0x5: (kind 4) int [3][2][1] (size 0x18) (aligned at 0x4) -> 0x4: (kind
4) int [3][2] (size 0x18) (aligned at 0x4) -> 0x3: (kind 4) int [3] (size 0xc)
(aligned at 0x4) -> 0x1: (kind 1) int (format 0x1) (size 0x4) (aligned at 0x4)

  Types:
    0x1: (kind 1) int (format 0x1) (size 0x4) (aligned at 0x4)
    0x2: (kind 1) long unsigned int (format 0x0) (size 0x8) (aligned at 0x8)
    0x3: (kind 4) int [3] (size 0xc) (aligned at 0x4) -> 0x1: (kind 1) int
(format 0x1) (size 0x4) (aligned at 0x4)
    0x4: (kind 4) int [3][2] (size 0x18) (aligned at 0x4) -> 0x3: (kind 4) int
[3] (size 0xc) (aligned at 0x4) -> 0x1: (kind 1) int (format 0x1) (size 0x4)
(aligned at 0x4)
    0x5: (kind 4) int [3][2][1] (size 0x18) (aligned at 0x4) -> 0x4: (kind 4)
int [3][2] (size 0x18) (aligned at 0x4) -> 0x3: (kind 4) int [3] (size 0xc)
(aligned at 0x4) -> 0x1: (kind 1) int (format 0x1) (size 0x4) (aligned at 0x4)

  Strings:
    0x0: 
    0x1: int
    0x5: long unsigned int
    0x17: a
    0x19: //array.c

This behavior occurs as a result of this patch, which was applied in gcc
14.2.0:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114186
This patch solves the issue of reversed multidimensional array nelems in the
BTF dumper and in the assembler output, but causes the multidimensional arrays
in CTF to be dumped backwards.

This behavior can also be observed in ctf_get_aname() as well as some other
functions.

The problem lies in ctf_decl_push, and I have a solution as well as some tests.

The issue with this is that if this patch is applied while compiling with a
version of gcc older than 14.2.0, this patch will make the dumper output
backwards. 

The solution to this is either to backport the gcc-14.2.0 patch, or to add a
flag to objdump and libctf.

Patch is attached.

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

* [Bug debug/116663] CTF array dimensions dumped backwards
  2024-09-10 16:33 [Bug debug/116663] New: CTF array dimensions dumped backwards bruce.mcculloch at oracle dot com
@ 2024-09-10 16:45 ` sjames at gcc dot gnu.org
  2024-09-10 16:46 ` [Bug debug/116663] [14/15 regression] " sjames at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-09-10 16:45 UTC (permalink / raw)
  To: gcc-bugs

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

Sam James <sjames at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=114186
                 CC|                            |cupertino.miranda at oracle dot co
                   |                            |m, sjames at gcc dot gnu.org

--- Comment #1 from Sam James <sjames at gcc dot gnu.org> ---
Could you send the patch to the ML? Thanks.

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

* [Bug debug/116663] [14/15 regression] CTF array dimensions dumped backwards
  2024-09-10 16:33 [Bug debug/116663] New: CTF array dimensions dumped backwards bruce.mcculloch at oracle dot com
  2024-09-10 16:45 ` [Bug debug/116663] " sjames at gcc dot gnu.org
@ 2024-09-10 16:46 ` sjames at gcc dot gnu.org
  2024-09-10 16:49 ` sjames at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-09-10 16:46 UTC (permalink / raw)
  To: gcc-bugs

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

Sam James <sjames at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|CTF array dimensions dumped |[14/15 regression] CTF
                   |backwards                   |array dimensions dumped
                   |                            |backwards
   Target Milestone|---                         |14.3

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

* [Bug debug/116663] [14/15 regression] CTF array dimensions dumped backwards
  2024-09-10 16:33 [Bug debug/116663] New: CTF array dimensions dumped backwards bruce.mcculloch at oracle dot com
  2024-09-10 16:45 ` [Bug debug/116663] " sjames at gcc dot gnu.org
  2024-09-10 16:46 ` [Bug debug/116663] [14/15 regression] " sjames at gcc dot gnu.org
@ 2024-09-10 16:49 ` sjames at gcc dot gnu.org
  2024-09-10 16:54 ` bruce.mcculloch at oracle dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-09-10 16:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Sam James <sjames at gcc dot gnu.org> ---
Ah, wait, your patch is for libctf (-> binutils)?

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

* [Bug debug/116663] [14/15 regression] CTF array dimensions dumped backwards
  2024-09-10 16:33 [Bug debug/116663] New: CTF array dimensions dumped backwards bruce.mcculloch at oracle dot com
                   ` (2 preceding siblings ...)
  2024-09-10 16:49 ` sjames at gcc dot gnu.org
@ 2024-09-10 16:54 ` bruce.mcculloch at oracle dot com
  2024-09-10 17:23 ` jemarch at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bruce.mcculloch at oracle dot com @ 2024-09-10 16:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Bruce McCulloch <bruce.mcculloch at oracle dot com> ---
Yes, just realized I'm on the wrong bugzilla -- apologies

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

* [Bug debug/116663] [14/15 regression] CTF array dimensions dumped backwards
  2024-09-10 16:33 [Bug debug/116663] New: CTF array dimensions dumped backwards bruce.mcculloch at oracle dot com
                   ` (3 preceding siblings ...)
  2024-09-10 16:54 ` bruce.mcculloch at oracle dot com
@ 2024-09-10 17:23 ` jemarch at gcc dot gnu.org
  2024-09-10 17:24 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jemarch at gcc dot gnu.org @ 2024-09-10 17:23 UTC (permalink / raw)
  To: gcc-bugs

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

Jose E. Marchesi <jemarch at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jemarch at gcc dot gnu.org
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #4 from Jose E. Marchesi <jemarch at gcc dot gnu.org> ---
Resolving as invalid since this should be filed in binutils.

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

* [Bug debug/116663] [14/15 regression] CTF array dimensions dumped backwards
  2024-09-10 16:33 [Bug debug/116663] New: CTF array dimensions dumped backwards bruce.mcculloch at oracle dot com
                   ` (4 preceding siblings ...)
  2024-09-10 17:23 ` jemarch at gcc dot gnu.org
@ 2024-09-10 17:24 ` pinskia at gcc dot gnu.org
  2024-09-10 17:26 ` bruce.mcculloch at oracle dot com
  2024-09-10 17:28 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-09-10 17:24 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|INVALID                     |MOVED

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

* [Bug debug/116663] [14/15 regression] CTF array dimensions dumped backwards
  2024-09-10 16:33 [Bug debug/116663] New: CTF array dimensions dumped backwards bruce.mcculloch at oracle dot com
                   ` (5 preceding siblings ...)
  2024-09-10 17:24 ` pinskia at gcc dot gnu.org
@ 2024-09-10 17:26 ` bruce.mcculloch at oracle dot com
  2024-09-10 17:28 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: bruce.mcculloch at oracle dot com @ 2024-09-10 17:26 UTC (permalink / raw)
  To: gcc-bugs

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

Bruce McCulloch <bruce.mcculloch at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|MOVED                       |FIXED

--- Comment #5 from Bruce McCulloch <bruce.mcculloch at oracle dot com> ---
Posted to sourceware here:
https://sourceware.org/bugzilla/show_bug.cgi?id=32161

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

* [Bug debug/116663] [14/15 regression] CTF array dimensions dumped backwards
  2024-09-10 16:33 [Bug debug/116663] New: CTF array dimensions dumped backwards bruce.mcculloch at oracle dot com
                   ` (6 preceding siblings ...)
  2024-09-10 17:26 ` bruce.mcculloch at oracle dot com
@ 2024-09-10 17:28 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-09-10 17:28 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |MOVED

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

end of thread, other threads:[~2024-09-10 17:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-10 16:33 [Bug debug/116663] New: CTF array dimensions dumped backwards bruce.mcculloch at oracle dot com
2024-09-10 16:45 ` [Bug debug/116663] " sjames at gcc dot gnu.org
2024-09-10 16:46 ` [Bug debug/116663] [14/15 regression] " sjames at gcc dot gnu.org
2024-09-10 16:49 ` sjames at gcc dot gnu.org
2024-09-10 16:54 ` bruce.mcculloch at oracle dot com
2024-09-10 17:23 ` jemarch at gcc dot gnu.org
2024-09-10 17:24 ` pinskia at gcc dot gnu.org
2024-09-10 17:26 ` bruce.mcculloch at oracle dot com
2024-09-10 17:28 ` pinskia 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).