Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Lancelot SIX <lancelot.six@amd.com>
To: Simon Marchi <simon.marchi@efficios.com>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [PATCH 3/11] gdb/solib-rocm: pass reference to cache to rocm_code_object_stream_file
Date: Thu, 7 May 2026 19:20:58 +0100	[thread overview]
Message-ID: <lbfezu722whbhyhjq4iellabz2klj6pafp7vrjj4ssmo3tkbba@becfvzrnw2y4> (raw)
In-Reply-To: <20251209193610.296085-4-simon.marchi@efficios.com>

On Tue, Dec 09, 2025 at 02:32:07PM -0500, Simon Marchi wrote:
> ~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);

Just noting that this does not apply anymore, just need to change
"int fd" to "target_fd fd".

Other than that, this looks good to me.

Thanks.

Approved-by: Lancelot Six <lancelot.six@amd.com> (amdgpu)

>  
>    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

  reply	other threads:[~2026-05-07 18:21 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-09 19:32 [PATCH 00/11] Multiple solib_ops in a program_space Simon Marchi
2025-12-09 19:32 ` [PATCH 01/11] gdb/solib-rocm: assert that host ops isn't rocm_solib_ops Simon Marchi
2026-05-07 17:56   ` [PATCH 1/11] " Lancelot SIX
2026-05-08  1:37     ` Simon Marchi
2026-05-08 10:36       ` Lancelot SIX
2026-06-08 18:36         ` Simon Marchi
2025-12-09 19:32 ` [PATCH 02/11] gdb/solib: use early return in solib_read_symbols Simon Marchi
2026-04-28 16:16   ` Tom Tromey
2026-05-08  1:44     ` Simon Marchi
2025-12-09 19:32 ` [PATCH 03/11] gdb/solib-rocm: pass reference to cache to rocm_code_object_stream_file Simon Marchi
2026-05-07 18:20   ` Lancelot SIX [this message]
2026-05-08  1:48     ` [PATCH 3/11] " Simon Marchi
2025-12-09 19:32 ` [PATCH 04/11] gdb/solib-rocm: add cached_fd to manage cached fd lifetime Simon Marchi
2026-05-07 20:17   ` [PATCH 4/11] " Lancelot SIX
2026-05-08  1:52     ` Simon Marchi
2025-12-09 19:32 ` [PATCH 05/11] gdb: de-constify some methods of solib_ops Simon Marchi
2025-12-09 19:32 ` [PATCH 06/11] gdb/solib-rocm: move per-inferior data to rocm_solib_ops Simon Marchi
2026-04-28 16:19   ` Tom Tromey
2026-05-08  2:02     ` Simon Marchi
2025-12-09 19:32 ` [PATCH 07/11] gdb/solib-rocm: save inferior in rocm_solib_ops Simon Marchi
     [not found]   ` <87a4unm59w.fsf@tromey.com>
2026-05-08  2:10     ` Simon Marchi
2025-12-09 19:32 ` [PATCH 08/11] gdb/solib: add remove_solib function Simon Marchi
2026-04-28 16:23   ` Tom Tromey
2025-12-09 19:32 ` [PATCH 09/11] gdb: add objfile -> solib backlink Simon Marchi
2026-04-28 16:28   ` Tom Tromey
2026-05-08  2:25     ` Simon Marchi
2025-12-09 19:32 ` [PATCH 10/11] gdb: change default objfile iteration order to start with current objfile Simon Marchi
2026-04-28 16:42   ` Tom Tromey
2026-05-08  2:40     ` Simon Marchi
2025-12-09 19:32 ` [PATCH 11/11] gdb: multiple solib_ops per program space Simon Marchi
2026-04-28 17:27   ` Tom Tromey
2026-05-08  2:52     ` Simon Marchi
2026-04-28 16:00 ` [PATCH 00/11] Multiple solib_ops in a program_space Simon Marchi
2026-04-28 17:28   ` Tom Tromey
2026-05-08  2:40     ` 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=lbfezu722whbhyhjq4iellabz2klj6pafp7vrjj4ssmo3tkbba@becfvzrnw2y4 \
    --to=lancelot.six@amd.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.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