aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2023-02-01 11:43:02 -0700
committerTom Tromey <tom@tromey.com>2023-02-08 06:44:59 -0700
commit1947a4a4bb7651a4656edceb1f9b246f96f89ebd (patch)
treec73d970e46d15b1aa1c59c16b09b77994f549062 /gdb/dwarf2
parent4e315cd4af3bee733608990ddd6cfc0941a8b1ec (diff)
downloadgdb-1947a4a4bb7651a4656edceb1f9b246f96f89ebd.zip
gdb-1947a4a4bb7651a4656edceb1f9b246f96f89ebd.tar.gz
gdb-1947a4a4bb7651a4656edceb1f9b246f96f89ebd.tar.bz2
Simplify checks of cooked_index
This changes the cooked_index_functions to avoid an extra null check now that checked_static_cast allows a null argument. Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r--gdb/dwarf2/read.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index ee4e7c1..bbbf8ad 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 == nullptr)
- return nullptr;
cooked_index *table
= (gdb::checked_static_cast<cooked_index *>
(per_bfd->index_table.get ()));
+ if (table == nullptr)
+ return nullptr;
return table->lookup (adjusted_pc);
}
@@ -18650,13 +18650,13 @@ cooked_index_functions::find_compunit_symtab_by_address
return nullptr;
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
- if (per_objfile->per_bfd->index_table == nullptr)
- return nullptr;
-
- CORE_ADDR baseaddr = objfile->data_section_offset ();
cooked_index *table
= (gdb::checked_static_cast<cooked_index *>
(per_objfile->per_bfd->index_table.get ()));
+ if (table == nullptr)
+ return nullptr;
+
+ CORE_ADDR baseaddr = objfile->data_section_offset ();
dwarf2_per_cu_data *per_cu = table->lookup (address - baseaddr);
if (per_cu == nullptr)
return nullptr;
@@ -18673,8 +18673,12 @@ cooked_index_functions::expand_matching_symbols
symbol_compare_ftype *ordered_compare)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
- if (per_objfile->per_bfd->index_table == nullptr)
+ cooked_index *table
+ = (gdb::checked_static_cast<cooked_index *>
+ (per_objfile->per_bfd->index_table.get ()));
+ if (table == nullptr)
return;
+
const block_search_flags search_flags = (global
? SEARCH_GLOBAL_BLOCK
: SEARCH_STATIC_BLOCK);
@@ -18682,9 +18686,6 @@ cooked_index_functions::expand_matching_symbols
symbol_name_matcher_ftype *name_match
= lang->get_symbol_name_matcher (lookup_name);
- cooked_index *table
- = (gdb::checked_static_cast<cooked_index *>
- (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 = get_dwarf2_per_objfile (objfile);
- if (per_objfile->per_bfd->index_table == nullptr)
- return true;
cooked_index *table
= (gdb::checked_static_cast<cooked_index *>
(per_objfile->per_bfd->index_table.get ()));
+ if (table == nullptr)
+ return true;
+
table->wait ();
dw_expand_symtabs_matching_file_matcher (per_objfile, file_matcher);