[Bug libcc1/113977] debug info for alignment of structure is unspecified
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113977 Andrew Pinski changed: What|Removed |Added Status|NEW |RESOLVED Target Milestone|--- |14.0 Resolution|--- |FIXED --- Comment #14 from Andrew Pinski --- So fixed for GCC 14.
[Bug libcc1/113977] debug info for alignment of structure is unspecified
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113977 --- Comment #13 from Tom Tromey --- This is fixed on trunk now. I think that means it'll be in GCC 14... ? Which maybe I shouldn't have done according to the current status. Anyway, I'm not sure any more how gcc manages bugs, so I don't know if I should close this or what. gdb fix still not in, will do that soon.
[Bug libcc1/113977] debug info for alignment of structure is unspecified
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113977 --- Comment #12 from GCC Commits --- The master branch has been updated by Tom Tromey : https://gcc.gnu.org/g:bc0e18a960f9dff3e740f4d0cb5b25b3f68d920a commit r14-9239-gbc0e18a960f9dff3e740f4d0cb5b25b3f68d920a Author: Tom Tromey Date: Mon Feb 26 18:21:03 2024 -0700 Fix PR libcc1/113977 PR libcc1/113977 points out a case where a simple expression is rejected with a compiler error message. The bug here is that gdb does not inform the plugin of the correct alignment -- in fact, there is no way to do that. This patch adds a new method to allow the alignment to be set, and bumps the C front end protocol version. It also includes some updates to various comments in 'include', done here to simplify the merge to binutils-gdb. include * gcc-cp-interface.h (gcc_cp_fe_context_function): Update comment. * gcc-c-interface.h (enum gcc_c_api_version) : New constant. (gcc_c_fe_context_function): Update comment. * gcc-c-fe.def (finish_record_with_alignment): New method. Update documentation. libcc1 PR libcc1/113977 * libcc1plugin.cc (plugin_finish_record_or_union): New function. (plugin_finish_record_or_union): Rewrite. (plugin_init): Use GCC_C_FE_VERSION_2. * libcc1.cc (c_vtable): Use GCC_C_FE_VERSION_2. (gcc_c_fe_context): Check for GCC_C_FE_VERSION_2.
[Bug libcc1/113977] debug info for alignment of structure is unspecified
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113977 Tom Tromey changed: What|Removed |Added Assignee|unassigned at gcc dot gnu.org |tromey at gcc dot gnu.org --- Comment #11 from Tom Tromey --- I have a patch.
[Bug libcc1/113977] debug info for alignment of structure is unspecified
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113977 Andrew Pinski changed: What|Removed |Added Ever confirmed|0 |1 Resolution|MOVED |--- Last reconfirmed||2024-02-20 Status|RESOLVED|NEW --- Comment #10 from Andrew Pinski --- Confirmed for the libcc1 part that needs to be improved.
[Bug libcc1/113977] debug info for alignment of structure is unspecified
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113977 Tom Tromey changed: What|Removed |Added CC||tromey at gcc dot gnu.org --- Comment #9 from Tom Tromey --- I think this should be reopened -- some of the fix has to happen in libcc1. When this code was written, there was no way to find the alignment in DWARF. That's since been fixed but the protocol wasn't updated. There are some comments about this, see libcc1/libcc1plugin.cc: // FIXME there's no way to get this from DWARF, // or even, it seems, a particularly good way to deduce it. SET_TYPE_ALIGN (record_or_union_type, TYPE_PRECISION (pointer_sized_int_node));
[Bug libcc1/113977] debug info for alignment of structure is unspecified
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113977 --- Comment #8 from Andrew Pinski --- >(which is likely inherited from the default structure alignment requirement on >the platform) That is wrong assumption really. Since the ABI (the platform) says the alignment is type depedent and in this case the types are arrays of 7,8,9 in size of type char which definition has an alignment of 1 for the ABI. Anyways this is definitely a gdb bug in "mis"understanding the ABI.
[Bug libcc1/113977] debug info for alignment of structure is unspecified
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113977 Andrew Pinski changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|--- |MOVED See Also||https://sourceware.org/bugz ||illa/show_bug.cgi?id=31397 --- Comment #7 from Andrew Pinski --- Moved to https://sourceware.org/bugzilla/show_bug.cgi?id=31397 since this is almost definitely a bug in gdb's gcc_convert_symbol or gdb's understanding of the struct.
[Bug libcc1/113977] debug info for alignment of structure is unspecified
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113977 --- Comment #6 from Andrew Pinski --- trunk gdb fails too.
[Bug libcc1/113977] debug info for alignment of structure is unspecified
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113977 --- Comment #5 from Andrew Pinski --- (In reply to Tan Senqi from comment #4) > (In reply to Andrew Pinski from comment #3) > I think gcc can generate a DW_AT_alignment for my struct to solve this > problem. But why the alignment is considered as 8, I am not sure about this. > If it is inherited from the default structure alignment requirement on the > platform, then gcc should specify alignment for those whose alignment is not > 8. Or 8 is not the default value by DWARF5(i.e. undefined), then it is > surely a bug in gdb. So reading the definition of DW_AT_alignment, it is if the alignment is not the default for that type. In this case it should be 1 as char arrays have alignment of 1 inside structs. See https://dwarfstd.org/issues/140528.1.html for the definition. in this case the ABI specifies the alignment and GCC does not need to emit DW_AT_alignment since it is not different from the ABI. This would mean the bug is in gdb's gcc_convert_symbol, eg.: ``` gcc_convert_symbol "z": local symbol gdb command line:1:1: error: size of array element is not a multiple of its alignment ``` I am testing the trunk gdb right now to see if it was fixed.
[Bug libcc1/113977] debug info for alignment of structure is unspecified
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113977 --- Comment #4 from Tan Senqi --- (In reply to Andrew Pinski from comment #3) > For me with the trunk GCC we get: > ``` > (gdb) expr z[0]._[0] = 1 > gdb command line:1:1: error: size of array element is not a multiple of its > alignment > Compilation failed. > (gdb) expr y[0]._[0] = 1 > (gdb) expr x[0]._[0] = 1 > gdb command line:1:1: error: alignment of array elements is greater than > element size > Compilation failed. > > ``` > > I am starting to think this is a gdb issue ... I think gcc can generate a DW_AT_alignment for my struct to solve this problem. But why the alignment is considered as 8, I am not sure about this. If it is inherited from the default structure alignment requirement on the platform, then gcc should specify alignment for those whose alignment is not 8. Or 8 is not the default value by DWARF5(i.e. undefined), then it is surely a bug in gdb.
[Bug libcc1/113977] debug info for alignment of structure is unspecified
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113977 --- Comment #3 from Andrew Pinski --- For me with the trunk GCC we get: ``` (gdb) expr z[0]._[0] = 1 gdb command line:1:1: error: size of array element is not a multiple of its alignment Compilation failed. (gdb) expr y[0]._[0] = 1 (gdb) expr x[0]._[0] = 1 gdb command line:1:1: error: alignment of array elements is greater than element size Compilation failed. ``` I am starting to think this is a gdb issue ...
[Bug libcc1/113977] debug info for alignment of structure is unspecified
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113977 Andrew Pinski changed: What|Removed |Added Component|debug |libcc1 --- Comment #2 from Andrew Pinski --- Or is it is a bug in libcc1.