From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 6TeXFk56OGkyTikAWB0awg (envelope-from ) for ; Tue, 09 Dec 2025 14:36:46 -0500 Received: by simark.ca (Postfix, from userid 112) id 290D21E0BC; Tue, 09 Dec 2025 14:36:46 -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 vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (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 A0B601E0B3 for ; Tue, 09 Dec 2025 14:36:44 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id D46A84BA23DC for ; Tue, 9 Dec 2025 19:36:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D46A84BA23DC Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id D3FD94BA2E02 for ; Tue, 9 Dec 2025 19:36:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D3FD94BA2E02 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 D3FD94BA2E02 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=1765308975; cv=none; b=eEguA3gIe5v/PvGoxNPfQcqnd+jnGpLwsMScc2UAnG03vPsPHVEcegt7XtTtdOJtL7/sSlb3IVGfpeEQZQQYa15PuMF3d1XKXmzViiQHeIwC0yir8R66Ts0OKnaeLnZNSR7JwospM/b2Ym5qtqMw9cxjmwKZSFcjoMK9g3b3FrI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765308975; c=relaxed/simple; bh=i1VMLxzFh32tUtqWYBhTIBwrjQcCzFJ3JcLF9Ta+ATI=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=I4VYwoR3+2p0aQpmnqUrFx5MTrtCZgXFBuPLblN1VQ33a0WVdT40WBplc/mJquFhvNBwh277/pvm33dXzru6yGT5TJ06peYBDkh+UNX3CtmErW0Dkf0ge6TAYHUeQb2jUSLt60+303UUC9/9oq0B+N/UJakklSZBSmxAzLbSka8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D3FD94BA2E02 Received: by simark.ca (Postfix) id 493931E0BC; Tue, 09 Dec 2025 14:36:15 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 03/11] gdb/solib-rocm: pass reference to cache to rocm_code_object_stream_file Date: Tue, 9 Dec 2025 14:32:07 -0500 Message-ID: <20251209193610.296085-4-simon.marchi@efficios.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251209193610.296085-1-simon.marchi@efficios.com> References: <20251209193610.296085-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 ~rocm_code_object_stream_file obtains the fd cache to call "close" on using its m_inf field, obtaining the per-inferior info using get_solib_info. A patch later in this series moves the fd cache from the per-inferior registry to the rocm_solib_ops directly. This implies that we will need a new way to get a reference to the fd_cache owning the fd, as it won't be easy to get it from the inferior anymore. To achieve this, update rocm_code_object_stream_file to keep a reference to the fd cache directly (because the rocm_code_object_stream is not meant to be copied nor moved, make the field a reference). The inferior parameter and field are not needed anymore. Change-Id: Ia10f8f125840274e51e188cafcb7384fdff92240 --- gdb/solib-rocm.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c index a9573f8eefde..bde34bafd8b1 100644 --- a/gdb/solib-rocm.c +++ b/gdb/solib-rocm.c @@ -360,8 +360,8 @@ struct rocm_code_object_stream_file final : rocm_code_object_stream { DISABLE_COPY_AND_ASSIGN (rocm_code_object_stream_file); - rocm_code_object_stream_file (inferior *inf, int fd, ULONGEST offset, - ULONGEST size); + rocm_code_object_stream_file (rocm_solib_fd_cache &fd_cache, int fd, + ULONGEST offset, ULONGEST size); file_ptr read (bfd *abfd, void *buf, file_ptr size, file_ptr offset) override; @@ -371,9 +371,8 @@ struct rocm_code_object_stream_file final : rocm_code_object_stream ~rocm_code_object_stream_file () override; protected: - - /* The inferior owning this code object stream. */ - inferior *m_inf; + /* The fd cache owning this code object stream. */ + rocm_solib_fd_cache &m_fd_cache; /* The target file descriptor for this stream. */ int m_fd; @@ -387,8 +386,9 @@ struct rocm_code_object_stream_file final : rocm_code_object_stream }; rocm_code_object_stream_file::rocm_code_object_stream_file - (inferior *inf, int fd, ULONGEST offset, ULONGEST size) - : m_inf (inf), m_fd (fd), m_offset (offset), m_size (size) + (rocm_solib_fd_cache &fd_cache, int fd, ULONGEST offset, + ULONGEST size) + : m_fd_cache (fd_cache), m_fd (fd), m_offset (offset), m_size (size) { } @@ -453,9 +453,8 @@ rocm_code_object_stream_file::size () rocm_code_object_stream_file::~rocm_code_object_stream_file () { - auto info = get_solib_info (m_inf); fileio_error target_errno; - if (info->fd_cache.close (m_fd, &target_errno) != 0) + if (m_fd_cache.close (m_fd, &target_errno) != 0) warning (_("Failed to close solib: %s"), strerror (fileio_error_to_host (target_errno))); } @@ -608,7 +607,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior) return nullptr; } - return new rocm_code_object_stream_file (inferior, fd, offset, + return new rocm_code_object_stream_file (info->fd_cache, fd, offset, size); } -- 2.52.0