https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101643
Bug ID: 101643 Summary: [debug, ada] packed array not described as packed Product: gcc Version: 7.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: vries at gcc dot gnu.org Target Milestone: --- [ Filing FTR. ] Consider gdb test-case foo_ra24_010.adb / pck.adb / pck.ads ( https://sourceware.org/git/?p=binutils-gdb.git;a=tree;f=gdb/testsuite/gdb.ada/big_packed_array ). With gcc-8.5.0 we have: ... $ gnatmake-8 -f foo_ra24_010.adb -fgnat-encodings=minimal -g $ gdb -q -batch ./foo_ra24_010 -ex start -ex n -ex n -ex 'p bad' Temporary breakpoint 1 at 0x402ce6: file foo_ra24_010.adb, line 19. Temporary breakpoint 1, foo_ra24_010 () at foo_ra24_010.adb:19 19 Good : PA := (others => False); 20 Bad : Bad_Packed_Table := (others => False); 22 Do_Nothing (Good'Address); -- STOP $1 = (0 => 0 <repeats 25 times>) ... while with gcc-9.3.1 we have: ... $ gnatmake-9 -f foo_ra24_010.adb -fgnat-encodings=minimal -g + gdb -q -batch ./foo_ra24_010 -ex start -ex n -ex n -ex 'p bad' Temporary breakpoint 1 at 0x402d24: file foo_ra24_010.adb, line 19. Temporary breakpoint 1, foo_ra24_010 () at foo_ra24_010.adb:19 19 Good : PA := (others => False); 20 Bad : Bad_Packed_Table := (others => False); 22 Do_Nothing (Good'Address); -- STOP $1 = (false <repeats 196 times>) ... The difference in gdb behaviour is caused by the dwarf information. With gcc-8.5.0 we have: ... <2><2074>: Abbrev Number: 10 (DW_TAG_variable) <2075> DW_AT_name : bad <207c> DW_AT_type : <0x2028> <1><2028>: Abbrev Number: 5 (DW_TAG_array_type) <2029> DW_AT_name : pck__t <202d> DW_AT_bit_stride : 8 <202e> DW_AT_type : <0x2003> <2032> DW_AT_alignment : 1 <2033> DW_AT_sibling : <0x203f> <2><2037>: Abbrev Number: 7 (DW_TAG_subrange_type) <2038> DW_AT_type : <0x200a> <203c> DW_AT_lower_bound : 0 <203d> DW_AT_upper_bound : 24 <2><203e>: Abbrev Number: 0 <1><2003>: Abbrev Number: 4 (DW_TAG_base_type) <2004> DW_AT_byte_size : 1 <2005> DW_AT_encoding : 7 (unsigned) <2006> DW_AT_name : system__unsigned_types__packed_byte <1><200a>: Abbrev Number: 4 (DW_TAG_base_type) <200b> DW_AT_byte_size : 4 <200c> DW_AT_encoding : 5 (signed) <200d> DW_AT_name : integer ... With gcc-9.3.1 we have for foo_ra24_010.adb: ... <2><20a1>: Abbrev Number: 11 (DW_TAG_variable) <20a2> DW_AT_name : bad <20a9> DW_AT_type : <0x205f> <1><205f>: Abbrev Number: 7 (DW_TAG_typedef) <2060> DW_AT_name : pck__bad_packed_table <2067> DW_AT_type : <0x2048> <206b> DW_AT_alignment : 1 <1><2048>: Abbrev Number: 5 (DW_TAG_array_type) <2049> DW_AT_name : pck__t___XP1 <204d> DW_AT_bit_stride : 8 <204e> DW_AT_type : <0x2016> <2052> DW_AT_alignment : 1 <2><2057>: Abbrev Number: 8 (DW_TAG_subrange_type) <2058> DW_AT_type : <0x201d> <205c> DW_AT_lower_bound : 0 <205d> DW_AT_upper_bound : 24 <2><205e>: Abbrev Number: 0 <1><2016>: Abbrev Number: 4 (DW_TAG_base_type) <2017> DW_AT_byte_size : 1 <2018> DW_AT_encoding : 7 (unsigned) <2019> DW_AT_name : system__unsigned_types__packed_byte <1><201d>: Abbrev Number: 4 (DW_TAG_base_type) <201e> DW_AT_byte_size : 4 <201f> DW_AT_encoding : 5 (signed) <2020> DW_AT_name : integer ... and with pck__t___XP1 listed once more for pck.adb as: ... <1><1ab5>: Abbrev Number: 5 (DW_TAG_array_type) <1ab6> DW_AT_name : pck__t___XP1 <1aba> DW_AT_bit_stride : 1 <1abb> DW_AT_type : <0x1aa0> <1abf> DW_AT_alignment : 1 <2><1ac4>: Abbrev Number: 6 (DW_TAG_subrange_type) <1ac5> DW_AT_type : <0x15f9> <1ac9> DW_AT_lower_bound : 0 <1aca> DW_AT_upper_bound : 195 <2><1acb>: Abbrev Number: 0 <1><1aa0>: Abbrev Number: 4 (DW_TAG_base_type) <1aa1> DW_AT_byte_size : 1 <1aa2> DW_AT_encoding : 2 (boolean) <1aa3> DW_AT_name : boolean <1><15f9>: Abbrev Number: 2 (DW_TAG_enumeration_type) <15fa> DW_AT_name : pck__enum_idx <15fe> DW_AT_encoding : 7 (unsigned) <15ff> DW_AT_byte_size : 1 ... ISTM that in the gcc-8.5.0 case, gdb does the best it can do with the info provided, and that is this a gcc bug.