From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id gpDCBY9RFmkEID8AWB0awg (envelope-from ) for ; Thu, 13 Nov 2025 16:45:51 -0500 Received: by simark.ca (Postfix, from userid 112) id EE5871E04C; Thu, 13 Nov 2025 16:45:50 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C433F1E04C for ; Thu, 13 Nov 2025 16:45:49 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5FF7E385840D for ; Thu, 13 Nov 2025 21:45:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5FF7E385840D Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 7DFFE3858D21 for ; Thu, 13 Nov 2025 21:45:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7DFFE3858D21 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7DFFE3858D21 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1763070308; cv=none; b=b4QGpvU6pkpsFa9k3aFIXSeWt6i8PVsOBRvw8UqzFOB1b3VS/TkINSDOg96YjzPQB+1AJCLTfWHh/0T3bp6B5h/TgKgyx3bnhS466aSg44OX3WqoqUR83BV7eqeG7qNWGp0w9uz82l0CwM/aglL0r+3ATvA3h3eJKKH7NiZkiCE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1763070308; c=relaxed/simple; bh=UAUhSuKfRIGVINvJXOClyjCfACjpIqq8GvouM0ts+yU=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=x2EhSsACv6PxIz+72Lg+ExZMqOOLrxyLB0/m+Rs34MuTOIJS9yydedkoiFJjwZynxfwF43VBxHuoymcOc0yala7gd19qNYX6J4hEs9dm1d7EOXcW5r3rQQrnSnV9ZvAWDY0cLr+e0dzLpQttK/GLBbMfjESwef4nxQCgpuynItw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7DFFE3858D21 Received: by simark.ca (Postfix) id 121EA1E04C; Thu, 13 Nov 2025 16:45:08 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH v2] gdb: use gdb::unordered_{set,map} at a few places Date: Thu, 13 Nov 2025 16:43:56 -0500 Message-ID: <20251113214507.359286-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251113213506.313040-1-simon.marchi@efficios.com> References: <20251113213506.313040-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org New in v2: - I forgot to actually build-test with all targets enabled, so I was missing a change in solib-rocm.c. 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 --- gdb/aarch64-tdep.c | 2 +- gdb/amdgpu-tdep.c | 2 +- gdb/amdgpu-tdep.h | 9 ++++----- gdb/arch/amd64-linux-tdesc.c | 3 ++- gdb/arch/i386-linux-tdesc.c | 3 ++- gdb/i386-tdep.c | 3 +-- gdb/linux-nat.c | 6 ++++-- gdb/solib-rocm.c | 12 ++++++------ gdb/solib-svr4.c | 2 +- gdb/x86-nat.c | 4 +--- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 89142e0a2149..b1cc17499bfb 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -66,7 +66,7 @@ #define HA_MAX_NUM_FLDS 4 /* All possible aarch64 target descriptors. */ -static std::unordered_map tdesc_aarch64_map; +static gdb::unordered_map 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 diff --git a/gdb/amdgpu-tdep.c b/gdb/amdgpu-tdep.c index a2cb7d8984ac..e0f64ee4b21e 100644 --- a/gdb/amdgpu-tdep.c +++ b/gdb/amdgpu-tdep.c @@ -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; + = gdb::unordered_map; /* Parse S as a ULONGEST, raise an error on overflow. */ diff --git a/gdb/amdgpu-tdep.h b/gdb/amdgpu-tdep.h index 67bcaaf243a5..ac30023d74fc 100644 --- a/gdb/amdgpu-tdep.h +++ b/gdb/amdgpu-tdep.h @@ -23,9 +23,8 @@ #include "gdbarch.h" #include -#include -/* 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 dwarf_regnum_to_gdb_regnum; /* A map of gdb regnums keyed by they equivalent register_id. */ - std::unordered_map regnum_map; /* A map of register_class_ids keyed by their name. */ - std::unordered_map + gdb::unordered_map register_class_map; }; diff --git a/gdb/arch/amd64-linux-tdesc.c b/gdb/arch/amd64-linux-tdesc.c index 879666274e0e..4a7f2329f23d 100644 --- a/gdb/arch/amd64-linux-tdesc.c +++ b/gdb/arch/amd64-linux-tdesc.c @@ -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; + using tdesc_cache_type = gdb::unordered_map; /* Caches for the previously seen amd64 and x32 target descriptions, indexed by the xstate_bv value that created the target diff --git a/gdb/arch/i386-linux-tdesc.c b/gdb/arch/i386-linux-tdesc.c index bd736eb68817..74f192b9c37c 100644 --- a/gdb/arch/i386-linux-tdesc.c +++ b/gdb/arch/i386-linux-tdesc.c @@ -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 i386_tdesc_cache; + static gdb::unordered_map 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 diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index e00b3337beaf..72d880a7a8a0 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -62,7 +62,6 @@ #include "user-regs.h" #include "expression.h" #include -#include #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 ®name, int regnum) { - static const std::unordered_set reg_assoc + static const gdb::unordered_set reg_assoc = { "ax", "bx", "cx", "dx", "si", "di", "bp", "sp" }; diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 0c24e10c2c9e..cb33c0a9b844 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -63,7 +63,6 @@ #include "gdbsupport/scope-exit.h" #include "gdbsupport/gdb-sigmask.h" #include "gdbsupport/common-debug.h" -#include /* This comment documents high-level logic of this file. @@ -4039,6 +4038,9 @@ class proc_mem_file gdb_assert (m_fd.get () != -1); } + 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 +4069,7 @@ class proc_mem_file (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 proc_mem_file_map; +static gdb::unordered_map proc_mem_file_map; /* Close the /proc/PID/mem file for PID. */ diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c index b48e4426fd41..b328cc7b5d06 100644 --- a/gdb/solib-rocm.c +++ b/gdb/solib-rocm.c @@ -32,8 +32,6 @@ #include "solib-svr4.h" #include "symfile.h" -#include - namespace { /* Per inferior cache of opened file descriptors. */ @@ -60,15 +58,17 @@ 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) {} + refcnt_fd (refcnt_fd &&) = default; + refcnt_fd &operator=(refcnt_fd &&other) = default; + int fd = -1; int refcnt = 0; }; inferior *m_inferior; - std::unordered_map m_cache; + gdb::unordered_map m_cache; }; int @@ -101,7 +101,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::value_type; + using cache_val = gdb::unordered_map::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 +544,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 params; for (std::string_view token : tokens) { diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index c91e0b2c37b4..2d15e7dfd8a5 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -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 namespace_solibs; + gdb::unordered_map namespace_solibs; for (svr4_so &so : info->solib_lists[debug_base]) namespace_solibs[so.name] = so.lm_info.get (); diff --git a/gdb/x86-nat.c b/gdb/x86-nat.c index eb44dd58a4f4..381364cdd70e 100644 --- a/gdb/x86-nat.c +++ b/gdb/x86-nat.c @@ -21,8 +21,6 @@ #include "cli/cli-cmds.h" #include "inferior.h" -#include - /* 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 x86_debug_process_state; /* See x86-nat.h. */ base-commit: fd3b1c4f4c111444dfe6ff9c3f00a5469e7cd8a6 -- 2.51.2