Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH 07/11] gdb/solib-rocm: save inferior in rocm_solib_ops
Date: Tue,  9 Dec 2025 14:32:11 -0500	[thread overview]
Message-ID: <20251209193610.296085-8-simon.marchi@efficios.com> (raw)
In-Reply-To: <20251209193610.296085-1-simon.marchi@efficios.com>

From: Simon Marchi <simon.marchi@polymtl.ca>

Saving the inferior the rocm_solib_ops is for can avoid using
`current_inferior ()` at a couple of places.

Change-Id: Icf36bbef031eda7b776cd735a91a2ff918697dd3
---
 gdb/solib-rocm.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c
index 81a1c0ab64c1..a1bbb1a54f42 100644
--- a/gdb/solib-rocm.c
+++ b/gdb/solib-rocm.c
@@ -186,7 +186,7 @@ struct rocm_solib_ops : public solib_ops
      in order to provide support for ROCm code objects.  */
   explicit rocm_solib_ops (inferior *inf, solib_ops_up host_ops)
     : solib_ops (inf->pspace), m_host_ops (std::move (host_ops)),
-      m_fd_cache (inf)
+      m_inf (inf), m_fd_cache (inf)
   {
     gdb_assert (m_host_ops != nullptr);
     gdb_assert (dynamic_cast<rocm_solib_ops *> (m_host_ops.get ()) == nullptr);
@@ -257,10 +257,13 @@ struct rocm_solib_ops : public solib_ops
 private:
   owning_intrusive_list<solib>
   solibs_from_rocm_sos (const std::vector<rocm_so> &sos);
-  gdb_bfd_iovec_base *bfd_iovec_open (bfd *abfd, inferior *inferior);
+  gdb_bfd_iovec_base *bfd_iovec_open (bfd *abfd);
 
   solib_ops_up m_host_ops;
 
+  /* Inferior this rocm_solib_ops is for.  */
+  inferior *m_inf;
+
   /* List of code objects loaded into the inferior.  */
   std::vector<rocm_so> m_solib_list;
 
@@ -507,7 +510,7 @@ rocm_code_object_stream_memory::read (bfd *, void *buf, file_ptr size,
 } /* anonymous namespace */
 
 gdb_bfd_iovec_base *
-rocm_solib_ops::bfd_iovec_open (bfd *abfd, inferior *inferior)
+rocm_solib_ops::bfd_iovec_open (bfd *abfd)
 {
   std::string_view uri (bfd_get_filename (abfd));
   std::string_view protocol_delim = "://";
@@ -617,7 +620,7 @@ rocm_solib_ops::bfd_iovec_open (bfd *abfd, inferior *inferior)
       if (protocol == "memory")
 	{
 	  ULONGEST pid = try_strtoulst (path);
-	  if (pid != inferior->pid)
+	  if (pid != m_inf->pid)
 	    {
 	      warning (_("`%s': code object is from another inferior"),
 		       std::string (uri).c_str ());
@@ -663,7 +666,7 @@ rocm_solib_ops::bfd_open (const char *pathname)
 
   auto open = [this] (bfd *nbfd)
   {
-    return this->bfd_iovec_open (nbfd, current_inferior ());
+    return this->bfd_iovec_open (nbfd);
   };
 
   gdb_bfd_ref_ptr abfd = gdb_bfd_openr_iovec (pathname, "elf64-amdgcn", open);
@@ -752,9 +755,7 @@ rocm_solib_ops::create_inferior_hook (int from_tty)
 void
 rocm_solib_ops::update_solib_list ()
 {
-  inferior *inf = current_inferior ();
-
-  amd_dbgapi_process_id_t process_id = get_amd_dbgapi_process_id (inf);
+  amd_dbgapi_process_id_t process_id = get_amd_dbgapi_process_id (m_inf);
   if (process_id.handle == AMD_DBGAPI_PROCESS_NONE.handle)
     return;
 
-- 
2.52.0


  parent reply	other threads:[~2025-12-09 19:37 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   ` [PATCH 3/11] " Lancelot SIX
2026-05-08  1:48     ` 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 ` Simon Marchi [this message]
     [not found]   ` <87a4unm59w.fsf@tromey.com>
2026-05-08  2:10     ` [PATCH 07/11] gdb/solib-rocm: save inferior in rocm_solib_ops 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=20251209193610.296085-8-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /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