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 4/6] gdb/solib: use solib::ops for operations that concern a single solib
Date: Mon, 16 Jun 2025 15:33:02 -0400	[thread overview]
Message-ID: <20250616193443.16703-4-simon.marchi@efficios.com> (raw)
In-Reply-To: <20250616193443.16703-1-simon.marchi@efficios.com>

For operations that concern a single solib, use the solib_ops backlink
added in the previous patch (solib::ops), instead of using the solib_ops
from the gdbarch.  This is a small / easy step towards not using
gdbarch_so_ops, which is necessary for the C++ification patch later in
this series.

There is no change in behavior expected.

Change-Id: If80e9ea717a2788bada1cf0940cda3c73933bcff
---
 gdb/solib.c | 36 +++++++++++++++---------------------
 1 file changed, 15 insertions(+), 21 deletions(-)

diff --git a/gdb/solib.c b/gdb/solib.c
index 90e7b906222c..d008a72c5a38 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -482,10 +482,8 @@ solib_bfd_open (const char *pathname)
 static int
 solib_map_sections (solib &so)
 {
-  const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
-
   gdb::unique_xmalloc_ptr<char> filename (tilde_expand (so.name.c_str ()));
-  gdb_bfd_ref_ptr abfd (ops->bfd_open (filename.get ()));
+  gdb_bfd_ref_ptr abfd (so.ops ().bfd_open (filename.get ()));
 
   /* If we have a core target then the core target might have some helpful
      information (i.e. build-ids) about the shared libraries we are trying
@@ -495,7 +493,7 @@ solib_map_sections (solib &so)
      If we don't have a core target then this will return an empty struct
      with no hint information, we then lookup the shared library based on
      its filename.  */
-  std::optional<CORE_ADDR> solib_addr = ops->find_solib_addr (so);
+  std::optional<CORE_ADDR> solib_addr = so.ops ().find_solib_addr (so);
   std::optional <const core_target_mapped_file_info> mapped_file_info
     = core_target_find_mapped_file (so.name.c_str (), solib_addr);
 
@@ -519,7 +517,7 @@ solib_map_sections (solib &so)
 	     However, if it was good enough during the mapped file
 	     processing, we assume it's good enough now.  */
 	  if (!mapped_file_info->filename ().empty ())
-	    abfd = ops->bfd_open (mapped_file_info->filename ().c_str ());
+	    abfd = so.ops ().bfd_open (mapped_file_info->filename ().c_str ());
 	  else
 	    abfd = nullptr;
 
@@ -559,7 +557,7 @@ solib_map_sections (solib &so)
       /* Relocate the section binding addresses as recorded in the shared
 	 object's file by the base address to which the object was actually
 	 mapped.  */
-      ops->relocate_section_addresses (so, &p);
+      so.ops ().relocate_section_addresses (so, &p);
 
       /* If the target didn't provide information about the address
 	 range of the shared object, assume we want the location of
@@ -586,8 +584,6 @@ solib_map_sections (solib &so)
 void
 solib::clear ()
 {
-  const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
-
   this->sections.clear ();
   this->abfd = nullptr;
 
@@ -602,8 +598,8 @@ solib::clear ()
   this->name = this->original_name;
 
   /* Do the same for target-specific data.  */
-  if (ops->clear_so != NULL)
-    ops->clear_so (*this);
+  if (this->ops ().clear_so != NULL)
+    this->ops ().clear_so (*this);
 }
 
 lm_info::~lm_info () = default;
@@ -1827,19 +1823,17 @@ static value *
 linker_namespace_make_value (gdbarch *gdbarch, internalvar *var,
 				     void *ignore)
 {
-  const solib_ops *ops = gdbarch_so_ops (gdbarch);
   int nsid = 0;
-  if (ops->find_solib_ns != nullptr)
-    {
-      CORE_ADDR curr_pc = get_frame_pc (get_selected_frame ());
-      for (const solib &so : current_program_space->solibs ())
-	if (solib_contains_address_p (so, curr_pc))
-	  {
-	    nsid = ops->find_solib_ns (so);
-	    break;
-	  }
-    }
+  CORE_ADDR curr_pc = get_frame_pc (get_selected_frame ());
 
+  for (const solib &so : current_program_space->solibs ())
+    if (solib_contains_address_p (so, curr_pc))
+      {
+	if (so.ops ().find_solib_ns != nullptr)
+	  nsid = so.ops ().find_solib_ns (so);
+
+	break;
+      }
 
   /* If the PC is not in an SO, or the solib_ops doesn't support
      linker namespaces, the inferior is in the default namespace.  */
-- 
2.49.0


  parent reply	other threads:[~2025-06-16 19:36 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 ` [PATCH v3 3/6] gdb/solib: add solib -> solib_ops backlink Simon Marchi
2025-06-20 18:17   ` Pedro Alves
2025-06-16 19:33 ` Simon Marchi [this message]
2025-06-20 18:17   ` [PATCH v3 4/6] gdb/solib: use solib::ops for operations that concern a single solib 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-4-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