From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 6EFE03858D39; Wed, 8 Feb 2023 14:34:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6EFE03858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675866883; bh=PAC+rT65vGixaCaz98fCCXdv0ZIjvH/WCnr8g0MSMs0=; h=From:To:Subject:Date:From; b=AcuMYlhv/EpVnKxaAj/8d6kddPyw+wEyGDv3HoPk+Xp3AKqyF9D0k71zpbzFh7Bm/ W1lqD7rvfB5VFL8GiDcvkyP4N/DcR5yLG7nX40aEER+6cD/87QoxU4fRqEL4ulimOO znDqVImfuqSQORpPmOcOu5WlCIBzvvU8OGUEXsDc= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Simplify checks of cooked_index X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 4e315cd4af3bee733608990ddd6cfc0941a8b1ec X-Git-Newrev: 1947a4a4bb7651a4656edceb1f9b246f96f89ebd Message-Id: <20230208143443.6EFE03858D39@sourceware.org> Date: Wed, 8 Feb 2023 14:34:43 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D1947a4a4bb76= 51a4656edceb1f9b246f96f89ebd commit 1947a4a4bb7651a4656edceb1f9b246f96f89ebd Author: Tom Tromey Date: Wed Feb 1 11:43:02 2023 -0700 Simplify checks of cooked_index =20 This changes the cooked_index_functions to avoid an extra null check now that checked_static_cast allows a null argument. =20 Approved-By: Simon Marchi Diff: --- gdb/dwarf2/read.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index ee4e7c1530a..bbbf8ad1816 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -18634,11 +18634,11 @@ dwarf2_per_cu_data * cooked_index_functions::find_per_cu (dwarf2_per_bfd *per_bfd, CORE_ADDR adjusted_pc) { - if (per_bfd->index_table =3D=3D nullptr) - return nullptr; cooked_index *table =3D (gdb::checked_static_cast (per_bfd->index_table.get ())); + if (table =3D=3D nullptr) + return nullptr; return table->lookup (adjusted_pc); } =20 @@ -18650,13 +18650,13 @@ cooked_index_functions::find_compunit_symtab_by_a= ddress return nullptr; =20 dwarf2_per_objfile *per_objfile =3D get_dwarf2_per_objfile (objfile); - if (per_objfile->per_bfd->index_table =3D=3D nullptr) - return nullptr; - - CORE_ADDR baseaddr =3D objfile->data_section_offset (); cooked_index *table =3D (gdb::checked_static_cast (per_objfile->per_bfd->index_table.get ())); + if (table =3D=3D nullptr) + return nullptr; + + CORE_ADDR baseaddr =3D objfile->data_section_offset (); dwarf2_per_cu_data *per_cu =3D table->lookup (address - baseaddr); if (per_cu =3D=3D nullptr) return nullptr; @@ -18673,8 +18673,12 @@ cooked_index_functions::expand_matching_symbols symbol_compare_ftype *ordered_compare) { dwarf2_per_objfile *per_objfile =3D get_dwarf2_per_objfile (objfile); - if (per_objfile->per_bfd->index_table =3D=3D nullptr) + cooked_index *table + =3D (gdb::checked_static_cast + (per_objfile->per_bfd->index_table.get ())); + if (table =3D=3D nullptr) return; + const block_search_flags search_flags =3D (global ? SEARCH_GLOBAL_BLOCK : SEARCH_STATIC_BLOCK); @@ -18682,9 +18686,6 @@ cooked_index_functions::expand_matching_symbols symbol_name_matcher_ftype *name_match =3D lang->get_symbol_name_matcher (lookup_name); =20 - cooked_index *table - =3D (gdb::checked_static_cast - (per_objfile->per_bfd->index_table.get ())); for (const cooked_index_entry *entry : table->all_entries ()) { QUIT; @@ -18713,12 +18714,13 @@ cooked_index_functions::expand_symtabs_matching enum search_domain kind) { dwarf2_per_objfile *per_objfile =3D get_dwarf2_per_objfile (objfile); - if (per_objfile->per_bfd->index_table =3D=3D nullptr) - return true; =20 cooked_index *table =3D (gdb::checked_static_cast (per_objfile->per_bfd->index_table.get ())); + if (table =3D=3D nullptr) + return true; + table->wait (); =20 dw_expand_symtabs_matching_file_matcher (per_objfile, file_matcher);