[RFA]: Fix for pending breakpoints in manually loaded/unloaded shlibs

Jeff Johnston jjohnstn@redhat.com
Wed Aug 11 15:58:00 GMT 2004


Eli Zaretskii wrote:
>>Date: Tue, 10 Aug 2004 15:09:37 -0400
>>From: Jeff Johnston <jjohnstn@redhat.com>
>>
>>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.
> 
> 
> Could you please explain why this complicated mechanism is needed to
> fix this problem?  Why cannot GDB directly mark the breakpoints when
> the library is unloaded, instead of going the observer path?
>

Kind of damned if I do, damned if I don't :) I had talked over the problem with 
Andrew and he suggested the observer path as this is an event that other parts 
of gdb would be interested in knowing about.  IMHO, the mechanism is rather 
elegant, extensible, and simple to use.

Do you feel that this event isn't worthy of observation?

-- Jeff J.

> 
>>Index: doc/observer.texi
>>===================================================================
>>RCS file: /cvs/src/src/gdb/doc/observer.texi,v
>>retrieving revision 1.7
>>diff -u -p -r1.7 observer.texi
>>--- doc/observer.texi	21 May 2004 16:04:03 -0000	1.7
>>+++ doc/observer.texi	10 Aug 2004 18:47:47 -0000
>>@@ -90,3 +90,8 @@ at the entry-point instruction.  For @sa
>> @value{GDBN} calls this observer immediately after connecting to the
>> inferior, and before any information on the inferior has been printed.
>> @end deftypefun
>>+
>>+@deftypefun void solib_unloaded (struct so_list *@var{solib})
>>+The specified shared library has been discovered to be unloaded.
>>+@end deftypefun
>>+
> 
> 
> This part is approved (provided that the rest of the patch is
> aproved).
> 
> 
>>+/* Disable any breakpoints that are in in an unloaded shared library.  Only
> 
>                                        ^^^^^
> A typo.
> 
> 
>>+void
>>+disable_breakpoints_in_unloaded_shlib (struct so_list *solib)
>>+{
>>+  struct breakpoint *b;
>>+  int disabled_shlib_breaks = 0;
>>+
>>+  /* See also: insert_breakpoints, under DISABLE_UNSETTABLE_BREAK. */
>>+  ALL_BREAKPOINTS (b)
>>+  {
>>+#if defined (PC_SOLIB)
> 
> 
> I think this #ifdef should be outside the loop: why loop at all if we
> do nothing inside the loop body?
> 



More information about the Gdb-patches mailing list