public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* How does solib handline shared library unloads?
@ 2005-11-01  5:39 Christopher Faylor
  2005-11-01  6:59 ` Mark Kettenis
  0 siblings, 1 reply; 9+ messages in thread
From: Christopher Faylor @ 2005-11-01  5:39 UTC (permalink / raw)
  To: gdb

Can anyone enlighten me as to how information about a library is
relinquished when a library loaded via dlopen is unloaded via dlclose?
Theoretically, the information about the library should be removed and
the library should not be listed by "info sharedlibrary".

I don't see any way for this to be handled in solib.c and inf*.c but I'm
sure I'm just missing something obvious.  I haven't written a test case
yet to see how it is being handled but I was hoping someone could
clarify this for me.

cgf

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How does solib handline shared library unloads?
  2005-11-01  5:39 How does solib handline shared library unloads? Christopher Faylor
@ 2005-11-01  6:59 ` Mark Kettenis
  2005-11-01 13:45   ` Christopher Faylor
  0 siblings, 1 reply; 9+ messages in thread
From: Mark Kettenis @ 2005-11-01  6:59 UTC (permalink / raw)
  To: me; +Cc: gdb

> Date: Tue, 1 Nov 2005 00:39:34 -0500
> From: Christopher Faylor <me@cgf.cx>
> 
> Can anyone enlighten me as to how information about a library is
> relinquished when a library loaded via dlopen is unloaded via dlclose?
> Theoretically, the information about the library should be removed and
> the library should not be listed by "info sharedlibrary".
> 
> I don't see any way for this to be handled in solib.c and inf*.c but I'm
> sure I'm just missing something obvious.  I haven't written a test case
> yet to see how it is being handled but I was hoping someone could
> clarify this for me.

It happens as part of solib_add(), which should be called for every
shared library events, not just dlopen()s.  See the code in
update_solib_list() for the code that actually removes libraries from
GDB's internal list.

That said, I think I have convinced myself in the past that there is a
big gaping memory leak.

Mark

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How does solib handline shared library unloads?
  2005-11-01  6:59 ` Mark Kettenis
@ 2005-11-01 13:45   ` Christopher Faylor
  2005-11-01 13:51     ` Daniel Jacobowitz
  0 siblings, 1 reply; 9+ messages in thread
From: Christopher Faylor @ 2005-11-01 13:45 UTC (permalink / raw)
  To: gdb

On Tue, Nov 01, 2005 at 07:58:35AM +0100, Mark Kettenis wrote:
>> Date: Tue, 1 Nov 2005 00:39:34 -0500
>> From: Christopher Faylor
>> 
>> Can anyone enlighten me as to how information about a library is
>> relinquished when a library loaded via dlopen is unloaded via dlclose?
>> Theoretically, the information about the library should be removed and
>> the library should not be listed by "info sharedlibrary".
>> 
>> I don't see any way for this to be handled in solib.c and inf*.c but I'm
>> sure I'm just missing something obvious.  I haven't written a test case
>> yet to see how it is being handled but I was hoping someone could
>> clarify this for me.
>
>It happens as part of solib_add(), which should be called for every
>shared library events, not just dlopen()s.  See the code in
>update_solib_list() for the code that actually removes libraries from
>GDB's internal list.

Is this handled as part of the so breakpoint stuff?  I was trying to
avoid implementing that but I will if I have to.

>That said, I think I have convinced myself in the past that there is a
>big gaping memory leak.

I was wondering about that.  I thought there might be a big memory leak
there since it doesn't look like objfile's are being freed.

