]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/solib: pass program space to solib_used
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 22 Jul 2024 17:20:22 +0000 (17:20 +0000)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 22 Jul 2024 17:59:43 +0000 (13:59 -0400)
Make the current program space reference bubble up one level.

Change-Id: I6113c9ef57cb31ca8ea129ab58e7c318c09b5123

gdb/solib.c

index 8b97cc61f64cd15cc285ad7a4edca65db5b5ab5b..931fa571be25c29a3047507ec221330de4d1f467 100644 (file)
@@ -710,15 +710,16 @@ solib_read_symbols (solib &so, symfile_add_flags flags)
   return false;
 }
 
-/* Return true if KNOWN->objfile is used by any other so_list object
-   in the list of shared libraries.  Return false otherwise.  */
+/* Return true if KNOWN->objfile is used by any other solib object
+   in PSPACE's list of shared libraries.  Return false otherwise.  */
 
 static bool
-solib_used (const solib &known)
+solib_used (program_space *pspace, const solib &known)
 {
-  for (const solib &pivot : current_program_space->solibs ())
+  for (const solib &pivot : pspace->solibs ())
     if (&pivot != &known && pivot.objfile == known.objfile)
       return true;
+
   return false;
 }
 
@@ -845,7 +846,7 @@ update_solib_list (int from_tty)
          /* Unless the user loaded it explicitly, free SO's objfile.  */
          if (gdb_iter->objfile != nullptr
              && !(gdb_iter->objfile->flags & OBJF_USERLOADED)
-             && !solib_used (*gdb_iter))
+             && !solib_used (current_program_space, *gdb_iter))
            gdb_iter->objfile->unlink ();
 
          /* Some targets' section tables might be referring to
@@ -1321,7 +1322,7 @@ reload_shared_libraries_1 (int from_tty)
              && filename_cmp (found_pathname, so.so_name.c_str ()) != 0))
        {
          if (so.objfile && !(so.objfile->flags & OBJF_USERLOADED)
-             && !solib_used (so))
+             && !solib_used (current_program_space, so))
            so.objfile->unlink ();
          current_program_space->remove_target_sections (&so);
          so.clear ();