Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH][gdb/symtab] Implement addrmap_mutable_find
@ 2021-08-03 14:46 Tom de Vries
  2021-08-04 10:57 ` [committed][PATCH][gdb/symtab] " Tom de Vries
  2021-08-04 16:18 ` [PATCH][gdb/symtab] " Tom Tromey
  0 siblings, 2 replies; 3+ messages in thread
From: Tom de Vries @ 2021-08-03 14:46 UTC (permalink / raw)
  To: gdb-patches

Hi,

Currently addrmap_mutable_find is not implemented:
...
static void *
addrmap_mutable_find (struct addrmap *self, CORE_ADDR addr)
{
  /* Not needed yet.  */
  internal_error (__FILE__, __LINE__,
                  _("addrmap_find is not implemented yet "
                    "for mutable addrmaps"));
}
...

I implemented this because I needed this during debugging, to be able to do:
...
(gdb) p ((dwarf2_psymtab *)addrmap_find (map, addr))->filename
...
before and after a call to addrmap_set_empty.

Rebuild on x86_64-linux, tested by using it during debugging session.

Any comments?

Thanks,
- Tom

[gdb/symtab] Implement addrmap_mutable_find

gdb/ChangeLog:

2021-08-03  Tom de Vries  <tdevries@suse.de>

	* addrmap.c (addrmap_mutable_find): Implement.

---
 gdb/addrmap.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/gdb/addrmap.c b/gdb/addrmap.c
index 9bd924e8382..1df20076be8 100644
--- a/gdb/addrmap.c
+++ b/gdb/addrmap.c
@@ -390,10 +390,22 @@ addrmap_mutable_set_empty (struct addrmap *self,
 static void *
 addrmap_mutable_find (struct addrmap *self, CORE_ADDR addr)
 {
-  /* Not needed yet.  */
-  internal_error (__FILE__, __LINE__,
-		  _("addrmap_find is not implemented yet "
-		    "for mutable addrmaps"));
+  struct addrmap_mutable *map = (struct addrmap_mutable *) self;
+  splay_tree_node n = addrmap_splay_tree_lookup (map, addr);
+  if (n != nullptr)
+    {
+      gdb_assert (addrmap_node_key (n) == addr);
+      return addrmap_node_value (n);
+    }
+
+  n = addrmap_splay_tree_predecessor (map, addr);
+  if (n != nullptr)
+    {
+      gdb_assert (addrmap_node_key (n) < addr);
+      return addrmap_node_value (n);
+    }
+
+  return nullptr;
 }
 
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-04 16:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-03 14:46 [PATCH][gdb/symtab] Implement addrmap_mutable_find Tom de Vries
2021-08-04 10:57 ` [committed][PATCH][gdb/symtab] " Tom de Vries
2021-08-04 16:18 ` [PATCH][gdb/symtab] " Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox