]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: use gdb::unordered_{set,map} at a few places
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 13 Nov 2025 21:43:56 +0000 (16:43 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 17 Nov 2025 16:31:01 +0000 (11:31 -0500)
Use the gdb:: set/map types instead of the std:: ones.  I only changed
places in files I can build on my dev machine.

I needed to explicitly default the move constructor and assigment
operator in proc_mem_file.  I think this is ok, as nothing takes the
address of a proc_mem_file, requiring it not to move.

I also needed to do it for refcnt_fd, in solib-rocm.c.  It's a bit odd
to prevent moving / copying a refcnt_fd, as this struct doesn't directly
hold a resource, but I think I get why it was done.

Change-Id: If6f2d7ba3b1ae338eba38b0ab9f987400e661dff
Approved-By: Tom Tromey <tom@tromey.com>
gdb/aarch64-tdep.c
gdb/amdgpu-tdep.c
gdb/amdgpu-tdep.h
gdb/arch/amd64-linux-tdesc.c
gdb/arch/i386-linux-tdesc.c
gdb/i386-tdep.c
gdb/linux-nat.c
gdb/solib-rocm.c
gdb/solib-svr4.c
gdb/x86-nat.c

index 0bb23944297ea6a7ce6ac0e519fec249f8189f41..e44f84c42f4d154407de4df9edb1e88e68b2665a 100644 (file)
@@ -66,7 +66,7 @@
 #define HA_MAX_NUM_FLDS                4
 
 /* All possible aarch64 target descriptors.  */
-static std::unordered_map <aarch64_features, target_desc *> tdesc_aarch64_map;
+static gdb::unordered_map <aarch64_features, target_desc *> tdesc_aarch64_map;
 
 /* The standard register names, and all the valid aliases for them.
    We're not adding fp here, that name is already taken, see
index a2cb7d8984acb3f7704d523a2724e936fe8dab7f..e0f64ee4b21e7099605cba7ecd48570e8739ceef 100644 (file)
@@ -356,7 +356,7 @@ using amd_dbgapi_register_type_enum_up
 
 /* Map type lookup names to types.  */
 using amd_dbgapi_register_type_map
-  = std::unordered_map<std::string, amd_dbgapi_register_type_up>;
+  = gdb::unordered_map<std::string, amd_dbgapi_register_type_up>;
 
 /* Parse S as a ULONGEST, raise an error on overflow.  */
 
index 67bcaaf243a59c21ccda5b97c44c5bcf77783e16..ac30023d74fc3c6b020eec948d582d0fb1376491 100644 (file)
@@ -23,9 +23,8 @@
 #include "gdbarch.h"
 
 #include <amd-dbgapi/amd-dbgapi.h>
-#include <unordered_map>
 
-/* Provide std::unordered_map::Hash for amd_dbgapi_register_id_t.  */
+/* Provide gdb::unordered_map::Hash for amd_dbgapi_register_id_t.  */
 struct register_id_hash
 {
   size_t
@@ -35,7 +34,7 @@ struct register_id_hash
   }
 };
 
-/* Provide std::unordered_map::Equal for amd_dbgapi_register_id_t.  */
+/* Provide gdb::unordered_map::Equal for amd_dbgapi_register_id_t.  */
 struct register_id_equal_to
 {
   bool
@@ -74,12 +73,12 @@ struct amdgpu_gdbarch_tdep : gdbarch_tdep_base
   std::vector<int> dwarf_regnum_to_gdb_regnum;
 
   /* A map of gdb regnums keyed by they equivalent register_id.  */
-  std::unordered_map<amd_dbgapi_register_id_t, int, register_id_hash,
+  gdb::unordered_map<amd_dbgapi_register_id_t, int, register_id_hash,
                     register_id_equal_to>
     regnum_map;
 
   /* A map of register_class_ids keyed by their name.  */
-  std::unordered_map<std::string, amd_dbgapi_register_class_id_t>
+  gdb::unordered_map<std::string, amd_dbgapi_register_class_id_t>
     register_class_map;
 };
 
