+void
+program_space::remove_objfile (struct objfile *objfile)
+{
+ /* Removing an objfile from the objfile list invalidates any frame
+ that was built using frame info found in the objfile. Reinit the
+ frame cache to get rid of any frame that might otherwise
+ reference stale info. */
+ reinit_frame_cache ();
+
+ auto iter = std::find_if (objfiles_list.begin (), objfiles_list.end (),
+ [=] (const std::shared_ptr<::objfile> &objf)
+ {
+ return objf.get () == objfile;
+ });
+ gdb_assert (iter != objfiles_list.end ());
+ objfiles_list.erase (iter);