On openSUSE Tumbleweed with test-case gdb.cp/stub-array-size.exp and target board cc-with-gdb-index, I run into: ... (gdb) print sizeof(a)/sizeof(a[0])^M Division by zero^M (gdb) FAIL: gdb.cp/stub-array-size.exp: print sizeof(a)/sizeof(a[0]) ... This is a regression since gdb 12 branch point. Bisects to: ... 6acc36f71dfc60e357496174672103f133f85e97 is the first bad commit commit 6acc36f71dfc60e357496174672103f133f85e97 Author: Tom Tromey <tromey@adacore.com> Date: Thu Apr 21 09:37:24 2022 -0600 Fix method naming bug in new DWARF indexer ...
This is not reproducible sofar on Leap 15.4.
Created attachment 14400 [details] Patch adding hardcoded .s test-case Using this test-case, I can reproduce the problem on Leap 15.4.
I was able to reproduce on Fedora 34. On Monday I'll check if my gdb-index series fixes it.
(In reply to Tom Tromey from comment #3) > I was able to reproduce on Fedora 34. > On Monday I'll check if my gdb-index series fixes it. Unfortunately, for me it doesn't.
The new index says: [1008] A: 0 [global, type] whereas the old one says: [737] A: 1 [global, type] Here the old one is correct because the A in CU 0 is just a declaration without a size: <1><45>: Abbrev Number: 10 (DW_TAG_structure_type) <46> DW_AT_name : A <48> DW_AT_declaration : 1 <48> DW_AT_sibling : <0x6d> So, I think the solution is probably for the scanner to avoid creating entries for these declaration types.
https://sourceware.org/pipermail/gdb-patches/2022-October/192767.html
The master branch has been updated by Tom Tromey <tromey@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2afd002ac6acb01763d643686345cc0c6ad564bd commit 2afd002ac6acb01763d643686345cc0c6ad564bd Author: Tom Tromey <tromey@adacore.com> Date: Mon Oct 17 12:21:10 2022 -0600 Fix incorrect .gdb_index with new DWARF scanner PR symtab/29694 points out a regression caused by the new DWARF scanner when the cc-with-gdb-index target board is used. What happens here is that an older version of gdb will make an index describing the "A" type as: [737] A: 1 [global, type] whereas the new gdb says: [1008] A: 0 [global, type] Here the old one is correct because the A in CU 0 is just a declaration without a size: <1><45>: Abbrev Number: 10 (DW_TAG_structure_type) <46> DW_AT_name : A <48> DW_AT_declaration : 1 <48> DW_AT_sibling : <0x6d> This patch fixes the problem by introducing the idea of a "type declaration". I think gdb still needs to recurse into these types, searching for methods, but by marking the type itself as a declaration, gdb can skip this type during lookups and when writing the index. Regression tested on x86-64 using the cc-with-gdb-index board. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29694
Fixed.