From: Simon Marchi Date: Wed, 5 Mar 2025 05:06:39 +0000 (-0500) Subject: gdb/dwarf: remove unnecessary parameters to create_{cus,debug_type}_hash_table X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=37912250961807bb5dc98158edaf1ee803d0eab3;p=thirdparty%2Fbinutils-gdb.git gdb/dwarf: remove unnecessary parameters to create_{cus,debug_type}_hash_table In create_cus_hash_table, we can get the section and hash table from the dwo_file directly. In create_debug_type_hash_table, we can get the hash table from the dwo_file directly - the section varies. Change-Id: I1d5ef49df98fe2620e12b83484b28cd7398f24ae Approved-By: Tom Tromey --- diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 4bdf0b6aa42..b7274719fa6 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2539,13 +2539,12 @@ read_abbrev_offset (dwarf2_per_objfile *per_objfile, } /* A helper for create_debug_types_hash_table. Read types from SECTION - and fill them into TYPES_HTAB. It will process only type units, - therefore DW_UT_type. */ + and fill them into DWO_FILE's type unit hash table. It will process only + type units, therefore DW_UT_type. */ static void create_debug_type_hash_table (dwarf2_per_objfile *per_objfile, - struct dwo_file *dwo_file, - dwarf2_section_info *section, htab_up &types_htab, + dwo_file *dwo_file, dwarf2_section_info *section, rcuh_kind section_kind) { struct objfile *objfile = per_objfile->objfile; @@ -2606,8 +2605,8 @@ create_debug_type_hash_table (dwarf2_per_objfile *per_objfile, continue; } - if (types_htab == NULL) - types_htab = allocate_dwo_unit_table (); + if (dwo_file->tus == nullptr) + dwo_file->tus = allocate_dwo_unit_table (); dwo_tu = OBSTACK_ZALLOC (&per_objfile->per_bfd->obstack, dwo_unit); dwo_tu->dwo_file = dwo_file; @@ -2617,7 +2616,7 @@ create_debug_type_hash_table (dwarf2_per_objfile *per_objfile, dwo_tu->sect_off = sect_off; dwo_tu->length = length; - slot = htab_find_slot (types_htab.get (), dwo_tu, INSERT); + slot = htab_find_slot (dwo_file->tus.get (), dwo_tu, INSERT); gdb_assert (slot != NULL); if (*slot != NULL) complaint (_("debug type entry at offset %s is duplicate to" @@ -2639,18 +2638,15 @@ create_debug_type_hash_table (dwarf2_per_objfile *per_objfile, (or .debug_types.dwo) section(s). DWO_FILE is a pointer to the DWO file object. - The result is a pointer to the hash table or NULL if there are no types. - Note: This function processes DWO files only, not DWP files. */ static void -create_debug_types_hash_table (dwarf2_per_objfile *per_objfile, - struct dwo_file *dwo_file, - gdb::array_view type_sections, - htab_up &types_htab) +create_debug_types_hash_table + (dwarf2_per_objfile *per_objfile, dwo_file *dwo_file, + gdb::array_view type_sections) { for (dwarf2_section_info §ion : type_sections) - create_debug_type_hash_table (per_objfile, dwo_file, §ion, types_htab, + create_debug_type_hash_table (per_objfile, dwo_file, §ion, rcuh_kind::TYPE); } @@ -6931,13 +6927,13 @@ create_dwo_cu_reader (const cutu_reader *reader, const gdb_byte *info_ptr, Note: This function processes DWO files only, not DWP files. */ static void -create_cus_hash_table (dwarf2_cu *cu, struct dwo_file &dwo_file, - dwarf2_section_info §ion, htab_up &cus_htab) +create_cus_hash_table (dwarf2_cu *cu, dwo_file &dwo_file) { dwarf2_per_objfile *per_objfile = cu->per_objfile; struct objfile *objfile = per_objfile->objfile; dwarf2_per_bfd *per_bfd = per_objfile->per_bfd; const gdb_byte *info_ptr, *end_ptr; + auto §ion = dwo_file.sections.info; section.read (objfile); info_ptr = section.buffer; @@ -6968,17 +6964,17 @@ create_cus_hash_table (dwarf2_cu *cu, struct dwo_file &dwo_file, &dwo_file, &read_unit); info_ptr += per_cu.length (); - // If the unit could not be parsed, skip it. + /* If the unit could not be parsed, skip it. */ if (read_unit.dwo_file == NULL) continue; - if (cus_htab == NULL) - cus_htab = allocate_dwo_unit_table (); + if (dwo_file.cus == nullptr) + dwo_file.cus = allocate_dwo_unit_table (); dwo_unit = OBSTACK_ZALLOC (&per_bfd->obstack, struct dwo_unit); *dwo_unit = read_unit; - slot = htab_find_slot (cus_htab.get (), dwo_unit, INSERT); + slot = htab_find_slot (dwo_file.cus.get (), dwo_unit, INSERT); gdb_assert (slot != NULL); if (*slot != NULL) { @@ -8263,19 +8259,14 @@ open_and_init_dwo_file (dwarf2_cu *cu, const char *dwo_name, dwarf2_locate_dwo_sections (per_objfile->objfile, dwo_file->dbfd.get (), sec, &dwo_file->sections); - create_cus_hash_table (cu, *dwo_file, dwo_file->sections.info, dwo_file->cus); + create_cus_hash_table (cu, *dwo_file); if (cu->per_cu->version () < 5) - { - create_debug_types_hash_table (per_objfile, dwo_file.get (), - dwo_file->sections.types, dwo_file->tus); - } + create_debug_types_hash_table (per_objfile, dwo_file.get (), + dwo_file->sections.types); else - { - create_debug_type_hash_table (per_objfile, dwo_file.get (), - &dwo_file->sections.info, dwo_file->tus, - rcuh_kind::COMPILE); - } + create_debug_type_hash_table (per_objfile, dwo_file.get (), + &dwo_file->sections.info, rcuh_kind::COMPILE); dwarf_read_debug_printf ("DWO file found: %s", dwo_name);