cgf

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How does solib handline shared library unloads?
  2005-11-01 13:45   ` Christopher Faylor
@ 2005-11-01 13:51     ` Daniel Jacobowitz
  2005-11-01 14:40       ` Christopher Faylor
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Jacobowitz @ 2005-11-01 13:51 UTC (permalink / raw)
  To: gdb

On Tue, Nov 01, 2005 at 08:45:47AM -0500, Christopher Faylor wrote:
> On Tue, Nov 01, 2005 at 07:58:35AM +0100, Mark Kettenis wrote:
> >> Date: Tue, 1 Nov 2005 00:39:34 -0500
> >> From: Christopher Faylor
> >> 
> >> Can anyone enlighten me as to how information about a library is
> >> relinquished when a library loaded via dlopen is unloaded via dlclose?
> >> Theoretically, the information about the library should be removed and
> >> the library should not be listed by "info sharedlibrary".
> >> 
> >> I don't see any way for this to be handled in solib.c and inf*.c but I'm
> >> sure I'm just missing something obvious.  I haven't written a test case
> >> yet to see how it is being handled but I was hoping someone could
> >> clarify this for me.
> >
> >It happens as part of solib_add(), which should be called for every
> >shared library events, not just dlopen()s.  See the code in
> >update_solib_list() for the code that actually removes libraries from
> >GDB's internal list.
> 
> Is this handled as part of the so breakpoint stuff?  I was trying to
> avoid implementing that but I will if I have to.

Well, that's how we get to solib_add for svr4 targets; but it should
work to get there off an explicit DLL unload event, anyway.  I think.

> >That said, I think I have convinced myself in the past that there is a
> >big gaping memory leak.
> 
> I was wondering about that.  I thought there might be a big memory leak
> there since it doesn't look like objfile's are being freed.

I'm not sure... ideally, I'd rather they were neither freed nor leaked,
since we're likely to load them again.  But that may be a lot of work
yet.

-- 
Daniel Jacobowitz
CodeSourcery, LLC

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How does solib handline shared library unloads?
  2005-11-01 13:51     ` Daniel Jacobowitz
@ 2005-11-01 14:40       ` Christopher Faylor
  2005-11-01 15:12         ` Daniel Jacobowitz
  0 siblings, 1 reply; 9+ messages in thread
From: Christopher Faylor @ 2005-11-01 14:40 UTC (permalink / raw)
  To: gdb

On Tue, Nov 01, 2005 at 08:51:42AM -0500, Daniel Jacobowitz wrote:
>On Tue, Nov 01, 2005 at 08:45:47AM -0500, Christopher Faylor wrote:
>>Is this handled as part of the so breakpoint stuff?  I was trying to
>>avoid implementing that but I will if I have to.
>
>Well, that's how we get to solib_add for svr4 targets; but it should
>work to get there off an explicit DLL unload event, anyway.  I think.

Yeah, that's what I did but I think that the more I make the windows
target work like linux, the less chance there will be that it will get
out of sync with ongoing development.

So, I might eventually just try to make this work more like linux.

cgf

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How does solib handline shared library unloads?
  2005-11-01 14:40       ` Christopher Faylor
@ 2005-11-01 15:12         ` Daniel Jacobowitz
  2005-11-01 16:20           ` Christopher Faylor
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Jacobowitz @ 2005-11-01 15:12 UTC (permalink / raw)
  To: gdb

On Tue, Nov 01, 2005 at 09:40:32AM -0500, Christopher Faylor wrote:
> On Tue, Nov 01, 2005 at 08:51:42AM -0500, Daniel Jacobowitz wrote:
> >On Tue, Nov 01, 2005 at 08:45:47AM -0500, Christopher Faylor wrote:
> >>Is this handled as part of the so breakpoint stuff?  I was trying to
> >>avoid implementing that but I will if I have to.
> >
> >Well, that's how we get to solib_add for svr4 targets; but it should
> >work to get there off an explicit DLL unload event, anyway.  I think.
> 
> Yeah, that's what I did but I think that the more I make the windows
> target work like linux, the less chance there will be that it will get
> out of sync with ongoing development.
> 
> So, I might eventually just try to make this work more like linux.

Well, there's other targets which provide explicit unload notification
(HP/UX; perhaps Symbian someday)...

-- 
Daniel Jacobowitz
CodeSourcery, LLC

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How does solib handline shared library unloads?
  2005-11-01 15:12         ` Daniel Jacobowitz
@ 2005-11-01 16:20           ` Christopher Faylor
  2005-11-01 16:24             ` Daniel Jacobowitz
  0 siblings, 1 reply; 9+ messages in thread
From: Christopher Faylor @ 2005-11-01 16:20 UTC (permalink / raw)
  To: gdb

