public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug debug/113918] New: Incomplete DWARF5 debug information for anonymous unions @ 2024-02-14 9:42 tsqurt at outlook dot com 2024-02-14 10:10 ` [Bug debug/113918] " rguenth at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: tsqurt at outlook dot com @ 2024-02-14 9:42 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113918 Bug ID: 113918 Summary: Incomplete DWARF5 debug information for anonymous unions Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: tsqurt at outlook dot com Target Milestone: --- Created attachment 57421 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57421&action=edit example.c This is an academic finding and may not be a serious bug that urgently needs to be fixed. Fixing it may help improve the user's debugging experience. According to Programming languages — C, ISO/IEC9899:2017, Chapter 6, Section 7.2.1.13, the members of an anonymous structure or union are considered to be members of the containing structure or union. However, this feature does not seem to be reflected directly in the debug information. To check this problem, I use gcc-13.2.0 on Ubuntu 20.04.6 LTS, with the source code example.c attached. $gcc -o a.elf -std=c17 -gdwarf-5 --pedantic example.c $objdump -g a.elf ... <1><2e>: Abbrev Number: 2 (DW_TAG_union_type) <2f> DW_AT_byte_size : 4 <30> DW_AT_decl_file : 1 <31> DW_AT_decl_line : 4 <32> DW_AT_decl_column : 5 <33> DW_AT_sibling : <0x42> ... According to DWARF Debugging Information Format Version 5, Chapter 5, Section 7.1, this union type declared in ‘A’ should have a DW_AT_export_symbols attribute which indicates that member ‘x’ may be referenced as if ‘x’ is a member of ‘A’. To confirm that this issue is indeed a bug, I use GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2, and start with shell command `gdb a.elf`. $(gdb) b main Breakpoint 1 at 0x40110a: file example.c, line 12. $(gdb) run Starting program: a.elf Breakpoint 1, main () at example.c:12 $(gdb) expr x.z=20 $(gdb) expr x.y=20 gdb command line:1:2: error: ‘<U6720>’ has no member named ‘y’ Compilation failed. In comparison, member ‘z’ does not share this problem. This behavior is inconsistent with the C17 standard. I'm not sure if this problem should be down to DWARF5, gdb or gcc, but I think gcc should be capable to address this issue. Discussion: GCC has specified that the language is C17, so the debugger can deduce that ‘y’ is a member of ‘A’. But in DWARF5, debugging information is language-independent, so the debugger may not be responsible to make the above deduction based on the language C17. GCC should either generate a DW_AT_export_symbols attribute for the anonymous union or a descendant node for ‘A’. I do not know whether this is a bug or a feature. Please confirm this problem. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug debug/113918] Incomplete DWARF5 debug information for anonymous unions 2024-02-14 9:42 [Bug debug/113918] New: Incomplete DWARF5 debug information for anonymous unions tsqurt at outlook dot com @ 2024-02-14 10:10 ` rguenth at gcc dot gnu.org 2024-02-15 12:52 ` jakub at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: rguenth at gcc dot gnu.org @ 2024-02-14 10:10 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113918 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2024-02-14 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed at least for the user side. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug debug/113918] Incomplete DWARF5 debug information for anonymous unions 2024-02-14 9:42 [Bug debug/113918] New: Incomplete DWARF5 debug information for anonymous unions tsqurt at outlook dot com 2024-02-14 10:10 ` [Bug debug/113918] " rguenth at gcc dot gnu.org @ 2024-02-15 12:52 ` jakub at gcc dot gnu.org 2024-03-08 8:30 ` cvs-commit at gcc dot gnu.org 2024-03-08 9:00 ` jakub at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: jakub at gcc dot gnu.org @ 2024-02-15 12:52 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113918 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 57433 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57433&action=edit gcc14-pr113918.patch Untested patch to emit DW_AT_export_symbols for those cases. That said, I believe GDB must have some code to handle anonymous structs/unions even without that, because e.g. on this new testcase p s.i just works even without the patch (and after all, should even in DWARF4 and earlier where such attribute wasn't there at all). ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug debug/113918] Incomplete DWARF5 debug information for anonymous unions 2024-02-14 9:42 [Bug debug/113918] New: Incomplete DWARF5 debug information for anonymous unions tsqurt at outlook dot com 2024-02-14 10:10 ` [Bug debug/113918] " rguenth at gcc dot gnu.org 2024-02-15 12:52 ` jakub at gcc dot gnu.org @ 2024-03-08 8:30 ` cvs-commit at gcc dot gnu.org 2024-03-08 9:00 ` jakub at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2024-03-08 8:30 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113918 --- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:05109b1bd5ef4ee9d78fe17d4563889694a26d05 commit r14-9385-g05109b1bd5ef4ee9d78fe17d4563889694a26d05 Author: Jakub Jelinek <jakub@redhat.com> Date: Fri Mar 8 09:14:32 2024 +0100 dwarf2out: Emit DW_AT_export_symbols on anon unions/structs [PR113918] DWARF5 added DW_AT_export_symbols both for use on inline namespaces (where we emit it), but also on anonymous unions/structs (and we didn't emit that attribute there). The following patch fixes it. 2024-03-08 Jakub Jelinek <jakub@redhat.com> PR debug/113918 gcc/ * dwarf2out.cc (gen_field_die): Emit DW_AT_export_symbols on anonymous unions or structs for -gdwarf-5 or -gno-strict-dwarf. gcc/c/ * c-tree.h (c_type_dwarf_attribute): Declare. * c-objc-common.h (LANG_HOOKS_TYPE_DWARF_ATTRIBUTE): Redefine. * c-objc-common.cc: Include dwarf2.h. (c_type_dwarf_attribute): New function. gcc/cp/ * cp-objcp-common.cc (cp_type_dwarf_attribute): Return 1 for DW_AT_export_symbols on anonymous structs or unions. gcc/testsuite/ * c-c++-common/dwarf2/pr113918.c: New test. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug debug/113918] Incomplete DWARF5 debug information for anonymous unions 2024-02-14 9:42 [Bug debug/113918] New: Incomplete DWARF5 debug information for anonymous unions tsqurt at outlook dot com ` (2 preceding siblings ...) 2024-03-08 8:30 ` cvs-commit at gcc dot gnu.org @ 2024-03-08 9:00 ` jakub at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: jakub at gcc dot gnu.org @ 2024-03-08 9:00 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113918 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution|--- |FIXED --- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Should be implemented now in GCC 14. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-03-08 9:00 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-02-14 9:42 [Bug debug/113918] New: Incomplete DWARF5 debug information for anonymous unions tsqurt at outlook dot com 2024-02-14 10:10 ` [Bug debug/113918] " rguenth at gcc dot gnu.org 2024-02-15 12:52 ` jakub at gcc dot gnu.org 2024-03-08 8:30 ` cvs-commit at gcc dot gnu.org 2024-03-08 9:00 ` jakub 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).