From: Tom Tromey Date: Fri, 28 May 2021 22:20:03 +0000 (-0600) Subject: Fix oddity in write_gdbindex X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b5b44b5df07883e9dd81860ab49e08400727b70d;p=binutils-gdb.git 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. --- diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index 2da222a6b5d..ccd6ef1b7fc 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -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);