Index: solib.c =================================================================== RCS file: /cvs/src/src/gdb/solib.c,v retrieving revision 1.122 diff -u -p -u -r1.122 solib.c --- solib.c 17 Jul 2009 17:08:23 -0000 1.122 +++ solib.c 29 Jul 2009 23:39:11 -0000 @@ -893,10 +893,8 @@ solib_name_from_address (CORE_ADDR addre return (0); } -/* Called by free_all_symtabs */ - -void -clear_solib (void) +static void +clear_solib_1 (int notify_observers) { struct target_so_ops *ops = solib_ops (target_gdbarch); @@ -928,7 +926,8 @@ clear_solib (void) { struct so_list *so = so_list_head; so_list_head = so->next; - observer_notify_solib_unloaded (so); + if (notify_observers) + observer_notify_solib_unloaded (so); if (so->abfd) remove_target_sections (so->abfd); free_so (so); @@ -937,6 +936,15 @@ clear_solib (void) ops->clear_solib (); } +/* Called by free_all_symtabs */ + +void +clear_solib (void) +{ + clear_solib_1 (1); +} + + /* GLOBAL FUNCTION solib_create_inferior_hook -- shared library startup support @@ -1018,13 +1026,20 @@ sharedlibrary_command (char *args, int f void no_shared_libraries (char *ignored, int from_tty) { - /* The order of the two routines below is important: clear_solib notifies - the solib_unloaded observers, and some of these observers might need - access to their associated objfiles. Therefore, we can not purge the - solibs' objfiles before clear_solib has been called. */ + struct so_list *so = so_list_head; + + /* We notify all solib_unloaded observers before destroying any objfiles, + because some observers need access to their associated objfiles. */ + + for (so = so_list_head; so; so = so->next) + observer_notify_solib_unloaded (so); + + /* The order of the two routines below is important: clear_solib_1 + will free/close objfile->obfd (solib owns it), but objfile_purge_solibs + needs access to it (at least on ARM, see arm_objfile_data_cleanup). */ - clear_solib (); objfile_purge_solibs (); + clear_solib_1 (0); } static void