]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix oddity in write_gdbindex
authorTom Tromey <tom@tromey.com>
Fri, 28 May 2021 22:20:03 +0000 (16:20 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 5 Jul 2021 17:57:14 +0000 (11:57 -0600)
My recent patch to unify CUs and TUs introduced an oddity in
write_gdbindex.  Here, we pass 'i' to recursively_write_psymbols, but
we must instead pass 'counter', to handle the situation where a TU is
mixed in with the CUs.

I am not sure a test case for this is possible.  I think it can only
happen when using DWARF 5, where a TU appears in .debug_info.
However, this situation is already not handled correctly by
.gdb_index.  I filed a bug about this.

gdb/dwarf2/index-write.c

index 2da222a6b5d279ce4bec8f225df8e2658cdd1d4e..ccd6ef1b7fc7186d3c423084c36ae67376706805 100644 (file)
@@ -1441,7 +1441,7 @@ write_gdbindex (dwarf2_per_objfile *per_objfile, FILE *out_file,
        {
          if (psymtab->user == NULL)
            recursively_write_psymbols (objfile, psymtab, &symtab,
-                                       psyms_seen, i);
+                                       psyms_seen, counter);
 
          const auto insertpair = cu_index_htab.emplace (psymtab, counter);
          gdb_assert (insertpair.second);