index 879666274e0e5c30d58ec0e11a277522dbb1c115..4a7f2329f23deae9908e73c7c9b5fe2a31d87d42 100644 (file)
@@ -21,6 +21,7 @@
 #include "arch/amd64-linux-tdesc.h"
 #include "arch/amd64.h"
 #include "arch/x86-linux-tdesc-features.h"
+#include "gdbsupport/unordered_map.h"
 
 
 /* See arch/amd64-linux-tdesc.h.  */
@@ -29,7 +30,7 @@ const struct target_desc *
 amd64_linux_read_description (uint64_t xstate_bv, bool is_x32)
 {
   /* The type used for the amd64 and x32 target description caches.  */
-  using tdesc_cache_type = std::unordered_map<uint64_t, const target_desc_up>;
+  using tdesc_cache_type = gdb::unordered_map<uint64_t, target_desc_up>;
 
   /* Caches for the previously seen amd64 and x32 target descriptions,
      indexed by the xstate_bv value that created the target
index bd736eb68817c39a6afc8ecf5e3e2aafe575e9bf..74f192b9c37c08cac64a5d1231a694152be6452a 100644 (file)
@@ -21,6 +21,7 @@
 #include "arch/i386-linux-tdesc.h"
 #include "arch/i386.h"
 #include "arch/x86-linux-tdesc-features.h"
+#include "gdbsupport/unordered_map.h"
 
 /* See arch/i386-linux-tdesc.h.  */
 
@@ -31,7 +32,7 @@ i386_linux_read_description (uint64_t xstate_bv)
      xstate_bv value that created the target description.  This
      needs to be static within this function to ensure it is initialised
      before first use.  */
-  static std::unordered_map<uint64_t, const target_desc_up> i386_tdesc_cache;
+  static gdb::unordered_map<uint64_t, target_desc_up> i386_tdesc_cache;
 
   /* Only some bits are checked when creating a tdesc, but the
      XSTATE_BV value contains other feature bits that are not relevant
index e00b3337beaf3a3a10e8fc5ad1de282cfad6275e..72d880a7a8a0b9a159fa99c1beb49681d8e1e322 100644 (file)
@@ -62,7 +62,6 @@
 #include "user-regs.h"
 #include "expression.h"
 #include <algorithm>
-#include <unordered_set>
 #include "producer.h"
 #include "infcall.h"
 #include "maint.h"
@@ -4206,7 +4205,7 @@ static std::string
 i386_stap_adjust_register (struct gdbarch *gdbarch, struct stap_parse_info *p,
                           const std::string &regname, int regnum)
 {
-  static const std::unordered_set<std::string> reg_assoc
+  static const gdb::unordered_set<std::string> reg_assoc
     = { "ax", "bx", "cx", "dx",
        "si", "di", "bp", "sp" };
 
index 0c24e10c2c9ec49b14304ac447ee80004efb9ef0..322b44eae65a5a190a3850a9c851fc241f0b0917 100644 (file)
@@ -63,7 +63,6 @@
 #include "gdbsupport/scope-exit.h"
 #include "gdbsupport/gdb-sigmask.h"
 #include "gdbsupport/common-debug.h"
-#include <unordered_map>
 
 /* This comment documents high-level logic of this file.
 
@@ -4039,6 +4038,11 @@ public:
     gdb_assert (m_fd.get () != -1);
   }
 
+  DISABLE_COPY_AND_ASSIGN (proc_mem_file);
+
+  proc_mem_file (proc_mem_file &&) = default;
+  proc_mem_file & operator= (proc_mem_file &&) = default;
+
   ~proc_mem_file ()
   {
     linux_nat_debug_printf ("closing fd %d for /proc/%d/task/%ld/mem",
@@ -4067,7 +4071,7 @@ private:
    (also default), we don't create an inferior for the fork child, but
    we still need to remove breakpoints from the fork child's
    memory.  */
-static std::unordered_map<int, proc_mem_file> proc_mem_file_map;
+static gdb::unordered_map<int, proc_mem_file> proc_mem_file_map;
 
 /* Close the /proc/PID/mem file for PID.  */
 
index b48e4426fd4100e8f20ad439ed2800748686925b..af7eff22b71e2ea5c147eb230fe46db4256983ef 100644 (file)
@@ -32,8 +32,6 @@
 #include "solib-svr4.h"
 #include "symfile.h"
 
-#include <unordered_map>
-
 namespace {
 
 /* Per inferior cache of opened file descriptors.  */
@@ -60,15 +58,19 @@ struct rocm_solib_fd_cache
 private:
   struct refcnt_fd
   {
-    DISABLE_COPY_AND_ASSIGN (refcnt_fd);
     refcnt_fd (int fd, int refcnt) : fd (fd), refcnt (refcnt) {}
 
+    DISABLE_COPY_AND_ASSIGN (refcnt_fd);
+
+    refcnt_fd (refcnt_fd &&) = default;
+    refcnt_fd &operator=(refcnt_fd &&other) = default;
+
     int fd = -1;
     int refcnt = 0;
   };
 
   inferior *m_inferior;
-  std::unordered_map<std::string, refcnt_fd> m_cache;
+  gdb::unordered_map<std::string, refcnt_fd> m_cache;
 };
 
 int
@@ -101,7 +103,7 @@ rocm_solib_fd_cache::open (const std::string &filename,
 int
 rocm_solib_fd_cache::close (int fd, fileio_error *target_errno)
 {
-  using cache_val = std::unordered_map<std::string, refcnt_fd>::value_type;
+  using cache_val = gdb::unordered_map<std::string, refcnt_fd>::value_type;
   auto it
     = std::find_if (m_cache.begin (), m_cache.end (),
                    [fd](const cache_val &s) { return s.second.fd == fd; });
@@ -544,7 +546,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
     tokens.emplace_back (uri.substr (last));
 
   /* Create a tag-value map from the tokenized query/fragment.  */
-  std::unordered_map<std::string_view, std::string_view,
+  gdb::unordered_map<std::string_view, std::string_view,
                     gdb::string_view_hash> params;
   for (std::string_view token : tokens)
     {
index c91e0b2c37b46633feec1f36e0b6c0d6b7fc8d97..2d15e7dfd8a5dc5c46e9fa0d1b4ca13287bc6751 100644 (file)
@@ -3758,7 +3758,7 @@ svr4_solib_ops::get_solibs_in_ns (int nsid) const
      faster, and to be able to remove SOs from the map, to avoid
      returning the dynamic linker multiple times.  */
   CORE_ADDR debug_base = info->namespace_id[nsid];
-  std::unordered_map<std::string, const lm_info_svr4 *> namespace_solibs;
+  gdb::unordered_map<std::string, const lm_info_svr4 *> namespace_solibs;
   for (svr4_so &so : info->solib_lists[debug_base])
     namespace_solibs[so.name] = so.lm_info.get ();
 
index eb44dd58a4f4232bf3590af75415d3ced3faf26d..381364cdd70edeb1006aa4535e77a310f14b2909 100644 (file)
@@ -21,8 +21,6 @@
 #include "cli/cli-cmds.h"
 #include "inferior.h"
 
-#include <unordered_map>
-
 /* Support for hardware watchpoints and breakpoints using the x86
    debug registers.
 
@@ -42,7 +40,7 @@ struct x86_dr_low_type x86_dr_low;
    need to keep track of processes that aren't bound to any inferior
    (e.g., fork children, checkpoints).  */
 
-static std::unordered_map<pid_t,
+static gdb::unordered_map<pid_t,
                          struct x86_debug_reg_state> x86_debug_process_state;
 
 /* See x86-nat.h.  */