]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb/dwarf: move index unit vectors to .debug_names reader and use them
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 9 Jul 2025 15:35:10 +0000 (11:35 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Fri, 1 Aug 2025 04:25:15 +0000 (00:25 -0400)
commit5acdeb08eb52cb1dd893853376c380412d5706cb
treea12cb0ea8ffc3e338639990957d5fc8ec57f2b6d
parent3e27b49025ff4cc62a8d028f7de6aa1a53a31df1
gdb/dwarf: move index unit vectors to .debug_names reader and use them

The all_comp_units_index_cus and all_comp_units_index_tus vectors
contain the CU and TU lists as found in the .debug_names list.  It seems
like they are meant to be used by the .debug_names reader when handling
a DW_IDX_compile_unit or DW_IDX_type_unit attribute.  The value of the
attribute would translate directly into an index into one of these
vectors.

However, it looks like these vectors aren't actually used in practice.
They are used in the dwarf2_per_bfd::get_index_{c,t}u methods, which in
turn aren't used anywhere.

The handlers of DW_IDX_compile_unit and DW_IDX_type_unit use the
dwarf2_per_bfd::get_unit method, with the assumption that
dwarf2_per_bfd::all_units has comp units before type units.  This is not
the case: the .debug_names reader creates the units in
dwarf2_per_bfd::all_units using the create_all_units function, which
creates the units in the order found in .debug_info, where type units
can be interleaved with comp units.

Since those vectors are specific to the .debug_names reader, move them
to the mapped_debug_names_reader struct.  Then, update the handlers of
DW_IDX_compile_unit and DW_IDX_type_unit to actually use them.

Change-Id: Ie7db81f4442f634ac6d02280a60c6c671bcd22a5
Approved-By: Tom Tromey <tom@tromey.com>
gdb/dwarf2/read-debug-names.c
gdb/dwarf2/read.h