aboutsummaryrefslogtreecommitdiff
path: root/gdb/addrmap.h
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/addrmap.h')
-rw-r--r--gdb/addrmap.h50
1 files changed, 33 insertions, 17 deletions
diff --git a/gdb/addrmap.h b/gdb/addrmap.h
index 5378b75..179e1f8 100644
--- a/gdb/addrmap.h
+++ b/gdb/addrmap.h
@@ -1,6 +1,6 @@
/* addrmap.h --- interface to address map data structure.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -17,11 +17,12 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#ifndef ADDRMAP_H
-#define ADDRMAP_H
+#ifndef GDB_ADDRMAP_H
+#define GDB_ADDRMAP_H
-#include "splay-tree.h"
#include "gdbsupport/function-view.h"
+#include "gdbsupport/gdb_obstack.h"
+#include "splay-tree.h"
/* An address map is essentially a table mapping CORE_ADDRs onto GDB
data structures, like blocks, symtabs, partial symtabs, and so on.
@@ -51,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
@@ -93,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;
@@ -125,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)
@@ -137,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;
}
@@ -180,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;
@@ -203,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);
@@ -218,8 +228,14 @@ private:
/* 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.) */
+ map is dumped.) If ANNOTATE_VALUE is non-nullptr, call it for each
+ value. */
+
void addrmap_dump (struct addrmap *map, struct ui_file *outfile,
- void *payload);
+ void *payload,
+ gdb::function_view<void (struct ui_file *outfile,
+ CORE_ADDR start_addr,
+ const void *value)>
+ annotate_value = nullptr);
-#endif /* ADDRMAP_H */
+#endif /* GDB_ADDRMAP_H */