Bug 27930

Summary: gdb index does not handle DWARF 5 type units
Product: gdb Reporter: Tom Tromey <tromey>
Component: symtabAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: sam
Priority: P2    
Version: HEAD   
Target Milestone: ---   
See Also: https://sourceware.org/bugzilla/show_bug.cgi?id=31363
Host: Target:
Build: Last reconfirmed:
Project(s) to access: ssh public key:
Bug Depends on:    
Bug Blocks: 27453, 16998    

Description Tom Tromey 2021-05-29 13:46:45 UTC
In DWARF 5, a type unit can appear in .debug_info.
However, the gdb_index section does not handle this
situation -- it assumes that all type units appear in
.debug_types.
Comment 1 Tom Tromey 2022-09-20 22:32:57 UTC
Probably we should just close this as part of a general move
to preferring .debug_names instead.
Comment 2 Tom Tromey 2025-01-20 11:54:55 UTC
There's a test for this, gdb.dwarf2/gdb-index-types-dwarf5.exp,
but from what I can see it only passes by accident.
Comment 3 Tom Tromey 2025-03-09 20:32:42 UTC
It turns out there is a check where, if there is not .debug_types,
then TUs are assumed to come from .debug_info:

      dwarf2_section_info *section
	= (per_bfd->types.size () == 1
	   ? &per_bfd->types[0]
	   : &per_bfd->infos[0]);

So while this doesn't work in general, it can work in
a specific case.  This isn't documented.