The following patch fixes a problem with breakpoints set in shlibs that are manually loaded/unloaded by the program. What currently happens is that pending breakpoints work properly for the first run of the program. On the 2nd run, the resolved breakpoint(s) can end up at the start of the breakpoint list and is marked bp_shlib_disabled. This is fine for a bit and we reach the breakpoint again when the shared library is loaded. However, when we unload the 2nd time, there is trouble. We eventually get a shlib_event from the dlclose() and we attempt to remove the breakpoint to step over it. Unfortunately, we try and remove all breakpoints and we end attempting to remove a breakpoint that no longer exists (remember the breakpoint for the shared library routine is now at the start of the breakpoint list). We fail trying to remove the first breakpoint and end up failing remove_breakpoints. We subsequently keep running into the shlib_event breakpoint over and over again ad-infinitum. To fix this, I have added an observer for a new event: solib_unloaded. When update_solib_list discovers a shared library has been unloaded, it notifies all observers (initially this is just breakpoint.c). Breakpoint.c sets up an observer to find all breakpoints in the removed shlib and mark them as non-inserted and bp_shlib_disabled. This solves the problem. I also added code to re_enable_breakpoints_in_shlibs to remove the error messages we get when we go and rerun the program (it attempts to find shlib breakpoints in every shared library that gets loaded). I have included a new test case which exercises the scenario. Ok to commit? -- Jeff J. 2004-08-10 Jeff Johnston * observer.sh: Add struct so_list declaration. * Makefile.in: Add dependencies on observer.h for solib.c and breakpoint.c. * breakpoint.c (disable_breakpoints_in_unloaded_shlib): New function. (_initialize_breakpoint): Register disable_breakpoints_in_unloaded_shlib as an observer of the "solib unloaded" observation event. (re_enable_breakpoints_in_shlibs): For bp_shlib_disabled breakpoints, call decode_line_1 so unfound breakpoint errors are silent. * solib.c (update_solib_list): When a solib is discovered to have been unloaded by the program, notify all observers of the "solib unloaded" observation event. 2004-08-10 Jeff Johnston * gdb.base/unload.exp: New test for breakpoints in dynamically loaded libraries. * gdb.base/unload.c: Ditto. * gdb.base/unloadshr.c: Ditto.