+2020-10-29  Tom Tromey  <tom@tromey.com>
+
+       * progspace.c (program_space::~program_space): Don't call
+       clear_program_space_solib_cache.
+       (program_space::clear_solib_cache): Rename from
+       clear_solib_cache.
+       * solib.c (handle_solib_event): Update.
+       * progspace.h (struct program_space) <clear_solib_cache>: New
+       method.
+       (clear_program_space_solib_cache): Don't declare.
+
 2020-10-29  Tom Tromey  <tom@tromey.com>
 
        * windows-tdep.c (windows_solib_create_inferior_hook): Update.
 
   clear_symtab_users (SYMFILE_DEFER_BP_RESET);
   if (!gdbarch_has_shared_address_space (target_gdbarch ()))
     free_address_space (this->aspace);
-  clear_program_space_solib_cache (this);
     /* Discard any data modules have associated with the PSPACE.  */
   program_space_free_data (this);
 }
 /* See progspace.h.  */
 
 void
-clear_program_space_solib_cache (struct program_space *pspace)
+program_space::clear_solib_cache ()
 {
-  pspace->added_solibs.clear ();
-  pspace->deleted_solibs.clear ();
+  added_solibs.clear ();
+  deleted_solibs.clear ();
 }
 
 \f
 
     ebfd = std::move (abfd);
   }
 
+  /* Reset saved solib data at the start of an solib event.  This lets
+     us properly collect the data when calling solib_add, so it can then
+     later be printed.  */
+  void clear_solib_cache ();
+
   /* Unique ID number.  */
   int num = 0;
 
    mappings.  */
 extern void update_address_spaces (void);
 
-/* Reset saved solib data at the start of an solib event.  This lets
-   us properly collect the data when calling solib_add, so it can then
-   later be printed.  */
-extern void clear_program_space_solib_cache (struct program_space *);
-
 /* Keep a registry of per-pspace data-pointers required by other GDB
    modules.  */
 
 
   if (ops->handle_event != NULL)
     ops->handle_event ();
 
-  clear_program_space_solib_cache (current_inferior ()->pspace);
+  current_inferior ()->pspace->clear_solib_cache ();
 
   /* Check for any newly added shared libraries if we're supposed to
      be adding them automatically.  Switch terminal for any messages