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.
{
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);