Automatic date update in version.in
[binutils-gdb.git] / gdb / dwarf2 / read-debug-names.c
blobffc4f3ad5eb028662c694e124c85de105067ff55
1 /* Reading code for .debug_names
3 Copyright (C) 2023-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "read-debug-names.h"
21 #include "dwarf2/aranges.h"
22 #include "dwarf2/cooked-index.h"
24 #include "complaints.h"
25 #include "cp-support.h"
26 #include "dwz.h"
27 #include "mapped-index.h"
28 #include "read.h"
29 #include "stringify.h"
30 #include "extract-store-integer.h"
32 /* This is just like cooked_index_functions, but overrides a single
33 method so the test suite can distinguish the .debug_names case from
34 the ordinary case. */
35 struct dwarf2_debug_names_index : public cooked_index_functions
37 /* This dumps minimal information about .debug_names. It is called
38 via "mt print objfiles". The gdb.dwarf2/gdb-index.exp testcase
39 uses this to verify that .debug_names has been loaded. */
40 void dump (struct objfile *objfile) override
42 gdb_printf (".debug_names: exists\n");
43 /* This could call the superclass method if that's useful. */
47 /* This is like a cooked index, but as it has been ingested from
48 .debug_names, it can't be used to write out an index. */
49 class debug_names_index : public cooked_index
51 public:
53 using cooked_index::cooked_index;
55 cooked_index *index_for_writing () override
56 { return nullptr; }
58 quick_symbol_functions_up make_quick_functions () const override
59 { return quick_symbol_functions_up (new dwarf2_debug_names_index); }
62 /* A description of the mapped .debug_names. */
64 struct mapped_debug_names_reader
66 const gdb_byte *scan_one_entry (const char *name,
67 const gdb_byte *entry,
68 cooked_index_entry **result,
69 std::optional<ULONGEST> &parent);
70 void scan_entries (uint32_t index, const char *name, const gdb_byte *entry);
71 void scan_all_names ();
73 dwarf2_per_objfile *per_objfile = nullptr;
74 bfd *abfd = nullptr;
75 bfd_endian dwarf5_byte_order {};
76 bool dwarf5_is_dwarf64 = false;
77 bool augmentation_is_gdb = false;
78 uint8_t offset_size = 0;
79 uint32_t cu_count = 0;
80 uint32_t tu_count = 0, bucket_count = 0, name_count = 0;
81 const gdb_byte *cu_table_reordered = nullptr;
82 const gdb_byte *tu_table_reordered = nullptr;
83 const uint32_t *bucket_table_reordered = nullptr;
84 const uint32_t *hash_table_reordered = nullptr;
85 const gdb_byte *name_table_string_offs_reordered = nullptr;
86 const gdb_byte *name_table_entry_offs_reordered = nullptr;
87 const gdb_byte *entry_pool = nullptr;
89 struct index_val
91 ULONGEST dwarf_tag;
92 struct attr
94 /* Attribute name DW_IDX_*. */
95 ULONGEST dw_idx;
97 /* Attribute form DW_FORM_*. */
98 ULONGEST form;
100 /* Value if FORM is DW_FORM_implicit_const. */
101 LONGEST implicit_const;
103 std::vector<attr> attr_vec;
106 std::unordered_map<ULONGEST, index_val> abbrev_map;
108 std::unique_ptr<cooked_index_shard> shard;
109 std::vector<std::pair<cooked_index_entry *, ULONGEST>> needs_parent;
110 std::vector<std::vector<cooked_index_entry *>> all_entries;
113 /* Scan a single entry from the entries table. Set *RESULT and PARENT
114 (if needed) and return the updated pointer on success, or return
115 nullptr on error, or at the end of the table. */
117 const gdb_byte *
118 mapped_debug_names_reader::scan_one_entry (const char *name,
119 const gdb_byte *entry,
120 cooked_index_entry **result,
121 std::optional<ULONGEST> &parent)
123 unsigned int bytes_read;
124 const ULONGEST abbrev = read_unsigned_leb128 (abfd, entry, &bytes_read);
125 entry += bytes_read;
126 if (abbrev == 0)
127 return nullptr;
129 const auto indexval_it = abbrev_map.find (abbrev);
130 if (indexval_it == abbrev_map.cend ())
132 complaint (_("Wrong .debug_names undefined abbrev code %s "
133 "[in module %s]"),
134 pulongest (abbrev), bfd_get_filename (abfd));
135 return nullptr;
138 const auto &indexval = indexval_it->second;
139 cooked_index_flag flags = 0;
140 sect_offset die_offset {};
141 enum language lang = language_unknown;
142 dwarf2_per_cu_data *per_cu = nullptr;
143 for (const auto &attr : indexval.attr_vec)
145 ULONGEST ull;
146 switch (attr.form)
148 case DW_FORM_implicit_const:
149 ull = attr.implicit_const;
150 break;
151 case DW_FORM_flag_present:
152 ull = 1;
153 break;
154 case DW_FORM_udata:
155 ull = read_unsigned_leb128 (abfd, entry, &bytes_read);
156 entry += bytes_read;
157 break;
158 case DW_FORM_ref_addr:
159 ull = read_offset (abfd, entry, offset_size);
160 entry += offset_size;
161 break;
162 case DW_FORM_ref4:
163 ull = read_4_bytes (abfd, entry);
164 entry += 4;
165 break;
166 case DW_FORM_ref8:
167 ull = read_8_bytes (abfd, entry);
168 entry += 8;
169 break;
170 case DW_FORM_ref_sig8:
171 ull = read_8_bytes (abfd, entry);
172 entry += 8;
173 break;
174 default:
175 complaint (_("Unsupported .debug_names form %s [in module %s]"),
176 dwarf_form_name (attr.form),
177 bfd_get_filename (abfd));
178 return nullptr;
180 switch (attr.dw_idx)
182 case DW_IDX_compile_unit:
184 /* Don't crash on bad data. */
185 if (ull >= per_objfile->per_bfd->all_comp_units.size ())
187 complaint (_(".debug_names entry has bad CU index %s"
188 " [in module %s]"),
189 pulongest (ull),
190 bfd_get_filename (abfd));
191 continue;
194 per_cu = per_objfile->per_bfd->get_cu (ull);
195 break;
196 case DW_IDX_type_unit:
197 /* Don't crash on bad data. */
198 if (ull >= per_objfile->per_bfd->all_type_units.size ())
200 complaint (_(".debug_names entry has bad TU index %s"
201 " [in module %s]"),
202 pulongest (ull),
203 bfd_get_filename (abfd));
204 continue;
207 int nr_cus = per_objfile->per_bfd->all_comp_units.size ();
208 per_cu = per_objfile->per_bfd->get_cu (nr_cus + ull);
210 break;
211 case DW_IDX_die_offset:
212 die_offset = sect_offset (ull);
213 /* In a per-CU index (as opposed to a per-module index), index
214 entries without CU attribute implicitly refer to the single CU. */
215 if (per_cu == NULL)
216 per_cu = per_objfile->per_bfd->get_cu (0);
217 break;
218 case DW_IDX_parent:
219 parent = ull;
220 break;
221 case DW_IDX_GNU_internal:
222 if (augmentation_is_gdb && ull != 0)
223 flags |= IS_STATIC;
224 break;
225 case DW_IDX_GNU_main:
226 if (augmentation_is_gdb && ull != 0)
227 flags |= IS_MAIN;
228 break;
229 case DW_IDX_GNU_language:
230 if (augmentation_is_gdb)
231 lang = dwarf_lang_to_enum_language (ull);
232 break;
233 case DW_IDX_GNU_linkage_name:
234 if (augmentation_is_gdb && ull != 0)
235 flags |= IS_LINKAGE;
236 break;
240 /* Skip if we couldn't find a valid CU/TU index. */
241 if (per_cu != nullptr)
242 *result = shard->add (die_offset, (dwarf_tag) indexval.dwarf_tag, flags,
243 lang, name, nullptr, per_cu);
244 return entry;
247 /* Scan all the entries for NAME, at name slot INDEX. */
249 void
250 mapped_debug_names_reader::scan_entries (uint32_t index,
251 const char *name,
252 const gdb_byte *entry)
254 std::vector<cooked_index_entry *> these_entries;
256 while (true)
258 std::optional<ULONGEST> parent;
259 cooked_index_entry *this_entry;
260 entry = scan_one_entry (name, entry, &this_entry, parent);
262 if (entry == nullptr)
263 break;
265 these_entries.push_back (this_entry);
266 if (parent.has_value ())
267 needs_parent.emplace_back (this_entry, *parent);
270 all_entries[index] = std::move (these_entries);
273 /* Scan the name table and create all the entries. */
275 void
276 mapped_debug_names_reader::scan_all_names ()
278 all_entries.resize (name_count);
280 /* In the first pass, create all the entries. */
281 for (uint32_t i = 0; i < name_count; ++i)
283 const ULONGEST namei_string_offs
284 = extract_unsigned_integer ((name_table_string_offs_reordered
285 + i * offset_size),
286 offset_size, dwarf5_byte_order);
287 const char *name = read_indirect_string_at_offset (per_objfile,
288 namei_string_offs);
290 const ULONGEST namei_entry_offs
291 = extract_unsigned_integer ((name_table_entry_offs_reordered
292 + i * offset_size),
293 offset_size, dwarf5_byte_order);
294 const gdb_byte *entry = entry_pool + namei_entry_offs;
296 scan_entries (i, name, entry);
299 /* Now update the parent pointers for all entries. This has to be
300 done in a funny way because DWARF specifies the parent entry to
301 point to a name -- but we don't know which specific one. */
302 for (auto [entry, parent_idx] : needs_parent)
304 /* Name entries are indexed from 1 in DWARF. */
305 std::vector<cooked_index_entry *> &entries = all_entries[parent_idx - 1];
306 for (const auto &parent : entries)
307 if (parent->lang == entry->lang)
309 entry->set_parent (parent);
310 break;
315 /* A reader for .debug_names. */
317 struct cooked_index_debug_names : public cooked_index_worker
319 cooked_index_debug_names (dwarf2_per_objfile *per_objfile,
320 mapped_debug_names_reader &&map)
321 : cooked_index_worker (per_objfile),
322 m_map (std::move (map))
325 void do_reading () override;
327 mapped_debug_names_reader m_map;
330 void
331 cooked_index_debug_names::do_reading ()
333 complaint_interceptor complaint_handler;
334 std::vector<gdb_exception> exceptions;
337 m_map.scan_all_names ();
339 catch (const gdb_exception &exc)
341 exceptions.push_back (std::move (exc));
344 dwarf2_per_bfd *per_bfd = m_per_objfile->per_bfd;
345 per_bfd->quick_file_names_table
346 = create_quick_file_names_table (per_bfd->all_units.size ());
347 m_results.emplace_back (nullptr,
348 complaint_handler.release (),
349 std::move (exceptions),
350 parent_map ());
351 std::vector<std::unique_ptr<cooked_index_shard>> indexes;
352 indexes.push_back (std::move (m_map.shard));
353 cooked_index *table
354 = (gdb::checked_static_cast<cooked_index *>
355 (per_bfd->index_table.get ()));
356 /* Note that this code never uses IS_PARENT_DEFERRED, so it is safe
357 to pass nullptr here. */
358 table->set_contents (std::move (indexes), &m_warnings, nullptr);
360 bfd_thread_cleanup ();
363 /* Check the signatured type hash table from .debug_names. */
365 static bool
366 check_signatured_type_table_from_debug_names
367 (dwarf2_per_objfile *per_objfile,
368 const mapped_debug_names_reader &map,
369 struct dwarf2_section_info *section)
371 struct objfile *objfile = per_objfile->objfile;
372 dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
373 int nr_cus = per_bfd->all_comp_units.size ();
374 int nr_cus_tus = per_bfd->all_units.size ();
376 section->read (objfile);
378 uint32_t j = nr_cus;
379 for (uint32_t i = 0; i < map.tu_count; ++i)
381 sect_offset sect_off
382 = (sect_offset) (extract_unsigned_integer
383 (map.tu_table_reordered + i * map.offset_size,
384 map.offset_size,
385 map.dwarf5_byte_order));
387 bool found = false;
388 for (; j < nr_cus_tus; j++)
389 if (per_bfd->get_cu (j)->sect_off == sect_off)
391 found = true;
392 break;
394 if (!found)
396 warning (_("Section .debug_names has incorrect entry in TU table,"
397 " ignoring .debug_names."));
398 return false;
400 per_bfd->all_comp_units_index_tus.push_back (per_bfd->get_cu (j));
402 return true;
405 /* DWARF-5 debug_names reader. */
407 /* The old, no-longer-supported GDB augmentation. */
408 static const gdb_byte old_gdb_augmentation[]
409 = { 'G', 'D', 'B', 0 };
410 static_assert (sizeof (old_gdb_augmentation) % 4 == 0);
412 /* DWARF-5 augmentation string for GDB's DW_IDX_GNU_* extension. This
413 must have a size that is a multiple of 4. */
414 const gdb_byte dwarf5_augmentation[8] = { 'G', 'D', 'B', '2', 0, 0, 0, 0 };
415 static_assert (sizeof (dwarf5_augmentation) % 4 == 0);
417 /* A helper function that reads the .debug_names section in SECTION
418 and fills in MAP. FILENAME is the name of the file containing the
419 section; it is used for error reporting.
421 Returns true if all went well, false otherwise. */
423 static bool
424 read_debug_names_from_section (dwarf2_per_objfile *per_objfile,
425 const char *filename,
426 struct dwarf2_section_info *section,
427 mapped_debug_names_reader &map)
429 struct objfile *objfile = per_objfile->objfile;
431 if (section->empty ())
432 return false;
434 /* Older elfutils strip versions could keep the section in the main
435 executable while splitting it for the separate debug info file. */
436 if ((section->get_flags () & SEC_HAS_CONTENTS) == 0)
437 return false;
439 section->read (objfile);
441 map.per_objfile = per_objfile;
442 map.dwarf5_byte_order = gdbarch_byte_order (objfile->arch ());
444 const gdb_byte *addr = section->buffer;
446 bfd *abfd = section->get_bfd_owner ();
447 map.abfd = abfd;
449 unsigned int bytes_read;
450 LONGEST length = read_initial_length (abfd, addr, &bytes_read);
451 addr += bytes_read;
453 map.dwarf5_is_dwarf64 = bytes_read != 4;
454 map.offset_size = map.dwarf5_is_dwarf64 ? 8 : 4;
455 if (bytes_read + length != section->size)
457 /* There may be multiple per-CU indices. */
458 warning (_("Section .debug_names in %s length %s does not match "
459 "section length %s, ignoring .debug_names."),
460 filename, plongest (bytes_read + length),
461 pulongest (section->size));
462 return false;
465 /* The version number. */
466 uint16_t version = read_2_bytes (abfd, addr);
467 addr += 2;
468 if (version != 5)
470 warning (_("Section .debug_names in %s has unsupported version %d, "
471 "ignoring .debug_names."),
472 filename, version);
473 return false;
476 /* Padding. */
477 uint16_t padding = read_2_bytes (abfd, addr);
478 addr += 2;
479 if (padding != 0)
481 warning (_("Section .debug_names in %s has unsupported padding %d, "
482 "ignoring .debug_names."),
483 filename, padding);
484 return false;
487 /* comp_unit_count - The number of CUs in the CU list. */
488 map.cu_count = read_4_bytes (abfd, addr);
489 addr += 4;
491 /* local_type_unit_count - The number of TUs in the local TU
492 list. */
493 map.tu_count = read_4_bytes (abfd, addr);
494 addr += 4;
496 /* foreign_type_unit_count - The number of TUs in the foreign TU
497 list. */
498 uint32_t foreign_tu_count = read_4_bytes (abfd, addr);
499 addr += 4;
500 if (foreign_tu_count != 0)
502 warning (_("Section .debug_names in %s has unsupported %lu foreign TUs, "
503 "ignoring .debug_names."),
504 filename, static_cast<unsigned long> (foreign_tu_count));
505 return false;
508 /* bucket_count - The number of hash buckets in the hash lookup
509 table. */
510 map.bucket_count = read_4_bytes (abfd, addr);
511 addr += 4;
513 /* name_count - The number of unique names in the index. */
514 map.name_count = read_4_bytes (abfd, addr);
515 addr += 4;
517 /* abbrev_table_size - The size in bytes of the abbreviations
518 table. */
519 uint32_t abbrev_table_size = read_4_bytes (abfd, addr);
520 addr += 4;
522 /* augmentation_string_size - The size in bytes of the augmentation
523 string. This value is rounded up to a multiple of 4. */
524 uint32_t augmentation_string_size = read_4_bytes (abfd, addr);
525 addr += 4;
526 augmentation_string_size += (-augmentation_string_size) & 3;
528 if (augmentation_string_size == sizeof (old_gdb_augmentation)
529 && memcmp (addr, old_gdb_augmentation,
530 sizeof (old_gdb_augmentation)) == 0)
532 warning (_(".debug_names created by an old version of gdb; ignoring"));
533 return false;
536 map.augmentation_is_gdb = ((augmentation_string_size
537 == sizeof (dwarf5_augmentation))
538 && memcmp (addr, dwarf5_augmentation,
539 sizeof (dwarf5_augmentation)) == 0);
541 if (!map.augmentation_is_gdb)
543 warning (_(".debug_names not created by gdb; ignoring"));
544 return false;
547 addr += augmentation_string_size;
549 /* List of CUs */
550 map.cu_table_reordered = addr;
551 addr += map.cu_count * map.offset_size;
553 /* List of Local TUs */
554 map.tu_table_reordered = addr;
555 addr += map.tu_count * map.offset_size;
557 /* Hash Lookup Table */
558 map.bucket_table_reordered = reinterpret_cast<const uint32_t *> (addr);
559 addr += map.bucket_count * 4;
560 map.hash_table_reordered = reinterpret_cast<const uint32_t *> (addr);
561 if (map.bucket_count != 0)
562 addr += map.name_count * 4;
564 /* Name Table */
565 map.name_table_string_offs_reordered = addr;
566 addr += map.name_count * map.offset_size;
567 map.name_table_entry_offs_reordered = addr;
568 addr += map.name_count * map.offset_size;
570 const gdb_byte *abbrev_table_start = addr;
571 for (;;)
573 const ULONGEST index_num = read_unsigned_leb128 (abfd, addr, &bytes_read);
574 addr += bytes_read;
575 if (index_num == 0)
576 break;
578 const auto insertpair
579 = map.abbrev_map.emplace (index_num, mapped_debug_names_reader::index_val ());
580 if (!insertpair.second)
582 warning (_("Section .debug_names in %s has duplicate index %s, "
583 "ignoring .debug_names."),
584 filename, pulongest (index_num));
585 return false;
587 mapped_debug_names_reader::index_val &indexval = insertpair.first->second;
588 indexval.dwarf_tag = read_unsigned_leb128 (abfd, addr, &bytes_read);
589 addr += bytes_read;
591 for (;;)
593 mapped_debug_names_reader::index_val::attr attr;
594 attr.dw_idx = read_unsigned_leb128 (abfd, addr, &bytes_read);
595 addr += bytes_read;
596 attr.form = read_unsigned_leb128 (abfd, addr, &bytes_read);
597 addr += bytes_read;
598 if (attr.form == DW_FORM_implicit_const)
600 attr.implicit_const = read_signed_leb128 (abfd, addr,
601 &bytes_read);
602 addr += bytes_read;
604 if (attr.dw_idx == 0 && attr.form == 0)
605 break;
606 indexval.attr_vec.push_back (std::move (attr));
609 if (addr != abbrev_table_start + abbrev_table_size)
611 warning (_("Section .debug_names in %s has abbreviation_table "
612 "of size %s vs. written as %u, ignoring .debug_names."),
613 filename, plongest (addr - abbrev_table_start),
614 abbrev_table_size);
615 return false;
617 map.entry_pool = addr;
619 return true;
622 /* A helper for check_cus_from_debug_names that handles the MAP's CU
623 list. */
625 static bool
626 check_cus_from_debug_names_list (dwarf2_per_bfd *per_bfd,
627 const mapped_debug_names_reader &map,
628 dwarf2_section_info &section,
629 bool is_dwz)
631 int nr_cus = per_bfd->all_comp_units.size ();
633 if (!map.augmentation_is_gdb)
635 uint32_t j = 0;
636 for (uint32_t i = 0; i < map.cu_count; ++i)
638 sect_offset sect_off
639 = (sect_offset) (extract_unsigned_integer
640 (map.cu_table_reordered + i * map.offset_size,
641 map.offset_size,
642 map.dwarf5_byte_order));
643 bool found = false;
644 for (; j < nr_cus; j++)
645 if (per_bfd->get_cu (j)->sect_off == sect_off)
647 found = true;
648 break;
650 if (!found)
652 warning (_("Section .debug_names has incorrect entry in CU table,"
653 " ignoring .debug_names."));
654 return false;
656 per_bfd->all_comp_units_index_cus.push_back (per_bfd->get_cu (j));
658 return true;
661 if (map.cu_count != nr_cus)
663 warning (_("Section .debug_names has incorrect number of CUs in CU table,"
664 " ignoring .debug_names."));
665 return false;
668 for (uint32_t i = 0; i < map.cu_count; ++i)
670 sect_offset sect_off
671 = (sect_offset) (extract_unsigned_integer
672 (map.cu_table_reordered + i * map.offset_size,
673 map.offset_size,
674 map.dwarf5_byte_order));
675 if (sect_off != per_bfd->get_cu (i)->sect_off)
677 warning (_("Section .debug_names has incorrect entry in CU table,"
678 " ignoring .debug_names."));
679 return false;
683 return true;
686 /* Read the CU list from the mapped index, and use it to create all
687 the CU objects for this dwarf2_per_objfile. */
689 static bool
690 check_cus_from_debug_names (dwarf2_per_bfd *per_bfd,
691 const mapped_debug_names_reader &map,
692 const mapped_debug_names_reader &dwz_map)
694 if (!check_cus_from_debug_names_list (per_bfd, map, per_bfd->infos[0],
695 false /* is_dwz */))
696 return false;
698 if (dwz_map.cu_count == 0)
699 return true;
701 dwz_file *dwz = dwarf2_get_dwz_file (per_bfd);
702 return check_cus_from_debug_names_list (per_bfd, dwz_map, dwz->info,
703 true /* is_dwz */);
706 /* This does all the work for dwarf2_read_debug_names, but putting it
707 into a separate function makes some cleanup a bit simpler. */
709 static bool
710 do_dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile)
712 mapped_debug_names_reader map;
713 mapped_debug_names_reader dwz_map;
714 struct objfile *objfile = per_objfile->objfile;
715 dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
717 if (!read_debug_names_from_section (per_objfile, objfile_name (objfile),
718 &per_bfd->debug_names, map))
719 return false;
721 /* Don't use the index if it's empty. */
722 if (map.name_count == 0)
723 return false;
725 /* If there is a .dwz file, read it so we can get its CU list as
726 well. */
727 dwz_file *dwz = dwarf2_get_dwz_file (per_bfd);
728 if (dwz != NULL)
730 if (!read_debug_names_from_section (per_objfile,
731 bfd_get_filename (dwz->dwz_bfd.get ()),
732 &dwz->debug_names, dwz_map))
734 warning (_("could not read '.debug_names' section from %s; skipping"),
735 bfd_get_filename (dwz->dwz_bfd.get ()));
736 return false;
740 create_all_units (per_objfile);
741 if (!check_cus_from_debug_names (per_bfd, map, dwz_map))
742 return false;
744 if (map.tu_count != 0)
746 /* We can only handle a single .debug_info and .debug_types when we have
747 an index. */
748 if (per_bfd->infos.size () > 1
749 || per_bfd->types.size () > 1)
750 return false;
752 dwarf2_section_info *section
753 = (per_bfd->types.size () == 1
754 ? &per_bfd->types[0]
755 : &per_bfd->infos[0]);
757 if (!check_signatured_type_table_from_debug_names (per_objfile,
758 map, section))
759 return false;
762 per_bfd->debug_aranges.read (per_objfile->objfile);
763 addrmap_mutable addrmap;
764 deferred_warnings warnings;
765 read_addrmap_from_aranges (per_objfile, &per_bfd->debug_aranges,
766 &addrmap, &warnings);
767 warnings.emit ();
769 map.shard = std::make_unique<cooked_index_shard> ();
770 map.shard->install_addrmap (&addrmap);
772 cooked_index *idx
773 = new debug_names_index (per_objfile,
774 (std::make_unique<cooked_index_debug_names>
775 (per_objfile, std::move (map))));
776 per_bfd->index_table.reset (idx);
778 idx->start_reading ();
780 return true;
783 /* See read-debug-names.h. */
785 bool
786 dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile)
788 bool result = do_dwarf2_read_debug_names (per_objfile);
789 if (!result)
790 per_objfile->per_bfd->all_units.clear ();
791 return result;