diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c index a062c1ad256..30ad0b21f2d 100644 --- a/gdb/dwarf2/read-debug-names.c +++ b/gdb/dwarf2/read-debug-names.c @@ -1075,7 +1075,15 @@ dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile) } } + /* Populate the `all_units` vector. */ create_all_units (per_objfile); + create_foreign_type_units_from_debug_names (per_objfile->per_bfd, map); + + /* Sort the `all_units` vector. This must be done before the + `build_and_check_*` calls below, since they do binary search lookups in + that vector. */ + finalize_all_units (per_objfile->per_bfd); + if (!build_and_check_cu_lists_from_debug_names (per_bfd, map, dwz_map)) return false; @@ -1097,12 +1105,6 @@ dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile) return false; } - create_foreign_type_units_from_debug_names (per_objfile->per_bfd, map); - - /* create_foreign_type_units_from_debug_names may add more entries to the - ALL_UNITS vector, so it must be called before finalize_all_units. */ - finalize_all_units (per_objfile->per_bfd); - per_bfd->debug_aranges.read (per_objfile->objfile); /* There is a single address map for the whole index (coming from