aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2024-05-30 10:39:17 -0600
committerTom Tromey <tromey@adacore.com>2024-05-31 08:26:05 -0600
commit2e3b7a38930730b98e41f1393f8479488debb823 (patch)
tree2502d0091839acc403b36940eb538cc4af4a7e66
parent5df6499c83896c243073d8cad8c5830f89436bd6 (diff)
downloadbinutils-2e3b7a38930730b98e41f1393f8479488debb823.zip
binutils-2e3b7a38930730b98e41f1393f8479488debb823.tar.gz
binutils-2e3b7a38930730b98e41f1393f8479488debb823.tar.bz2
Move dwarf2_per_bfd::index_addrmap to mapped_gdb_index
dwarf2_per_bfd::index_addrmap is only used by the .gdb_index reader, so this field can be moved to mapped_gdb_index instead. Then, cooked_index_functions::find_per_cu can be removed in favor of a method on the index object. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31821 Approved-By: Simon Marchi <simon.marchi@efficios.com>
-rw-r--r--gdb/dwarf2/cooked-index.h5
-rw-r--r--gdb/dwarf2/mapped-index.h5
-rw-r--r--gdb/dwarf2/read-gdb-index.c17
-rw-r--r--gdb/dwarf2/read.c27
-rw-r--r--gdb/dwarf2/read.h8
5 files changed, 25 insertions, 37 deletions
diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h
index d245570..efd03e6 100644
--- a/gdb/dwarf2/cooked-index.h
+++ b/gdb/dwarf2/cooked-index.h
@@ -671,7 +671,7 @@ public:
/* Look up ADDR in the address map, and return either the
corresponding CU, or nullptr if the address could not be
found. */
- dwarf2_per_cu_data *lookup (unrelocated_addr addr);
+ dwarf2_per_cu_data *lookup (unrelocated_addr addr) override;
/* Return a new vector of all the addrmaps used by all the indexes
held by this object. */
@@ -737,9 +737,6 @@ struct cooked_index_functions : public dwarf2_base_index_functions
return table;
}
- dwarf2_per_cu_data *find_per_cu (dwarf2_per_bfd *per_bfd,
- unrelocated_addr adjusted_pc) override;
-
struct compunit_symtab *find_compunit_symtab_by_address
(struct objfile *objfile, CORE_ADDR address) override;
diff --git a/gdb/dwarf2/mapped-index.h b/gdb/dwarf2/mapped-index.h
index 86a3c59..b4f6483 100644
--- a/gdb/dwarf2/mapped-index.h
+++ b/gdb/dwarf2/mapped-index.h
@@ -82,6 +82,11 @@ struct dwarf_scanner_base
virtual void wait_completely ()
{
}
+
+ /* Look up ADDR, and return either the corresponding CU, or nullptr
+ if the address could not be found. */
+ virtual dwarf2_per_cu_data *lookup (unrelocated_addr addr)
+ { return nullptr; }
};
/* Base class containing bits shared by both .gdb_index and
diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c
index 9410924..8cd665c 100644
--- a/gdb/dwarf2/read-gdb-index.c
+++ b/gdb/dwarf2/read-gdb-index.c
@@ -91,6 +91,9 @@ struct mapped_gdb_index final : public mapped_index_base
/* The shortcut table data. */
gdb::array_view<const gdb_byte> shortcut_table;
+ /* An address map that maps from PC to dwarf2_per_cu_data. */
+ addrmap_fixed *index_addrmap = nullptr;
+
/* Return the index into the constant pool of the name of the IDXth
symbol in the symbol table. */
offset_type symbol_name_index (offset_type idx) const
@@ -129,6 +132,15 @@ struct mapped_gdb_index final : public mapped_index_base
{
return version >= 8;
}
+
+ dwarf2_per_cu_data *lookup (unrelocated_addr addr) override
+ {
+ if (index_addrmap == nullptr)
+ return nullptr;
+
+ void *obj = index_addrmap->find (static_cast<CORE_ADDR> (addr));
+ return static_cast<dwarf2_per_cu_data *> (obj);
+ }
};
struct dwarf2_gdb_index : public dwarf2_base_index_functions
@@ -528,8 +540,7 @@ create_signatured_type_table_from_gdb_index
per_bfd->signatured_types = std::move (sig_types_hash);
}
-/* Read the address map data from the mapped GDB index, and use it to
- populate the index_addrmap. */
+/* Read the address map data from the mapped GDB index. */
static void
create_addrmap_from_gdb_index (dwarf2_per_objfile *per_objfile,
@@ -570,7 +581,7 @@ create_addrmap_from_gdb_index (dwarf2_per_objfile *per_objfile,
mutable_map.set_empty (lo, hi - 1, per_bfd->get_cu (cu_index));
}
- per_bfd->index_addrmap
+ index->index_addrmap
= new (&per_bfd->obstack) addrmap_fixed (&per_bfd->obstack, &mutable_map);
}
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 4818da5..6a19064 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -2997,17 +2997,6 @@ recursively_find_pc_sect_compunit_symtab (struct compunit_symtab *cust,
return NULL;
}
-dwarf2_per_cu_data *
-dwarf2_base_index_functions::find_per_cu (dwarf2_per_bfd *per_bfd,
- unrelocated_addr adjusted_pc)
-{
- if (per_bfd->index_addrmap == nullptr)
- return nullptr;
-
- void *obj = per_bfd->index_addrmap->find ((CORE_ADDR) adjusted_pc);
- return static_cast<dwarf2_per_cu_data *> (obj);
-}
-
struct compunit_symtab *
dwarf2_base_index_functions::find_pc_sect_compunit_symtab
(struct objfile *objfile,
@@ -3019,10 +3008,14 @@ dwarf2_base_index_functions::find_pc_sect_compunit_symtab
struct compunit_symtab *result;
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
+ dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
+
+ if (per_bfd->index_table == nullptr)
+ return nullptr;
CORE_ADDR baseaddr = objfile->text_section_offset ();
struct dwarf2_per_cu_data *data
- = find_per_cu (per_objfile->per_bfd, (unrelocated_addr) (pc - baseaddr));
+ = per_bfd->index_table->lookup ((unrelocated_addr) (pc - baseaddr));
if (data == nullptr)
return nullptr;
@@ -16559,16 +16552,6 @@ cooked_indexer::make_index (cutu_reader *reader)
index_dies (reader, reader->info_ptr, nullptr, false);
}
-dwarf2_per_cu_data *
-cooked_index_functions::find_per_cu (dwarf2_per_bfd *per_bfd,
- unrelocated_addr adjusted_pc)
-{
- cooked_index *table
- = (gdb::checked_static_cast<cooked_index *>
- (per_bfd->index_table.get ()));
- return table->lookup (adjusted_pc);
-}
-
struct compunit_symtab *
cooked_index_functions::find_compunit_symtab_by_address
(struct objfile *objfile, CORE_ADDR address)
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index 7ab6152..e55d053 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -534,9 +534,6 @@ public:
std::unordered_map<sect_offset, std::vector<sect_offset>,
gdb::hash_enum<sect_offset>>
abstract_to_concrete;
-
- /* The address map that is used by the DWARF index code. */
- addrmap_fixed *index_addrmap = nullptr;
};
/* An iterator for all_units that is based on index. This
@@ -846,11 +843,6 @@ struct dwarf2_base_index_functions : public quick_symbol_functions
void expand_all_symtabs (struct objfile *objfile) override;
- /* A helper function that finds the per-cu object from an "adjusted"
- PC -- a PC with the base text offset removed. */
- virtual dwarf2_per_cu_data *find_per_cu (dwarf2_per_bfd *per_bfd,
- unrelocated_addr adjusted_pc);
-
struct compunit_symtab *find_pc_sect_compunit_symtab
(struct objfile *objfile, struct bound_minimal_symbol msymbol,
CORE_ADDR pc, struct obj_section *section, int warn_if_readin)