From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 54B863858C50; Tue, 10 Sep 2024 16:33:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 54B863858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1725986026; bh=AIvBIlLD8J6TPsDQ3JrwMc5RiUZVOxV+fcEzvj+wgjc=; h=From:To:Subject:Date:From; b=BwGvvhhCCJK/RzlJLL0bvGN2buEvVt5GpAOzpEwoRWxcWyBfkccm+VQ668ALB/NSA LSmnfBvuEXSHE8ZO08Gxthm/H21IHU89qm+CdVOglTWjvvuYAAxUs2PyRrco9bA78Q QeUiI749WnL4+C2U43xxQZO+dgWIvp3Q4jdMAPzE= From: "bruce.mcculloch at oracle dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/116663] New: CTF array dimensions dumped backwards Date: Tue, 10 Sep 2024 16:33:45 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: debug X-Bugzilla-Version: 14.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bruce.mcculloch at oracle dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D116663 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=3D59088&action=3Dedit 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 0= xc) (aligned at 0x4) -> 0x1: (kind 1) int (format 0x1) (size 0x4) (aligned at 0= x4) 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 0= xc) (aligned at 0x4) -> 0x1: (kind 1) int (format 0x1) (size 0x4) (aligned at 0= x4) 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 0= x4) Strings: 0x0:=20 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=3D114186 This patch solves the issue of reversed multidimensional array nelems in the BTF dumper and in the assembler output, but causes the multidimensional arr= ays 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 te= sts. 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.=20 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.=