Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: simon.marchi@polymtl.ca
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>, Lancelot SIX <Lancelot.Six@amd.com>,
	Simon Marchi <simon.marchi@efficios.com>,
	Lancelot Six <lancelot.six@amd.com>
Subject: [PATCH v3 02/10] gdb/solib-rocm: pass reference to cache to rocm_code_object_stream_file
Date: Wed,  8 Jul 2026 17:51:34 -0400	[thread overview]
Message-ID: <20260708215145.93134-3-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20260708215145.93134-1-simon.marchi@polymtl.ca>

From: Simon Marchi <simon.marchi@efficios.com>

~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
Approved-by: Lancelot Six <lancelot.six@amd.com>
---
 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 48040111b196..97eb93865610 100644
--- a/gdb/solib-rocm.c
+++ b/gdb/solib-rocm.c
@@ -356,8 +356,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, target_fd fd, ULONGEST offset,
-				ULONGEST size);
+  rocm_code_object_stream_file (rocm_solib_fd_cache &fd_cache, target_fd fd,
+				ULONGEST offset, ULONGEST size);
 
   file_ptr read (bfd *abfd, void *buf, file_ptr size,
 		 file_ptr offset) override;
@@ -367,9 +367,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.  */
   target_fd m_fd;
@@ -383,8 +382,9 @@ struct rocm_code_object_stream_file final : rocm_code_object_stream
 };
 
 rocm_code_object_stream_file::rocm_code_object_stream_file
-  (inferior *inf, target_fd fd, ULONGEST offset, ULONGEST size)
-  : m_inf (inf), m_fd (fd), m_offset (offset), m_size (size)
+  (rocm_solib_fd_cache &fd_cache, target_fd fd, ULONGEST offset,
+   ULONGEST size)
+  : m_fd_cache (fd_cache), m_fd (fd), m_offset (offset), m_size (size)
 {
 }
 
@@ -449,9 +449,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)));
 }
@@ -620,7 +619,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.55.0


  parent reply	other threads:[~2026-07-08 21:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08 21:51 [PATCH v3 00/10] Multiple solib_ops in a program_space simon.marchi
2026-07-08 21:51 ` [PATCH v3 01/10] gdb/solib-rocm: assert that host ops isn't rocm_solib_ops simon.marchi
2026-07-08 21:51 ` simon.marchi [this message]
2026-07-08 21:51 ` [PATCH v3 03/10] gdb/solib-rocm: add cached_target_fd to manage cached fd lifetime simon.marchi
2026-07-08 21:51 ` [PATCH v3 04/10] gdb: de-constify some methods of solib_ops simon.marchi
2026-07-08 21:51 ` [PATCH v3 05/10] gdb/solib: add remove_solib function simon.marchi
2026-07-08 21:51 ` [PATCH v3 06/10] gdb/solib-rocm: move per-inferior data to rocm_solib_ops simon.marchi
2026-07-08 21:51 ` [PATCH v3 07/10] gdb/solib-rocm: save inferior in rocm_solib_ops simon.marchi
2026-07-08 21:51 ` [PATCH v3 08/10] gdb: add objfile -> solib backlink simon.marchi
2026-07-21 17:31   ` Tom Tromey
2026-07-08 21:51 ` [PATCH v3 09/10] gdb: change default objfile iteration order to start with current objfile simon.marchi
2026-07-08 21:51 ` [PATCH v3 10/10] gdb: multiple solib_ops per program space simon.marchi

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=20260708215145.93134-3-simon.marchi@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=Lancelot.Six@amd.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    --cc=tom@tromey.com \
    /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