From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9A514385AE51; Thu, 14 Jul 2022 13:35:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9A514385AE51 From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug symtab/29367] New: [gdb, debug-types, gdb-index] Bad CU index complaint not triggered Date: Thu, 14 Jul 2022 13:35:02 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: symtab X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jul 2022 13:35:02 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D29367 Bug ID: 29367 Summary: [gdb, debug-types, gdb-index] Bad CU index complaint not triggered Product: gdb Version: HEAD Status: NEW Severity: normal Priority: P2 Component: symtab Assignee: unassigned at sourceware dot org Reporter: vries at gcc dot gnu.org Target Milestone: --- [ .gdb_index variant of PR29336. ] Do this change in the test-suite: ... diff --git a/gdb/testsuite/gdb.ada/access_tagged_param.exp b/gdb/testsuite/gdb.ada/access_t agged_param.exp index 2b8e8ef172f..9c2b1871819 100644 --- a/gdb/testsuite/gdb.ada/access_tagged_param.exp +++ b/gdb/testsuite/gdb.ada/access_tagged_param.exp @@ -22,7 +22,7 @@ if { [skip_ada_tests] } { return -1 } standard_ada_testfile foo -if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != =3D "" } { +if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional_flags=3D-fdebug-types-section]] !=3D "" } { return -1 } ... and run the test-case with target board cc-with-gdb-index. Verify that there are no complaints: ... $ gdb -q -batch -iex "set complaints 100" ./outputs/gdb.ada/access_tagged_param/foo -ex "b foo" Breakpoint 1 at 0x4023f4: file /home/vries/gdb_versions/devel/binutils-gdb.git/gdb/testsuite/gdb.ada/acces= s_tagged_param/foo.adb, line 17. ... Observe using readelf -w that nr_cus =3D=3D 56 and nr_tus =3D=3D 10. Now hack gdb: ... diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index e554bc4f642..b3f0f5506c8 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2996,6 +2996,7 @@ dw2_symtab_iter_next (struct dw2_symtab_iterator *ite= r, int attrs_valid =3D (index.version >=3D 7 && symbol_kind !=3D GDB_INDEX_SYMBOL_KIND_NONE); + cu_index =3D 56; /* Don't crash on bad data. */ if (cu_index >=3D per_objfile->per_bfd->all_comp_units.size (CUTU)) { ... Try again to see any complaints. Still none. Now do: ... /* Don't crash on bad data. */ - if (cu_index >=3D per_objfile->per_bfd->all_comp_units.size (CUTU)) + if (cu_index >=3D per_objfile->per_bfd->all_comp_units.size (CU)) ... [ assuming tentative patch for PR29336. ] Try again: ... $ gdb -q -batch -iex "set complaints 100" ./outputs/gdb.ada/access_tagged_param/foo -ex "b foo" During symbol reading: .gdb_index entry has bad CU index [in module /home/vries/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.ada/access_t= agged_param/foo] During symbol reading: .gdb_index entry has bad CU index [in module /home/vries/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.ada/access_t= agged_param/foo] Breakpoint 1 at 0x4023f4: file /home/vries/gdb_versions/devel/binutils-gdb.git/gdb/testsuite/gdb.ada/acces= s_tagged_param/foo.adb, line 17. ... Bingo. Now the question: is this change correct? I can't figure out how a type in a .debug_types section would be addressed = from the index. Maybe 56 is the correct way to address TU 0 ? I can't tell from the readelf output. Looking at the first type in .debug_types, ada_main__local_interrupt_states___PAD, we find it back in t= he index here: ... [2574] ada_main__local_interrupt_states___PAD: 0 [static, type] ... It's says zero here, but how is CU id 0 distinguished from TU id 0? --=20 You are receiving this mail because: You are on the CC list for the bug.=