On Tue, Nov 01, 2005 at 10:12:12AM -0500, Daniel Jacobowitz wrote:
>On Tue, Nov 01, 2005 at 09:40:32AM -0500, Christopher Faylor wrote:
>> On Tue, Nov 01, 2005 at 08:51:42AM -0500, Daniel Jacobowitz wrote:
>> >On Tue, Nov 01, 2005 at 08:45:47AM -0500, Christopher Faylor wrote:
>> >>Is this handled as part of the so breakpoint stuff?  I was trying to
>> >>avoid implementing that but I will if I have to.
>> >
>> >Well, that's how we get to solib_add for svr4 targets; but it should
>> >work to get there off an explicit DLL unload event, anyway.  I think.
>> 
>> Yeah, that's what I did but I think that the more I make the windows
>> target work like linux, the less chance there will be that it will get
>> out of sync with ongoing development.
>> 
>> So, I might eventually just try to make this work more like linux.
>
>Well, there's other targets which provide explicit unload notification
>(HP/UX; perhaps Symbian someday)...

Cygwin sets TARGET_WAITKIND_LOADED when a DLL is loaded but I don't see
any corresponding TARGET_WAITKIND_UNLOADED.  It doesn't look like
TARGET_WAITKIND_LOADED calls solib_add, though.

cgf

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How does solib handline shared library unloads?
  2005-11-01 16:20           ` Christopher Faylor
@ 2005-11-01 16:24             ` Daniel Jacobowitz
  2005-11-01 18:24               ` Mark Kettenis
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Jacobowitz @ 2005-11-01 16:24 UTC (permalink / raw)
  To: gdb

On Tue, Nov 01, 2005 at 11:20:25AM -0500, Christopher Faylor wrote:
> Cygwin sets TARGET_WAITKIND_LOADED when a DLL is loaded but I don't see
> any corresponding TARGET_WAITKIND_UNLOADED.  It doesn't look like
> TARGET_WAITKIND_LOADED calls solib_add, though.

Yes: those are (were) just used for catch, not for actual shared
library list management.  This is bogus; that's the part that ought to
be fixed in core GDB.

-- 
Daniel Jacobowitz
CodeSourcery, LLC

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How does solib handline shared library unloads?
  2005-11-01 16:24             ` Daniel Jacobowitz
@ 2005-11-01 18:24               ` Mark Kettenis
  0 siblings, 0 replies; 9+ messages in thread
From: Mark Kettenis @ 2005-11-01 18:24 UTC (permalink / raw)
  To: drow; +Cc: gdb

> Date: Tue, 1 Nov 2005 11:24:37 -0500
> From: Daniel Jacobowitz <drow@false.org>
> 
> On Tue, Nov 01, 2005 at 11:20:25AM -0500, Christopher Faylor wrote:
> > Cygwin sets TARGET_WAITKIND_LOADED when a DLL is loaded but I don't see
> > any corresponding TARGET_WAITKIND_UNLOADED.  It doesn't look like
> > TARGET_WAITKIND_LOADED calls solib_add, though.
> 
> Yes: those are (were) just used for catch, not for actual shared
> library list management.  This is bogus; that's the part that ought to
> be fixed in core GDB.

Indeed, there's quite a bit old cruft in the shared library code.
HP-UX doesn't use TARGET_WAITKIND_LOADED anymore, but it seems it is
still used for AIX.  That said, it defenitely is preferable to have
those events instead of overloading the breakpoint mechanism like
Linux does.  Using shared library breakpoints means that core GDB
needs to figure out whether we stopped because of a shared library
event or a normal breakpoint.  Chris, if your OS can tell you why it
stopped, you shouldn't throw away that information.

Mark

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2005-11-01 18:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-01  5:39 How does solib handline shared library unloads? Christopher Faylor
2005-11-01  6:59 ` Mark Kettenis
2005-11-01 13:45   ` Christopher Faylor
2005-11-01 13:51     ` Daniel Jacobowitz
2005-11-01 14:40       ` Christopher Faylor
2005-11-01 15:12         ` Daniel Jacobowitz
2005-11-01 16:20           ` Christopher Faylor
2005-11-01 16:24             ` Daniel Jacobowitz
2005-11-01 18:24               ` Mark Kettenis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).