Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 15/19] Use gdb unordered set and map in unit tests
Date: Mon, 17 Mar 2025 20:15:08 -0600	[thread overview]
Message-ID: <20250317-replace-std-stuff-v1-15-7ba4ee88e218@tromey.com> (raw)
In-Reply-To: <20250317-replace-std-stuff-v1-0-7ba4ee88e218@tromey.com>

This changes some unit test code to use gdb:unordered_set and
gdb::unordered_map.
---
 gdb/gdbarch-selftests.c                  | 5 ++---
 gdb/unittests/command-def-selftests.c    | 5 ++---
 gdb/unittests/intrusive_list-selftests.c | 4 ++--
 3 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/gdb/gdbarch-selftests.c b/gdb/gdbarch-selftests.c
index 56ecc381505b4368c20609f597e008b12f0e2f24..27b17d172a60aa75b29041ae7a0ff770d3d4a8fe 100644
--- a/gdb/gdbarch-selftests.c
+++ b/gdb/gdbarch-selftests.c
@@ -25,8 +25,7 @@
 #include "gdbsupport/def-vector.h"
 #include "gdbarch.h"
 #include "scoped-mock-context.h"
-
-#include <map>
+#include "gdbsupport/unordered_map.h"
 
 namespace selftests {
 
@@ -131,7 +130,7 @@ register_name_test (struct gdbarch *gdbarch)
   scoped_mock_context<test_target_ops> mockctx (gdbarch);
 
   /* Track the number of times each register name appears.  */
-  std::map<const std::string, int> name_counts;
+  gdb::unordered_map<std::string, int> name_counts;
 
   const int num_regs = gdbarch_num_cooked_regs (gdbarch);
   for (auto regnum = 0; regnum < num_regs; regnum++)
diff --git a/gdb/unittests/command-def-selftests.c b/gdb/unittests/command-def-selftests.c
index cf51f0d275ab799d2f205d46e1c9e6555bd04108..1579511db1960e582de0098b08f2a9ba879161c8 100644
--- a/gdb/unittests/command-def-selftests.c
+++ b/gdb/unittests/command-def-selftests.c
@@ -20,8 +20,7 @@
 #include "cli/cli-cmds.h"
 #include "cli/cli-decode.h"
 #include "gdbsupport/selftest.h"
-
-#include <map>
+#include "gdbsupport/unordered_map.h"
 
 namespace selftests {
 
@@ -134,7 +133,7 @@ static unsigned int nr_invalid_prefixcmd = 0;
 
 /* A map associating a list with the prefix leading to it.  */
 
-static std::map<cmd_list_element **, const char *> lists;
+static gdb::unordered_map<cmd_list_element **, const char *> lists;
 
 /* Store each command list in lists, associated with the prefix to reach it.  A
    list must only be found once.
diff --git a/gdb/unittests/intrusive_list-selftests.c b/gdb/unittests/intrusive_list-selftests.c
index 0bcfa624ce579f132b59d019828fd060a5e35909..6d624e4954743bea19c20e5cbb6d321b22ca33b7 100644
--- a/gdb/unittests/intrusive_list-selftests.c
+++ b/gdb/unittests/intrusive_list-selftests.c
@@ -20,7 +20,7 @@
 #include "gdbsupport/intrusive_list.h"
 #include "gdbsupport/owning_intrusive_list.h"
 #include "gdbsupport/selftest.h"
-#include <unordered_set>
+#include "gdbsupport/unordered_set.h"
 
 /* Count of how many item_with_base or item_with_member objects are
    currently alive.  */
@@ -717,7 +717,7 @@ struct intrusive_list_test
     item_type a ("a"), b ("b"), c ("c");
     ListType list;
     std::vector<const item_type *> expected;
-    std::unordered_set<const item_type *> disposer_seen;
+    gdb::unordered_set<const item_type *> disposer_seen;
     int disposer_calls = 0;
 
     list.push_back (a);

-- 
2.46.1


  parent reply	other threads:[~2025-03-18  2:18 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-18  2:14 [PATCH 00/19] Convert std::unordered_{set,map} to gdb implementations Tom Tromey
2025-03-18  2:14 ` [PATCH 01/19] Use gdb unordered set and map in corelow.c Tom Tromey
2025-03-18  2:14 ` [PATCH 02/19] Use gdb unordered set in breakpoint.c Tom Tromey
2025-03-18  2:14 ` [PATCH 03/19] Use gdb unordered map in dictionary.c Tom Tromey
2025-03-18  2:14 ` [PATCH 04/19] Use gdb unordered map in gdb_bfd.c Tom Tromey
2025-03-18  2:14 ` [PATCH 05/19] Use gdb unordered set in symtab.c Tom Tromey
2025-03-18  2:14 ` [PATCH 06/19] Use gdb unordered map in ada-exp.y Tom Tromey
2025-03-18  2:15 ` [PATCH 07/19] Use gdb unordered map in inferior.h Tom Tromey
2025-03-18  2:15 ` [PATCH 08/19] Use gdb unordered map in stap-probe.c Tom Tromey
2025-03-18  2:15 ` [PATCH 09/19] Use gdb unordered map for complaints Tom Tromey
2025-03-18  2:15 ` [PATCH 10/19] Use gdb unordered map in linux-nat.c Tom Tromey
2025-03-18  2:15 ` [PATCH 11/19] Use gdb unordered set in linux-procfs.c Tom Tromey
2025-03-18  2:15 ` [PATCH 12/19] Use gdb unordered set and map in Python layer Tom Tromey
2025-03-18  2:15 ` [PATCH 13/19] Use gdb unordered map in ravenscar.c Tom Tromey
2025-03-18  2:15 ` [PATCH 14/19] Use gdb unordered map in target.c Tom Tromey
2025-03-18  2:15 ` Tom Tromey [this message]
2025-03-18  2:15 ` [PATCH 16/19] Use gdb unordered map in xml-tdesc.c Tom Tromey
2025-03-18  2:15 ` [PATCH 17/19] Use gdb unordered set and map in cp-namespace.c Tom Tromey
2025-03-18  3:20   ` Simon Marchi
2025-03-18 11:32     ` Tom Tromey
2025-03-18  2:15 ` [PATCH 18/19] Use gdb unordered map in tui-io.c Tom Tromey
2025-03-18  3:26   ` Simon Marchi
2025-03-18 11:34     ` Tom Tromey
2025-03-18  2:15 ` [PATCH 19/19] Use gdb unordered map in regcache.c Tom Tromey
2025-03-18  3:27 ` [PATCH 00/19] Convert std::unordered_{set,map} to gdb implementations Simon Marchi
2025-03-18 11:43   ` 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=20250317-replace-std-stuff-v1-15-7ba4ee88e218@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