Fix two regressions caused by CU / TU merging
authorTom Tromey <tom@tromey.com>
Wed, 4 Aug 2021 18:44:10 +0000 (12:44 -0600)
committerTom Tromey <tromey@adacore.com>
Wed, 8 Sep 2021 20:50:50 +0000 (14:50 -0600)
commitde2143d60b9928fa19af00fe3dbb0c8b79b1237b
tree11a9a1a4983e97550cbacfa9ec2f5ba58a7ab12b
parentcdf4e8ae55ac5a070b6b5c17b047639f20d37f5f
Fix two regressions caused by CU / TU merging

PR symtab/28160 and PR symtab/27893 concern GDB crashes in the test
suite when using the "fission" target board.  They are both caused by
the patches that merge the list of CUs with the list of TUs (and to a
lesser degree by the patches to share DWARF data across objfiles), and
the underlying issue is the same: it turns out that reading a DWO can
cause new type units to be created.  This means that the list of
dwarf2_per_cu_data objects depends on precisely which CUs have been
expanded.  However, because the type units can be created while
expanding a CU means that the vector of CUs can expand while it is
being iterated over -- a classic mistake.  Also, because a TU can be
added later, it means the resize_symtabs approach is incorrect.

This patch fixes resize_symtabs by removing it, and having set_symtab
resize the vector on demand.  It fixes the iteration problem by
introducing a safe (index-based) iterator and changing the relevant
spots to use it.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28160
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27893

(cherry picked from commit d58e54bd277b90d847be09ae4b18bfdbc0dc2066)
gdb/dwarf2/read.c
gdb/dwarf2/read.h
This page took 0.024566 seconds and 4 git commands to generate.