void *
-addrmap_fixed::find (CORE_ADDR addr) const
+addrmap_fixed::do_find (CORE_ADDR addr) const
{
const struct addrmap_transition *bottom = &transitions[0];
const struct addrmap_transition *top = &transitions[num_transitions - 1];
int
-addrmap_fixed::foreach (addrmap_foreach_fn fn)
+addrmap_fixed::do_foreach (addrmap_foreach_fn fn) const
{
size_t i;
void *
-addrmap_mutable::find (CORE_ADDR addr) const
+addrmap_mutable::do_find (CORE_ADDR addr) const
{
splay_tree_node n = splay_tree_lookup (addr);
if (n != nullptr)
int
-addrmap_mutable::foreach (addrmap_foreach_fn fn)
+addrmap_mutable::do_foreach (addrmap_foreach_fn fn) const
{
return splay_tree_foreach (tree, addrmap_mutable_foreach_worker, &fn);
}
addrmap entry defines the end of the range). */
bool previous_matched = false;
- auto callback = [&] (CORE_ADDR start_addr, void *obj)
+ auto callback = [&] (CORE_ADDR start_addr, const void *obj)
{
QUIT;
/* The type of a function used to iterate over the map.
OBJ is NULL for unmapped regions. */
-typedef gdb::function_view<int (CORE_ADDR start_addr, void *obj)>
- addrmap_foreach_fn;
+using addrmap_foreach_fn
+ = gdb::function_view<int (CORE_ADDR start_addr, void *obj)>;
+using addrmap_foreach_const_fn
+ = gdb::function_view<int (CORE_ADDR start_addr, const void *obj)>;
/* The base class for addrmaps. */
struct addrmap
void *obj) = 0;
/* Return the object associated with ADDR in MAP. */
- virtual void *find (CORE_ADDR addr) const = 0;
+ const void *find (CORE_ADDR addr) const
+ { return this->do_find (addr); }
+
+ void *find (CORE_ADDR addr)
+ { return this->do_find (addr); }
/* Relocate all the addresses in MAP by OFFSET. (This can be applied
to either mutable or immutable maps.) */
If FN ever returns a non-zero value, the iteration ceases
immediately, and the value is returned. Otherwise, this function
returns 0. */
- virtual int foreach (addrmap_foreach_fn fn) = 0;
+ int foreach (addrmap_foreach_const_fn fn) const
+ { return this->do_foreach (fn); }
+
+ int foreach (addrmap_foreach_fn fn)
+ { return this->do_foreach (fn); }
+
+
+private:
+ /* Worker for find, implemented by sub-classes. */
+ virtual void *do_find (CORE_ADDR addr) const = 0;
+
+ /* Worker for foreach, implemented by sub-classes. */
+ virtual int do_foreach (addrmap_foreach_fn fn) const = 0;
};
struct addrmap_mutable;
void set_empty (CORE_ADDR start, CORE_ADDR end_inclusive,
void *obj) override;
- void *find (CORE_ADDR addr) const override;
void relocate (CORE_ADDR offset) override;
- int foreach (addrmap_foreach_fn fn) override;
private:
+ void *do_find (CORE_ADDR addr) const override;
+ int do_foreach (addrmap_foreach_fn fn) const override;
/* A transition: a point in an address map where the value changes.
The map maps ADDR to VALUE, but if ADDR > 0, it maps ADDR-1 to
void set_empty (CORE_ADDR start, CORE_ADDR end_inclusive,
void *obj) override;
- void *find (CORE_ADDR addr) const override;
void relocate (CORE_ADDR offset) override;
- int foreach (addrmap_foreach_fn fn) override;
private:
+ void *do_find (CORE_ADDR addr) const override;
+ int do_foreach (addrmap_foreach_fn fn) const override;
/* A splay tree, with a node for each transition; there is a
transition at address T if T-1 and T map to different objects.
{
if (per_bfd->index_addrmap == nullptr)
return nullptr;
- return ((struct dwarf2_per_cu_data *)
- per_bfd->index_addrmap->find (adjusted_pc));
+
+ void *obj = per_bfd->index_addrmap->find (adjusted_pc);
+ return static_cast<dwarf2_per_cu_data *> (obj);
}
struct compunit_symtab *
else if (*parent_entry == nullptr)
{
CORE_ADDR lookup = form_addr (origin_offset, origin_is_dwz);
- *parent_entry
- = (cooked_index_entry *) m_die_range_map.find (lookup);
+ void *obj = m_die_range_map.find (lookup);
+ *parent_entry = static_cast <cooked_index_entry *> (obj);
}
unsigned int bytes_read;
for (const auto &entry : m_deferred_entries)
{
CORE_ADDR key = form_addr (entry.die_offset, m_per_cu->is_dwz);
- cooked_index_entry *parent
- = (cooked_index_entry *) m_die_range_map.find (key);
+ void *obj = m_die_range_map.find (key);
+ cooked_index_entry *parent = static_cast <cooked_index_entry *> (obj);
m_index_storage->add (entry.die_offset, entry.tag, entry.flags,
entry.name, parent, m_per_cu);
}