public inbox for gdb-patches@sourceware.org
 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 4/5] gdb: add program_space parameter to clear_solib
Date: Tue,  6 Feb 2024 12:14:26 -0500	[thread overview]
Message-ID: <20240206171514.119244-5-simon.marchi@efficios.com> (raw)
In-Reply-To: <20240206171514.119244-1-simon.marchi@efficios.com>

Make the current_program_space reference bubble up one level.

Remove one unnecessary declaration of clear_solib.

Change-Id: I234e2c8c0b71713364fc7b76cee2bee2b026bd6d
---
 gdb/corelow.c |  2 +-
 gdb/solib.c   | 21 ++++++++++++---------
 gdb/solib.h   |  6 +++---
 gdb/symtab.h  |  4 ----
 4 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/gdb/corelow.c b/gdb/corelow.c
index 43c1f69b1317..f291b2aba191 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -335,7 +335,7 @@ core_target::clear_core ()
 
       /* Clear out solib state while the bfd is still open.  See
 	 comments in clear_solib in solib.c.  */
-      clear_solib ();
+      clear_solib (current_program_space);
 
       current_program_space->cbfd.reset (nullptr);
     }
diff --git a/gdb/solib.c b/gdb/solib.c
index 98cda039a833..bd69c549b8e8 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -1180,23 +1180,26 @@ solib_keep_data_in_core (CORE_ADDR vaddr, unsigned long size)
     return false;
 }
 
-/* Called by free_all_symtabs */
+/* See solib.h.  */
 
 void
-clear_solib (void)
+clear_solib (program_space *pspace)
 {
-  const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
+  inferior *inf = find_inferior_for_program_space (pspace);
+  gdb_assert (inf != nullptr);
+
+  const solib_ops *ops = gdbarch_so_ops (inf->arch ());
 
-  disable_breakpoints_in_shlibs (current_program_space);
+  disable_breakpoints_in_shlibs (pspace);
 
-  current_program_space->so_list.clear_and_dispose ([] (solib *so) {
-    notify_solib_unloaded (current_program_space, *so);
-    current_program_space->remove_target_sections (so);
+  pspace->so_list.clear_and_dispose ([pspace] (solib *so) {
+    notify_solib_unloaded (pspace, *so);
+    pspace->remove_target_sections (so);
     delete so;
   });
 
   if (ops->clear_solib != nullptr)
-    ops->clear_solib (current_program_space);
+    ops->clear_solib (pspace);
 }
 
 /* Shared library startup support.  When GDB starts up the inferior,
@@ -1244,7 +1247,7 @@ no_shared_libraries (const char *ignored, int from_tty)
      access to their associated objfiles.  Therefore, we can not purge the
      solibs' objfiles before clear_solib has been called.  */
 
-  clear_solib ();
+  clear_solib (current_program_space);
   objfile_purge_solibs ();
 }
 
diff --git a/gdb/solib.h b/gdb/solib.h
index 69183278318b..f7a93c0718f0 100644
--- a/gdb/solib.h
+++ b/gdb/solib.h
@@ -42,10 +42,10 @@ extern bool debug_solib;
 #define SOLIB_SCOPED_DEBUG_START_END(fmt, ...) \
   scoped_debug_start_end (debug_solib, "solib", fmt, ##__VA_ARGS__)
 
-/* Called when we free all symtabs, to free the shared library information
-   as well.  */
+/* Called when we free all symtabs of PSPACE, to free the shared library
+   information as well.  */
 
-extern void clear_solib (void);
+extern void clear_solib (program_space *pspace);
 
 /* Called to add symbols from a shared library to gdb's symbol table.  */
 
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 3b067a77b3c8..ca5a5b0f7fde 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -2423,10 +2423,6 @@ extern bool find_line_pc_range (struct symtab_and_line, CORE_ADDR *,
 
 extern void resolve_sal_pc (struct symtab_and_line *);
 
-/* solib.c */
-
-extern void clear_solib (void);
-
 /* The reason we're calling into a completion match list collector
    function.  */
 enum class complete_symbol_mode
-- 
2.43.0


  parent reply	other threads:[~2024-02-06 17:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-06 17:14 [PATCH 0/5] Random cleanup patches Simon Marchi
2024-02-06 17:14 ` [PATCH 1/5] gdb: add program_space parameter to mark_breakpoints_out Simon Marchi
2024-02-06 17:14 ` [PATCH 2/5] gdb: add inferior parameter to breakpoint_init_inferior Simon Marchi
2024-02-06 17:14 ` [PATCH 3/5] gdb: add program_space parameter to disable_breakpoints_in_shlibs Simon Marchi
2024-02-06 17:14 ` Simon Marchi [this message]
2024-02-07  3:37   ` [PATCH 4/5] gdb: add program_space parameter to clear_solib Simon Marchi
2024-02-06 17:14 ` [PATCH 5/5] gdb: remove unnecessary nullptr check in remove_user_added_objfile 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=20240206171514.119244-5-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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).