gdb_static_assert (sizeof (splay_tree_key) >= sizeof (CORE_ADDR *));
gdb_static_assert (sizeof (splay_tree_value) >= sizeof (void *));
-\f
-void
-addrmap_set_empty (struct addrmap *map,
- CORE_ADDR start, CORE_ADDR end_inclusive,
- void *obj)
-{
- map->set_empty (start, end_inclusive, obj);
-}
-
-
-void *
-addrmap_find (const addrmap *map, CORE_ADDR addr)
-{
- return map->find (addr);
-}
-
-
-struct addrmap *
-addrmap_create_fixed (struct addrmap *original, struct obstack *obstack)
-{
- return original->create_fixed (obstack);
-}
-
-
-/* Relocate all the addresses in MAP by OFFSET. (This can be applied
- to either mutable or immutable maps.) */
-void
-addrmap_relocate (struct addrmap *map, CORE_ADDR offset)
-{
- map->relocate (offset);
-}
-
-
-int
-addrmap_foreach (struct addrmap *map, addrmap_foreach_fn fn)
-{
- return map->foreach (fn);
-}
\f
/* Fixed address maps. */
size_t transition_count = 0;
/* Count the number of transitions in the tree. */
- addrmap_foreach (mut, [&] (CORE_ADDR start, void *obj)
+ mut->foreach ([&] (CORE_ADDR start, void *obj)
{
++transition_count;
return 0;
/* Copy all entries from the splay tree to the array, in order
of increasing address. */
- addrmap_foreach (mut, [&] (CORE_ADDR start, void *obj)
+ mut->foreach ([&] (CORE_ADDR start, void *obj)
{
transitions[num_transitions].addr = start;
transitions[num_transitions].value = obj;
return 0;
};
- addrmap_foreach (map, callback);
+ map->foreach (callback);
}
#if GDB_SELF_TEST
do \
{ \
for (unsigned i = LOW; i <= HIGH; ++i) \
- SELF_CHECK (addrmap_find (MAP, core_addr (&ARRAY[i])) == VAL); \
+ SELF_CHECK (MAP->find (core_addr (&ARRAY[i])) == VAL); \
} \
while (0)
CHECK_ADDRMAP_FIND (map, array, 0, 19, nullptr);
/* Insert address range into mutable addrmap. */
- addrmap_set_empty (map, core_addr (&array[10]), core_addr (&array[12]),
- val1);
+ map->set_empty (core_addr (&array[10]), core_addr (&array[12]), val1);
CHECK_ADDRMAP_FIND (map, array, 0, 9, nullptr);
CHECK_ADDRMAP_FIND (map, array, 10, 12, val1);
CHECK_ADDRMAP_FIND (map, array, 13, 19, nullptr);
/* Create corresponding fixed addrmap. */
- struct addrmap *map2 = addrmap_create_fixed (map, &temp_obstack);
+ struct addrmap *map2 = map->create_fixed (&temp_obstack);
SELF_CHECK (map2 != nullptr);
CHECK_ADDRMAP_FIND (map2, array, 0, 9, nullptr);
CHECK_ADDRMAP_FIND (map2, array, 10, 12, val1);
SELF_CHECK (false);
return 0;
};
- SELF_CHECK (addrmap_foreach (map, callback) == 0);
- SELF_CHECK (addrmap_foreach (map2, callback) == 0);
+ SELF_CHECK (map->foreach (callback) == 0);
+ SELF_CHECK (map2->foreach (callback) == 0);
/* Relocate fixed addrmap. */
- addrmap_relocate (map2, 1);
+ map2->relocate (1);
CHECK_ADDRMAP_FIND (map2, array, 0, 10, nullptr);
CHECK_ADDRMAP_FIND (map2, array, 11, 13, val1);
CHECK_ADDRMAP_FIND (map2, array, 14, 19, nullptr);
/* Insert partially overlapping address range into mutable addrmap. */
- addrmap_set_empty (map, core_addr (&array[11]), core_addr (&array[13]),
- val2);
+ map->set_empty (core_addr (&array[11]), core_addr (&array[13]), val2);
CHECK_ADDRMAP_FIND (map, array, 0, 9, nullptr);
CHECK_ADDRMAP_FIND (map, array, 10, 12, val1);
CHECK_ADDRMAP_FIND (map, array, 13, 13, val2);
{
virtual ~addrmap () = default;
+ /* In the mutable address map MAP, associate the addresses from START
+ to END_INCLUSIVE that are currently associated with NULL with OBJ
+ instead. Addresses mapped to an object other than NULL are left
+ unchanged.
+
+ As the name suggests, END_INCLUSIVE is also mapped to OBJ. This
+ convention is unusual, but it allows callers to accurately specify
+ ranges that abut the top of the address space, and ranges that
+ cover the entire address space.
+
+ This operation seems a bit complicated for a primitive: if it's
+ needed, why not just have a simpler primitive operation that sets a
+ range to a value, wiping out whatever was there before, and then
+ let the caller construct more complicated operations from that,
+ along with some others for traversal?
+
+ It turns out this is the mutation operation we want to use all the
+ time, at least for now. Our immediate use for address maps is to
+ represent lexical blocks whose address ranges are not contiguous.
+ We walk the tree of lexical blocks present in the debug info, and
+ only create 'struct block' objects after we've traversed all a
+ block's children. If a lexical block declares no local variables
+ (and isn't the lexical block for a function's body), we omit it
+ from GDB's data structures entirely.
+
+ However, this means that we don't decide to create a block (and
+ thus record it in the address map) until after we've traversed its
+ children. If we do decide to create the block, we do so at a time
+ when all its children have already been recorded in the map. So
+ this operation --- change only those addresses left unset --- is
+ actually the operation we want to use every time.
+
+ It seems simpler to let the code which operates on the
+ representation directly deal with the hair of implementing these
+ semantics than to provide an interface which allows it to be
+ implemented efficiently, but doesn't reveal too much of the
+ representation. */
virtual void set_empty (CORE_ADDR start, CORE_ADDR end_inclusive,
void *obj) = 0;
+
+ /* Return the object associated with ADDR in MAP. */
virtual void *find (CORE_ADDR addr) const = 0;
+
+ /* Create a fixed address map which is a copy of this mutable
+ address map. Allocate entries in OBSTACK. */
virtual struct addrmap *create_fixed (struct obstack *obstack) = 0;
+
+ /* Relocate all the addresses in MAP by OFFSET. (This can be applied
+ to either mutable or immutable maps.) */
virtual void relocate (CORE_ADDR offset) = 0;
+
+ /* Call FN for every address in MAP, following an in-order traversal.
+ 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;
};
Allocate entries in OBSTACK. */
struct addrmap *addrmap_create_mutable (struct obstack *obstack);
-/* In the mutable address map MAP, associate the addresses from START
- to END_INCLUSIVE that are currently associated with NULL with OBJ
- instead. Addresses mapped to an object other than NULL are left
- unchanged.
-
- As the name suggests, END_INCLUSIVE is also mapped to OBJ. This
- convention is unusual, but it allows callers to accurately specify
- ranges that abut the top of the address space, and ranges that
- cover the entire address space.
-
- This operation seems a bit complicated for a primitive: if it's
- needed, why not just have a simpler primitive operation that sets a
- range to a value, wiping out whatever was there before, and then
- let the caller construct more complicated operations from that,
- along with some others for traversal?
-
- It turns out this is the mutation operation we want to use all the
- time, at least for now. Our immediate use for address maps is to
- represent lexical blocks whose address ranges are not contiguous.
- We walk the tree of lexical blocks present in the debug info, and
- only create 'struct block' objects after we've traversed all a
- block's children. If a lexical block declares no local variables
- (and isn't the lexical block for a function's body), we omit it
- from GDB's data structures entirely.
-
- However, this means that we don't decide to create a block (and
- thus record it in the address map) until after we've traversed its
- children. If we do decide to create the block, we do so at a time
- when all its children have already been recorded in the map. So
- this operation --- change only those addresses left unset --- is
- actually the operation we want to use every time.
-
- It seems simpler to let the code which operates on the
- representation directly deal with the hair of implementing these
- semantics than to provide an interface which allows it to be
- implemented efficiently, but doesn't reveal too much of the
- representation. */
-void addrmap_set_empty (struct addrmap *map,
- CORE_ADDR start, CORE_ADDR end_inclusive,
- void *obj);
-
-/* Return the object associated with ADDR in MAP. */
-void *addrmap_find (const addrmap *map, CORE_ADDR addr);
-
-/* Create a fixed address map which is a copy of the mutable address
- map ORIGINAL. Allocate entries in OBSTACK. */
-struct addrmap *addrmap_create_fixed (struct addrmap *original,
- struct obstack *obstack);
-
-/* Relocate all the addresses in MAP by OFFSET. (This can be applied
- to either mutable or immutable maps.) */
-void addrmap_relocate (struct addrmap *map, CORE_ADDR offset);
-
-/* Call FN for every address in MAP, following an in-order traversal.
- If FN ever returns a non-zero value, the iteration ceases
- immediately, and the value is returned. Otherwise, this function
- returns 0. */
-int addrmap_foreach (struct addrmap *map, addrmap_foreach_fn fn);
-
/* Dump the addrmap to OUTFILE. If PAYLOAD is non-NULL, only dump any
components that map to PAYLOAD. (If PAYLOAD is NULL, the entire
map is dumped.) */
/* If we have an addrmap mapping code addresses to blocks, then use
that. */
- if (bl->map () != nullptr)
- return (const struct block *) addrmap_find (bl->map (), pc);
+ if (bl->map ())
+ return (const struct block *) bl->map ()->find (pc);
/* Otherwise, use binary search to find the last block that starts
before PC.
if (m_pending_addrmap == nullptr)
m_pending_addrmap = addrmap_create_mutable (&m_pending_addrmap_obstack);
- addrmap_set_empty (m_pending_addrmap, start, end_inclusive, block);
+ m_pending_addrmap->set_empty (start, end_inclusive, block);
}
struct blockvector *
blockvector. */
if (m_pending_addrmap != nullptr && m_pending_addrmap_interesting)
blockvector->set_map
- (addrmap_create_fixed (m_pending_addrmap, &m_objfile->objfile_obstack));
+ (m_pending_addrmap->create_fixed (&m_objfile->objfile_obstack));
else
blockvector->set_map (nullptr);
void install_addrmap (addrmap *map)
{
gdb_assert (m_addrmap == nullptr);
- m_addrmap = addrmap_create_fixed (map, &m_storage);
+ m_addrmap = map->create_fixed (&m_storage);
}
/* Finalize the index. This should be called a single time, when
found. */
dwarf2_per_cu_data *lookup (CORE_ADDR addr)
{
- return (dwarf2_per_cu_data *) addrmap_find (m_addrmap, addr);
+ return (dwarf2_per_cu_data *) m_addrmap->find (addr);
}
/* Create a new cooked_index_entry and register it with this object.
{
struct addrmap_index_data addrmap_index_data (addr_vec, cu_index_htab);
- addrmap_foreach (addrmap, addrmap_index_data);
+ addrmap->foreach (addrmap_index_data);
/* It's highly unlikely the last entry (end address = 0xff...ff)
is valid, but we should still handle it.
lo = gdbarch_adjust_dwarf2_addr (gdbarch, lo + baseaddr) - baseaddr;
hi = gdbarch_adjust_dwarf2_addr (gdbarch, hi + baseaddr) - baseaddr;
- addrmap_set_empty (mutable_map, lo, hi - 1,
- per_bfd->get_cu (cu_index));
+ mutable_map->set_empty (lo, hi - 1, per_bfd->get_cu (cu_index));
}
- per_bfd->index_addrmap = addrmap_create_fixed (mutable_map,
- &per_bfd->obstack);
+ per_bfd->index_addrmap = mutable_map->create_fixed (&per_bfd->obstack);
}
/* Read the address map data from DWARF-5 .debug_aranges, and use it
- baseaddr);
end = (gdbarch_adjust_dwarf2_addr (gdbarch, end + baseaddr)
- baseaddr);
- addrmap_set_empty (mutable_map, start, end - 1, per_cu);
+ mutable_map->set_empty (start, end - 1, per_cu);
}
per_cu->addresses_seen = true;
addrmap *mutable_map = addrmap_create_mutable (&temp_obstack);
if (read_addrmap_from_aranges (per_objfile, section, mutable_map))
- per_bfd->index_addrmap = addrmap_create_fixed (mutable_map,
- &per_bfd->obstack);
+ per_bfd->index_addrmap = mutable_map->create_fixed (&per_bfd->obstack);
}
/* A helper function that reads the .gdb_index from BUFFER and fills
{
if (per_bfd->index_addrmap == nullptr)
return nullptr;
- return (struct dwarf2_per_cu_data *) addrmap_find (per_bfd->index_addrmap,
- adjusted_pc);
+ return ((struct dwarf2_per_cu_data *)
+ per_bfd->index_addrmap->find (adjusted_pc));
}
struct compunit_symtab *
highpc = (gdbarch_adjust_dwarf2_addr (gdbarch,
range_end + baseaddr)
- baseaddr);
- addrmap_set_empty (map, lowpc, highpc - 1, datum);
+ map->set_empty (lowpc, highpc - 1, datum);
}
/* FIXME: This is recording everything as a low-high
- baseaddr - 1);
/* Store the contiguous range if it is not empty; it can be
empty for CUs with no code. */
- addrmap_set_empty (m_index_storage->get_addrmap (), low, high,
- cu->per_cu);
+ m_index_storage->get_addrmap ()->set_empty (low, high, cu->per_cu);
cu->per_cu->addresses_seen = true;
}
{
CORE_ADDR lookup = form_addr (origin_offset, origin_is_dwz);
*parent_entry
- = (cooked_index_entry *) addrmap_find (m_die_range_map,
- lookup);
+ = (cooked_index_entry *) m_die_range_map->find (lookup);
}
unsigned int bytes_read;
CORE_ADDR hi
= (gdbarch_adjust_dwarf2_addr (gdbarch, *high_pc + baseaddr)
- baseaddr);
- addrmap_set_empty (m_index_storage->get_addrmap (), lo, hi - 1,
- scanning_per_cu);
+ m_index_storage->get_addrmap ()->set_empty (lo, hi - 1,
+ scanning_per_cu);
}
}
reader->cu->per_cu->is_dwz);
CORE_ADDR end = form_addr (sect_offset (info_ptr - 1 - reader->buffer),
reader->cu->per_cu->is_dwz);
- addrmap_set_empty (m_die_range_map, start, end, (void *) parent_entry);
+ m_die_range_map->set_empty (start, end, (void *) parent_entry);
}
return info_ptr;
{
CORE_ADDR key = form_addr (entry.die_offset, m_per_cu->is_dwz);
cooked_index_entry *parent
- = (cooked_index_entry *) addrmap_find (m_die_range_map, key);
+ = (cooked_index_entry *) m_die_range_map->find (key);
m_index_storage->add (entry.die_offset, entry.tag, entry.flags,
entry.name, parent, m_per_cu);
}
if (bv->map () == nullptr)
return 0;
- new_block = (const struct block *) addrmap_find (bv->map (), pc - 1);
+ new_block = (const struct block *) bv->map ()->find (pc - 1);
if (new_block == NULL)
return 1;
int block_line_section = cust->block_line_section ();
if (bv->map () != nullptr)
- addrmap_relocate (bv->map (), delta[block_line_section]);
+ bv->map ()->relocate (delta[block_line_section]);
for (block *b : bv->blocks ())
{
struct partial_symtab *pst
= ((struct partial_symtab *)
- addrmap_find (m_partial_symtabs->psymtabs_addrmap,
- pc - baseaddr));
+ m_partial_symtabs->psymtabs_addrmap->find (pc - baseaddr));
if (pst != NULL)
{
/* FIXME: addrmaps currently do not handle overlayed sections,
if (bv->map () != nullptr)
{
- if (addrmap_find (bv->map (), pc) == nullptr)
+ if (bv->map ()->find (pc) == nullptr)
continue;
return cust;