[1/4] Fix oddity in write_gdbindex

Message ID 20210529135443.1446279-2-tom@tromey.com
State New
Headers show
Series
  • Some small debug index writer cleanups
Related show

Commit Message

Tom Tromey May 29, 2021, 1:54 p.m.
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/ChangeLog
2021-05-28  Tom Tromey  <tom@tromey.com>

	* dwarf2/index-write.c (write_gdbindex): Pass 'counter' to
	recursively_write_psymbols.
---
 gdb/ChangeLog            | 5 +++++
 gdb/dwarf2/index-write.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

-- 
2.26.3

Patch

diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
index 4b78add0a5a..ffc49e8ba82 100644
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -1446,7 +1446,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);