From b5b44b5df07883e9dd81860ab49e08400727b70d Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 28 May 2021 16:20:03 -0600 Subject: [PATCH] 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. --- gdb/dwarf2/index-write.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); -- 2.30.2