public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug symtab/29367] New: [gdb, debug-types, gdb-index] Bad CU index complaint not triggered
@ 2022-07-14 13:35 vries at gcc dot gnu.org
  2022-07-21  9:00 ` [Bug symtab/29367] " vries at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: vries at gcc dot gnu.org @ 2022-07-14 13:35 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29367

            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]] != ""
} {
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug
additional_flags=-fdebug-types-section]] != "" } {
   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/access_tagged_param/foo.adb,
line 17.
...

Observe using readelf -w that nr_cus == 56 and nr_tus == 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 *iter,
       int attrs_valid = (index.version >= 7
                         && symbol_kind != GDB_INDEX_SYMBOL_KIND_NONE);

+      cu_index = 56;
       /* Don't crash on bad data.  */
       if (cu_index >= 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 >= per_objfile->per_bfd->all_comp_units.size (CUTU))
+      if (cu_index >= 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_tagged_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_tagged_param/foo]
Breakpoint 1 at 0x4023f4: file
/home/vries/gdb_versions/devel/binutils-gdb.git/gdb/testsuite/gdb.ada/access_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 the
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?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-21  9:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-14 13:35 [Bug symtab/29367] New: [gdb, debug-types, gdb-index] Bad CU index complaint not triggered vries at gcc dot gnu.org
2022-07-21  9:00 ` [Bug symtab/29367] " vries 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).