From: Simon Marchi Date: Mon, 22 Jul 2024 17:20:22 +0000 (+0000) Subject: gdb/solib: pass program space to solib_used X-Git-Tag: gdb-16-branchpoint~1341 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7dc9fbb845c2a048191f5045c18e833bb8255977;p=thirdparty%2Fbinutils-gdb.git gdb/solib: pass program space to solib_used Make the current program space reference bubble up one level. Change-Id: I6113c9ef57cb31ca8ea129ab58e7c318c09b5123 --- diff --git a/gdb/solib.c b/gdb/solib.c index 8b97cc61f64..931fa571be2 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -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 ();