From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH][gdb/symtab] Implement addrmap_mutable_find
Date: Tue, 3 Aug 2021 16:46:58 +0200 [thread overview]
Message-ID: <20210803144656.GA8040@delia> (raw)
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;
}
next reply other threads:[~2021-08-03 14:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-03 14:46 Tom de Vries [this message]
2021-08-04 10:57 ` [committed][PATCH][gdb/symtab] " Tom de Vries
2021-08-04 16:18 ` [PATCH][gdb/symtab] " Tom Tromey
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=20210803144656.GA8040@delia \
--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