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@efficios.com>
Subject: [PATCH v3 3/6] gdb/solib: add solib -> solib_ops backlink
Date: Mon, 16 Jun 2025 15:33:01 -0400	[thread overview]
Message-ID: <20250616193443.16703-3-simon.marchi@efficios.com> (raw)
In-Reply-To: <20250616193443.16703-1-simon.marchi@efficios.com>

The subsequent C++ification commit makes it so that one struct solib_ops
is instantiated for each program space.  For some operations, it will
then become necessary to be able to get the right solib_ops instance
from a given solib.  Add an solib -> solib_ops backlink for that.

Change-Id: Ib95407b3fa5fcfba55cf874e0e9dcd2d43a402e4
---
 gdb/solib-aix.c    |  2 +-
 gdb/solib-darwin.c |  2 +-
 gdb/solib-dsbt.c   |  2 +-
 gdb/solib-frv.c    |  2 +-
 gdb/solib-rocm.c   |  2 +-
 gdb/solib-svr4.c   |  4 ++--
 gdb/solib-target.c |  2 +-
 gdb/solib.h        | 15 +++++++++++++++
 8 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c
index 4af83de4d371..17eeba940770 100644
--- a/gdb/solib-aix.c
+++ b/gdb/solib-aix.c
@@ -480,7 +480,7 @@ solib_aix_current_sos ()
 	}
 
       /* Add it to the list.  */
-      auto &new_solib = sos.emplace_back ();
+      auto &new_solib = sos.emplace_back (solib_aix_so_ops);
       new_solib.original_name = so_name;
       new_solib.name = so_name;
       new_solib.lm_info = std::make_unique<lm_info_aix> (info);
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index 4003c77748ca..88a2962f5dd5 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -250,7 +250,7 @@ darwin_current_sos ()
 	break;
 
       /* Create and fill the new struct solib element.  */
-      auto &newobj = sos.emplace_back ();
+      auto &newobj = sos.emplace_back (darwin_so_ops);
 
       auto li = std::make_unique<lm_info_darwin> ();
 
diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c
index 2b3153692805..f6748b69353a 100644
--- a/gdb/solib-dsbt.c
+++ b/gdb/solib-dsbt.c
@@ -584,7 +584,7 @@ dsbt_current_sos (void)
 	      break;
 	    }
 
-	  auto &sop = sos.emplace_back ();
+	  auto &sop = sos.emplace_back (dsbt_so_ops);
 	  auto li = std::make_unique<lm_info_dsbt> ();
 	  li->map = loadmap;
 	  /* Fetch the name.  */
diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c
index ceef72208a1b..12d3140b513c 100644
--- a/gdb/solib-frv.c
+++ b/gdb/solib-frv.c
@@ -367,7 +367,7 @@ frv_current_sos ()
 	      break;
 	    }
 
-	  auto &sop = sos.emplace_back ();
+	  auto &sop = sos.emplace_back (frv_so_ops);
 	  auto li = std::make_unique<lm_info_frv> ();
 	  li->map = loadmap;
 	  li->got_value = got_addr;
diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c
index b27613bbf91a..a3599562e795 100644
--- a/gdb/solib-rocm.c
+++ b/gdb/solib-rocm.c
@@ -210,7 +210,7 @@ solibs_from_rocm_sos (const std::vector<rocm_so> &sos)
 
   for (const rocm_so &so : sos)
     {
-      auto &newobj = dst.emplace_back ();
+      auto &newobj = dst.emplace_back (rocm_solib_ops);
 
       newobj.lm_info = std::make_unique<lm_info_svr4> (*so.lm_info);
       newobj.name = so.name;
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 48aace1feb48..deefc2578599 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -1050,7 +1050,7 @@ solib_from_svr4_sos (const std::vector<svr4_so> &sos)
 
   for (const svr4_so &so : sos)
     {
-      auto &newobj = dst.emplace_back ();
+      auto &newobj = dst.emplace_back (svr4_so_ops);
 
       newobj.name = so.name;
       newobj.original_name = so.name;
@@ -1250,7 +1250,7 @@ svr4_default_sos (svr4_info *info)
   li->l_addr_p = 1;
 
   owning_intrusive_list<solib> sos;
-  auto &newobj = sos.emplace_back ();
+  auto &newobj = sos.emplace_back (svr4_so_ops);
 
   newobj.lm_info = std::move (li);
   newobj.name = info->debug_loader_name;
diff --git a/gdb/solib-target.c b/gdb/solib-target.c
index 68dc3cc92c0a..61b841928ff8 100644
--- a/gdb/solib-target.c
+++ b/gdb/solib-target.c
@@ -245,7 +245,7 @@ solib_target_current_sos (void)
   /* Build a struct solib for each entry on the list.  */
   for (lm_info_target_up &info : library_list)
     {
-      auto &new_solib = sos.emplace_back ();
+      auto &new_solib = sos.emplace_back (solib_target_so_ops);
 
       /* We don't need a copy of the name in INFO anymore.  */
       new_solib.name = std::move (info->name);
diff --git a/gdb/solib.h b/gdb/solib.h
index f5922aa5f5d6..09d56c08b953 100644
--- a/gdb/solib.h
+++ b/gdb/solib.h
@@ -54,8 +54,19 @@ struct lm_info
 
 using lm_info_up = std::unique_ptr<lm_info>;
 
+struct solib_ops;
+
 struct solib : intrusive_list_node<solib>
 {
+  /* Constructor
+
+     OPS is the solib_ops implementation providing this solib.  */
+  explicit solib (const solib_ops &ops) : m_ops (&ops) {}
+
+  /* Return the solib_ops implementation providing this solib.  */
+  const solib_ops &ops () const
+  { return *m_ops; }
+
   /* Free symbol-file related contents of SO and reset for possible reloading
      of SO.  If we have opened a BFD for SO, close it.  If we have placed SO's
      sections in some target's section table, the caller is responsible for
@@ -111,6 +122,10 @@ struct solib : intrusive_list_node<solib>
      that supports outputting multiple segments once the related code
      supports them.  */
   CORE_ADDR addr_low = 0, addr_high = 0;
+
+private:
+  /* The solib_ops responsible for this solib.  */
+  const solib_ops *m_ops;
 };
 
 /* A unique pointer to an solib.  */
-- 
2.49.0


  parent reply	other threads:[~2025-06-16 19:35 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-16 19:32 [PATCH v3 1/6] gdb/testsuite: check that "info shared" and "info linker-namespaces" before running don't crash Simon Marchi
2025-06-16 19:33 ` [PATCH v3 2/6] gdb/solib: fix formatting of "info linker-namespaces" error message Simon Marchi
2025-06-20 18:12   ` Pedro Alves
2025-06-26 17:35     ` Simon Marchi
2025-06-16 19:33 ` Simon Marchi [this message]
2025-06-20 18:17   ` [PATCH v3 3/6] gdb/solib: add solib -> solib_ops backlink Pedro Alves
2025-06-16 19:33 ` [PATCH v3 4/6] gdb/solib: use solib::ops for operations that concern a single solib Simon Marchi
2025-06-20 18:17   ` Pedro Alves
2025-06-16 19:33 ` [PATCH v3 5/6] gdb/progspace: add solib_ops pointer in program_space Simon Marchi
2025-06-17 19:45   ` Guinevere Larsen
2025-06-17 20:33     ` Simon Marchi
2025-06-18 11:51       ` Guinevere Larsen
2025-06-18 14:43         ` Simon Marchi
2025-06-18 15:01           ` Guinevere Larsen
2025-06-20 18:19   ` Pedro Alves
2025-06-26 17:37     ` Simon Marchi
2025-09-02 14:49   ` Tom de Vries
2025-09-02 16:05     ` Simon Marchi
2025-09-02 16:34       ` Tom de Vries
2025-06-16 19:33 ` [PATCH v3 6/6] gdb/solib: C++ify solib_ops Simon Marchi
2025-06-20 18:20   ` Pedro Alves
2025-06-26 18:04     ` Simon Marchi
2025-06-27 22:04       ` Tom de Vries
2025-06-27 22:46         ` Thiago Jung Bauermann
2025-06-28  5:25           ` Simon Marchi
2025-06-28  6:27             ` Tom de Vries
2025-06-20 18:12 ` [PATCH v3 1/6] gdb/testsuite: check that "info shared" and "info linker-namespaces" before running don't crash Pedro Alves
2025-06-26 17:30   ` 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=20250616193443.16703-3-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    /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