From bab287cdcfb47ac472da9e8d3c8db8b15880c12c Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 26 Mar 2021 09:37:22 -0600 Subject: [PATCH] Avoid some pointer chasing in DWARF reader I noticed a spot in the DWARF reader using "per_objfile->per_bfd", where a local per_bfd variable had already been created. Looking through the file, I found a number of such spots. This patch changes them to use the already-existing local, avoiding a bit of excess pointer chasing. gdb/ChangeLog 2021-03-26 Tom Tromey * dwarf2/read.c (dwarf2_read_debug_names) (dwarf2_build_psymtabs_hard, create_addrmap_from_aranges) (dw2_debug_names_iterator::next, create_type_unit_group): Simplify. --- gdb/ChangeLog | 7 +++++++ gdb/dwarf2/read.c | 13 ++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 173b08bf04b..8e7b92087aa 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2021-03-26 Tom Tromey + + * dwarf2/read.c (dwarf2_read_debug_names) + (dwarf2_build_psymtabs_hard, create_addrmap_from_aranges) + (dw2_debug_names_iterator::next, create_type_unit_group): + Simplify. + 2021-03-25 Pedro Alves * gdb.server/bkpt-other-inferior.exp: Only enable remote output diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index ee6f3f7f7e1..2f4b54b1aa3 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2774,7 +2774,7 @@ create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, dwarf2_per_cu_data *, gdb::hash_enum> debug_info_offset_to_per_cu; - for (dwarf2_per_cu_data *per_cu : per_objfile->per_bfd->all_comp_units) + for (dwarf2_per_cu_data *per_cu : per_bfd->all_comp_units) { const auto insertpair = debug_info_offset_to_per_cu.emplace (per_cu->sect_off, per_cu); @@ -5299,7 +5299,7 @@ dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile) dwarf2_per_bfd *per_bfd = per_objfile->per_bfd; if (!read_debug_names_from_section (objfile, objfile_name (objfile), - &per_objfile->per_bfd->debug_names, *map)) + &per_bfd->debug_names, *map)) return false; /* Don't use the index if it's empty. */ @@ -5341,7 +5341,7 @@ dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile) per_bfd->debug_names_table = std::move (map); per_bfd->using_index = 1; per_bfd->quick_file_names_table = - create_quick_file_names_table (per_objfile->per_bfd->all_comp_units.size ()); + create_quick_file_names_table (per_bfd->all_comp_units.size ()); return true; } @@ -5596,7 +5596,7 @@ dw2_debug_names_iterator::next () { case DW_IDX_compile_unit: /* Don't crash on bad data. */ - if (ull >= m_per_objfile->per_bfd->all_comp_units.size ()) + if (ull >= per_bfd->all_comp_units.size ()) { complaint (_(".debug_names entry has bad CU index %s" " [in module %s]"), @@ -7455,7 +7455,7 @@ create_type_unit_group (struct dwarf2_cu *cu, sect_offset line_offset_struct) struct dwarf2_per_cu_data *per_cu; struct type_unit_group *tu_group; - tu_group = OBSTACK_ZALLOC (&per_objfile->per_bfd->obstack, type_unit_group); + tu_group = OBSTACK_ZALLOC (&per_bfd->obstack, type_unit_group); per_cu = &tu_group->per_cu; per_cu->per_bfd = per_bfd; @@ -8081,8 +8081,7 @@ dwarf2_build_psymtabs_hard (dwarf2_per_objfile *per_objfile) objfile_name (objfile)); scoped_restore restore_reading_psyms - = make_scoped_restore (&per_objfile->per_bfd->reading_partial_symbols, - true); + = make_scoped_restore (&per_bfd->reading_partial_symbols, true); per_bfd->info.read (objfile); -- 2.30.2