diff options
Diffstat (limited to 'gdb/addrmap.h')
-rw-r--r-- | gdb/addrmap.h | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/gdb/addrmap.h b/gdb/addrmap.h index 95f6ec8..a2feb68 100644 --- a/gdb/addrmap.h +++ b/gdb/addrmap.h @@ -52,10 +52,6 @@ struct addrmap 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.) */ - 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 @@ -94,7 +90,8 @@ public: addrmap_fixed (addrmap_fixed &&other) = default; addrmap_fixed &operator= (addrmap_fixed &&) = default; - void relocate (CORE_ADDR offset) override; + /* Relocate all the addresses in this map by OFFSET. */ + void relocate (CORE_ADDR offset); private: void *do_find (CORE_ADDR addr) const override; @@ -126,8 +123,12 @@ struct addrmap_mutable final : public addrmap { public: - addrmap_mutable (); - ~addrmap_mutable (); + addrmap_mutable () = default; + ~addrmap_mutable () + { + clear (); + } + DISABLE_COPY_AND_ASSIGN (addrmap_mutable); addrmap_mutable (addrmap_mutable &&other) @@ -138,7 +139,13 @@ public: addrmap_mutable &operator= (addrmap_mutable &&other) { - std::swap (tree, other.tree); + /* Handle self-move. */ + if (this != &other) + { + clear (); + tree = other.tree; + other.tree = nullptr; + } return *this; } @@ -181,7 +188,9 @@ public: representation. */ void set_empty (CORE_ADDR start, CORE_ADDR end_inclusive, void *obj); - void relocate (CORE_ADDR offset) override; + + /* Clear this addrmap. */ + void clear (); private: void *do_find (CORE_ADDR addr) const override; @@ -204,7 +213,7 @@ private: function, we can't keep a freelist for keys. Since mutable addrmaps are only used temporarily right now, we just leak keys from deleted nodes; they'll be freed when the obstack is freed. */ - splay_tree tree; + splay_tree tree = nullptr; /* Various helper methods. */ splay_tree_key allocate_key (CORE_ADDR addr); |