From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 88B253858D35; Thu, 16 Mar 2023 20:45:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 88B253858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678999546; bh=Xyuw1fzvHNyCuZGSZ4BIX65GGY39orTHUfFf1iAwLNo=; h=From:To:Subject:Date:From; b=UZCijELXhHLntHHfye1zwoTJUC+TV2VPAC93ykhUkvsXmt7B0Ad56tjoInoIHKSEl XB4lt87Tojcgn+NO7KueYfiiO/AuQggz4dFzFdCx4bvQcLHUnr4KcDN9W5q7SbyHR8 7MRjEghsBN6a913iCShVoscUTJzuzmIJsBrLxmyk= From: "ibhagat at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/109161] New: Bad CTF generated for stub in function scope Date: Thu, 16 Mar 2023 20:45:46 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ibhagat at gcc dot gnu.org 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 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=3D109161 Bug ID: 109161 Summary: Bad CTF generated for stub in function scope Product: gcc Version: 13.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 t.c=20 void set_cpu_arch (void) { typedef struct arch_stack_entry { const struct arch_stack_entry *prev; } arch_stack_entry; static arch_stack_entry *arch_stack_top; } $ gcc -gctf -g3 -c t.c $ objdump --ctf=3D.ctf t.o will hang. The hang is because the compiler spits incorrect CTF.=20 Byte offsets (which point to the location of the various sub-sections in the CTF section) encoded in the CTF header as seen via poke: ... cth_funcoff=3D0U#B, cth_objtidxoff=3D4U#B, cth_funcidxoff=3D4U#B, cth_varoff=3D8U#B, cth_typeoff=3D8U#B, cth_stroff=3D96U#B, ... -- The generated CTF section has one function object, and no variables as = can be seen from the offsets in the header. This is OK.=20 --There are however, generated types; Further, a subset of which are incor= rect (see below). (poke) ctf_dump_all_types(ctf) Types: 1: (kind 1) integer void (size 0) (signed) 2: (kind 5) function set_cpu_arch --> ID 1: (kind 1) integer void (size= 0) 3: (kind 6) struct arch_stack_entry (size 8) [0U#b] prev (ID 5) [0U#b] (ID 3) 4: (kind 12) const --> ID 3: (kind 6) struct arch_stack_entry (size 8) 5: (kind 3) pointer --> ID 4: (kind 12) const --> ID 3: (kind 6) stru= ct arch_stack_entry (size 8) [Problem #1] A struct with two members, one of which is unnamed. The type = as defined by the user has one member named prev in the struct =3D> The genera= ted CTF is incorrect. [Problem #2] Well, why is there any generated CTF at all ? Both the variab= le and the defined type are function-scope; In CTF, only top-level types, functions, variables are to be described.=