Fix oddity in write_gdbindex

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.
This commit is contained in:
Tom Tromey 2021-05-28 16:20:03 -06:00
parent b6aeb717a8
commit b5b44b5df0

View 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);