diff options
author | Tom de Vries <tdevries@suse.de> | 2025-08-23 06:11:41 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2025-08-23 06:11:41 +0200 |
commit | 3c7cd14c1601c7245c867eda798a79305a28eedc (patch) | |
tree | 371cbecb8f3ea37b76ed4c679af91200e8c878e1 | |
parent | 5a74ce37a50c8675ecfb10973eb1ec9139f36bd5 (diff) | |
download | binutils-3c7cd14c1601c7245c867eda798a79305a28eedc.zip binutils-3c7cd14c1601c7245c867eda798a79305a28eedc.tar.gz binutils-3c7cd14c1601c7245c867eda798a79305a28eedc.tar.bz2 |
[gdb] Make addrmap_mutable::set_empty return bool
Function addrmap_mutable::set_empty has the follow behavior (shortened
comment):
...
/* 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. */
void set_empty (CORE_ADDR start, CORE_ADDR end_inclusive,
void *obj);
...
Change the return type to bool, and return true if the full range
[START, END_INCLUSIVE] is mapped to OBJ.
Tested on x86_64-linux.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
-rw-r--r-- | gdb/addrmap.c | 20 | ||||
-rw-r--r-- | gdb/addrmap.h | 4 |
2 files changed, 18 insertions, 6 deletions
diff --git a/gdb/addrmap.c b/gdb/addrmap.c index 4549350..2b333a1 100644 --- a/gdb/addrmap.c +++ b/gdb/addrmap.c @@ -201,10 +201,11 @@ xfree_wrapper (splay_tree_key key) xfree ((void *) key); } -void +bool addrmap_mutable::set_empty (CORE_ADDR start, CORE_ADDR end_inclusive, void *obj) { + bool full_range = true; splay_tree_node n, next; void *prior_value; @@ -234,7 +235,12 @@ addrmap_mutable::set_empty (CORE_ADDR start, CORE_ADDR end_inclusive, n && addrmap_node_key (n) <= end_inclusive; n = splay_tree_successor (addrmap_node_key (n))) { - if (! addrmap_node_value (n)) + if (addrmap_node_value (n)) + { + /* Already mapped. */ + full_range = false; + } + else addrmap_node_set_value (n, obj); } @@ -254,6 +260,8 @@ addrmap_mutable::set_empty (CORE_ADDR start, CORE_ADDR end_inclusive, else prior_value = addrmap_node_value (n); } + + return full_range; } @@ -433,7 +441,9 @@ test_addrmap () check_addrmap_find (map, array, 0, 19, nullptr); /* Insert address range into mutable addrmap. */ - map.set_empty (core_addr (&array[10]), core_addr (&array[12]), val1); + bool full_range_p + = map.set_empty (core_addr (&array[10]), core_addr (&array[12]), val1); + SELF_CHECK (full_range_p); check_addrmap_find (map, array, 0, 9, nullptr); check_addrmap_find (map, array, 10, 12, val1); check_addrmap_find (map, array, 13, 19, nullptr); @@ -469,7 +479,9 @@ test_addrmap () check_addrmap_find (*map2, array, 14, 19, nullptr); /* Insert partially overlapping address range into mutable addrmap. */ - map.set_empty (core_addr (&array[11]), core_addr (&array[13]), val2); + full_range_p + = map.set_empty (core_addr (&array[11]), core_addr (&array[13]), val2); + SELF_CHECK (!full_range_p); check_addrmap_find (map, array, 0, 9, nullptr); check_addrmap_find (map, array, 10, 12, val1); check_addrmap_find (map, array, 13, 13, val2); diff --git a/gdb/addrmap.h b/gdb/addrmap.h index 179e1f8..398bdd8 100644 --- a/gdb/addrmap.h +++ b/gdb/addrmap.h @@ -152,7 +152,7 @@ public: /* 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. + unchanged. Return true if the full range is mapped to OBJ. As the name suggests, END_INCLUSIVE is also mapped to OBJ. This convention is unusual, but it allows callers to accurately specify @@ -186,7 +186,7 @@ public: semantics than to provide an interface which allows it to be implemented efficiently, but doesn't reveal too much of the representation. */ - void set_empty (CORE_ADDR start, CORE_ADDR end_inclusive, + bool set_empty (CORE_ADDR start, CORE_ADDR end_inclusive, void *obj); /* Clear this addrmap. */ |