public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "peadar at arista dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/97811] New: Adding transparent_union tag when typedeffing compiles but produces no debug info for components of the union Date: Thu, 12 Nov 2020 11:51:29 +0000 [thread overview] Message-ID: <bug-97811-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97811 Bug ID: 97811 Summary: Adding transparent_union tag when typedeffing compiles but produces no debug info for components of the union Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: peadar at arista dot com Target Milestone: --- Created attachment 49551 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49551&action=edit Source file for good/bad example. This is against gcc (GCC) 10.2.1 20201016 (Red Hat 10.2.1-6) But exists as far back as gcc8.4 at least. transparent_enum's are used in glibc for example, with __SOCKADDR_ARG to allow any type of the numerous address family's variants of sockaddr to be passed to functions such as bind(2). The type __SOCKADDR_ARG is declared something like this: typedef union { sockaddr * restrict __sockadddr__; sockaddr_in * restrict __sockadddr_in__; /* more sockaddr_* types ... */ } __SOCKADDR_ARG __attribute__((transparent_union)); When compiled with -g, the resulting debug information does not contain any entries for the fields of the DIE for the (anonymous) union. The construction looked a little odd to me - it seemed that the attribute is being applied to the typedef, rather than the union itself, but gcc was happy to compile it, and the type behaves as expected when passing arguments to bind(2), for example. By putting the attribute before the __SOCKADDR_ARG token, it actually fixes the problem, but it seems either the debug information should be propagated to the union, or that the compiler should complain. The attachment is a source file transparent-union.c, and embedded a comment that is the output of `readelf --debug-dump=info transparent-union.o`. You can see that for UGood, there's a typedef to the union, and the union has child DIEs for each member. For UBad, there's the typedef and the union, but no members. gdb is, of course, unable to print the content of the problematic union when debugging, and other tools are equally unhappy.
reply other threads:[~2020-11-12 11:51 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-97811-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).