aboutsummaryrefslogtreecommitdiff
path: root/gdb/addrmap.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2022-04-16 10:12:49 -0600
committerTom Tromey <tom@tromey.com>2022-06-12 10:49:48 -0600
commit93b527ef787b7c98611abd21bdd77de6c41769f1 (patch)
tree2ed7039b479e080e108387a9e7a53c2050d73f44 /gdb/addrmap.h
parentd89120e9493281a60d6e7280e9cfa3741ea7e379 (diff)
downloadgdb-93b527ef787b7c98611abd21bdd77de6c41769f1.zip
gdb-93b527ef787b7c98611abd21bdd77de6c41769f1.tar.gz
gdb-93b527ef787b7c98611abd21bdd77de6c41769f1.tar.bz2
Use malloc for mutable addrmaps
Mutable addrmaps currently require an obstack. This was probably done to avoid having to call splay_tree_delete, but examination of the code shows that all mutable obstacks have a limited lifetime -- now it's simple to treat them as ordinary C++ objects, in some cases stack-allocating them, and have a destructor to make the needed call. This patch implements this change.
Diffstat (limited to 'gdb/addrmap.h')
-rw-r--r--gdb/addrmap.h23
1 files changed, 6 insertions, 17 deletions
diff --git a/gdb/addrmap.h b/gdb/addrmap.h
index a3b1d6a..bdf1199 100644
--- a/gdb/addrmap.h
+++ b/gdb/addrmap.h
@@ -32,7 +32,7 @@
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. */
@@ -40,7 +40,7 @@ typedef gdb::function_view<int (CORE_ADDR start_addr, void *obj)>
addrmap_foreach_fn;
/* The base class for addrmaps. */
-struct addrmap : public allocate_on_obstack
+struct addrmap
{
virtual ~addrmap () = default;
@@ -101,7 +101,8 @@ struct addrmap : public allocate_on_obstack
struct addrmap_mutable;
/* Fixed address maps. */
-struct addrmap_fixed : public addrmap
+struct addrmap_fixed : public addrmap,
+ public allocate_on_obstack
{
public:
@@ -142,7 +143,8 @@ struct addrmap_mutable : public addrmap
{
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,
@@ -153,16 +155,6 @@ public:
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.
@@ -190,9 +182,6 @@ private:
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);
};