From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 2/5] [gdb] Make addrmap_mutable::insert_empty return bool
Date: Thu, 21 Aug 2025 15:31:11 +0200 [thread overview]
Message-ID: <20250821133114.24091-3-tdevries@suse.de> (raw)
In-Reply-To: <20250821133114.24091-1-tdevries@suse.de>
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.
---
gdb/addrmap.c | 23 ++++++++++++++++++-----
gdb/addrmap.h | 4 ++--
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/gdb/addrmap.c b/gdb/addrmap.c
index 45493509f21..5fddc3c32b7 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,8 +235,14 @@ 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))
- addrmap_node_set_value (n, obj);
+ if (addrmap_node_value (n))
+ {
+ /* Already mapped. */
+ full_range = false;
+ continue;
+ }
+
+ addrmap_node_set_value (n, obj);
}
/* Walk the area again, removing transitions from any value to
@@ -254,6 +261,8 @@ addrmap_mutable::set_empty (CORE_ADDR start, CORE_ADDR end_inclusive,
else
prior_value = addrmap_node_value (n);
}
+
+ return full_range;
}
@@ -433,7 +442,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 +480,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 179e1f86668..398bdd84215 100644
--- a/gdb/addrmap.h
+++ b/gdb/addrmap.h
@@ -152,7 +152,7 @@ struct addrmap_mutable final : public addrmap
/* 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 @@ struct addrmap_mutable final : public addrmap
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. */
--
2.43.0
next prev parent reply other threads:[~2025-08-21 13:35 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-21 13:31 [PATCH v2 0/5] [gdb/symtab] Handle invalid .gdb_index better Tom de Vries
2025-08-21 13:31 ` [PATCH v2 1/5] [gdb/symtab] Bail out of create_addrmap_from_gdb_index on error Tom de Vries
2025-08-21 13:31 ` Tom de Vries [this message]
2025-08-22 14:54 ` [PATCH v2 2/5] [gdb] Make addrmap_mutable::insert_empty return bool Simon Marchi
2025-08-22 18:51 ` Tom Tromey
2025-08-23 4:20 ` Tom de Vries
2025-08-23 17:53 ` Simon Marchi
2025-08-29 0:20 ` Tom Tromey
2025-08-29 8:28 ` Tom de Vries
2025-08-21 13:31 ` [PATCH v2 3/5] [gdb/symtab] Detect overlapping ranges in create_addrmap_from_gdb_index Tom de Vries
2025-08-22 14:57 ` Simon Marchi
2025-08-21 13:31 ` [PATCH v2 4/5] [gdb/symtab] Improve invalid range check " Tom de Vries
2025-08-22 14:56 ` Tom de Vries
2025-08-22 15:17 ` Simon Marchi
2025-08-22 18:53 ` Tom Tromey
2025-08-23 4:33 ` Tom de Vries
2025-08-21 13:31 ` [PATCH v2 5/5] [gdb/symtab] Turn complaints in create_addrmap_from_gdb_index into warnings Tom de Vries
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250821133114.24091-3-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox