From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [pushed] Fix self-test failure in addrmap
Date: Sun, 12 Jun 2022 15:56:08 -0600 [thread overview]
Message-ID: <20220612215608.1503472-1-tom@tromey.com> (raw)
Mark pointed out that my recent addrmap C++-ficiation changes caused a
regression in the self-tests. This patch fixes the problem by
updating this test not to allocate the mutable addrmap on an obstack.
---
gdb/addrmap.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/gdb/addrmap.c b/gdb/addrmap.c
index 06f3a831df9..8c357fbf7e5 100644
--- a/gdb/addrmap.c
+++ b/gdb/addrmap.c
@@ -429,9 +429,8 @@ test_addrmap ()
void *val2 = &array[2];
/* Create mutable addrmap. */
- struct obstack temp_obstack;
- obstack_init (&temp_obstack);
- struct addrmap_mutable *map = new (&temp_obstack) addrmap_mutable;
+ auto_obstack temp_obstack;
+ std::unique_ptr<struct addrmap_mutable> map (new addrmap_mutable);
SELF_CHECK (map != nullptr);
/* Check initial state. */
@@ -445,7 +444,7 @@ test_addrmap ()
/* Create corresponding fixed addrmap. */
struct addrmap *map2
- = new (&temp_obstack) addrmap_fixed (&temp_obstack, map);
+ = new (&temp_obstack) addrmap_fixed (&temp_obstack, map.get ());
SELF_CHECK (map2 != nullptr);
CHECK_ADDRMAP_FIND (map2, array, 0, 9, nullptr);
CHECK_ADDRMAP_FIND (map2, array, 10, 12, val1);
@@ -479,9 +478,6 @@ test_addrmap ()
CHECK_ADDRMAP_FIND (map, array, 10, 12, val1);
CHECK_ADDRMAP_FIND (map, array, 13, 13, val2);
CHECK_ADDRMAP_FIND (map, array, 14, 19, nullptr);
-
- /* Cleanup. */
- obstack_free (&temp_obstack, NULL);
}
} // namespace selftests
--
2.34.1
reply other threads:[~2022-06-12 21:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220612215608.1503472-1-tom@tromey.com \
--to=tom@tromey.com \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).