Address maps come in two flavors: fixed, and mutable. Mutable
address maps consume more memory, but can be changed and extended.
A fixed address map, once constructed (from a mutable address map),
- can't be edited. Both kinds of map are allocated in obstacks. */
+ can't be edited. */
/* The type of a function used to iterate over the map.
OBJ is NULL for unmapped regions. */
addrmap_foreach_fn;
/* The base class for addrmaps. */
-struct addrmap : public allocate_on_obstack
+struct addrmap
{
virtual ~addrmap () = default;
/* 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;
struct addrmap_mutable;
/* Fixed address maps. */
-struct addrmap_fixed : public addrmap
+struct addrmap_fixed : public addrmap,
+ public allocate_on_obstack
{
public:
void set_empty (CORE_ADDR start, CORE_ADDR end_inclusive,
void *obj) override;
void *find (CORE_ADDR addr) const override;
- struct addrmap *create_fixed (struct obstack *obstack) override;
void relocate (CORE_ADDR offset) override;
int foreach (addrmap_foreach_fn fn) override;
{
public:
- explicit addrmap_mutable (struct obstack *obs);
+ addrmap_mutable ();
+ ~addrmap_mutable ();
DISABLE_COPY_AND_ASSIGN (addrmap_mutable);
void set_empty (CORE_ADDR start, CORE_ADDR end_inclusive,
void *obj) override;
void *find (CORE_ADDR addr) const override;
- struct addrmap *create_fixed (struct obstack *obstack) override;
void relocate (CORE_ADDR offset) override;
int foreach (addrmap_foreach_fn fn) override;
private:
- /* The obstack to use for allocations for this map. */
- struct obstack *obstack;
-
- /* A freelist for splay tree nodes, allocated on obstack, and
- chained together by their 'right' pointers. */
- /* splay_tree_new_with_allocator uses the provided allocation
- function to allocate the main splay_tree structure itself, so our
- free list has to be initialized before we create the tree. */
- splay_tree_node free_nodes = nullptr;
-
/* 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.
splay_tree_node splay_tree_successor (CORE_ADDR addr);
void splay_tree_remove (CORE_ADDR addr);
void splay_tree_insert (CORE_ADDR key, void *value);
-
- static void *splay_obstack_alloc (int size, void *closure);
- static void splay_obstack_free (void *obj, void *closure);
};