[vlc-devel] [PATCH] libvlc: help debug object references remaining in debug builds
David Fuhrmann
david.fuhrmann at gmail.com
Fri Oct 23 17:31:14 CEST 2015
2015-10-23 17:21 GMT+02:00 Steve Lhomme <robux4 at gmail.com>:
> On Fri, Oct 23, 2015 at 4:53 PM, Rémi Denis-Courmont <remi at remlab.net>
> wrote:
> > Le 2015-10-23 17:09, Steve Lhomme a écrit :
> >>
> >> ---
> >> src/libvlc.c | 12 ++++++++++++
> >> 1 file changed, 12 insertions(+)
> >>
> >> diff --git a/src/libvlc.c b/src/libvlc.c
> >> index 34824da..7e7b097 100644
> >> --- a/src/libvlc.c
> >> +++ b/src/libvlc.c
> >> @@ -553,7 +553,19 @@ void libvlc_InternalDestroy( libvlc_int_t
> *p_libvlc )
> >>
> >> vlc_ExitDestroy( &priv->exit );
> >>
> >> +#ifndef NDEBUG
> >> + vlc_object_internals_t *internals = vlc_internals(p_libvlc);
> >> + int refcount = atomic_load(&internals->refs);
> >> + if (refcount > 1) {
> >> + while (internals) {
> >> + vlc_Log(NULL, VLC_MSG_DBG, "libvlc", NULL, 0,
> >> "libvlc_InternalDestroy", "remaining ref %s count:%d",
> >> internals->psz_name ? internals->psz_name : "???", internals->refs);
> >> + internals = internals->first;
> >> + }
> >> + }
> >> + assert( refcount == 1 );
> >> +#else
> >> assert( atomic_load(&(vlc_internals(p_libvlc)->refs)) == 1 );
> >> +#endif
> >
> >
> > You know you can put a breakpoint and debug the memory content manually.
> In
> > general, we can't even assume that vlc logs will be flushed before the
> > assertion failure.
>
> That's advanced trickery to be able to get the debugger to access
> structures like this:
> # define vlc_internals( obj )
> (((vlc_object_internals_t*)(VLC_OBJECT(obj)))-1)
>
> >> vlc_object_release( p_libvlc );
> >> }
> >
> >
> > --
> > Rémi Denis-Courmont
> > http://www.remlab.net/
> > _______________________________________________
> > vlc-devel mailing list
> > To unsubscribe or modify your subscription options:
> > https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
Hi,
Actually, I tried already multiple times to get that information via a
debugger and failed always (probably because of compiler optimizations). So
some more debug output would be certainly useful.
BR. David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20151023/2d1b7b20/attachment.html>
More information about the vlc-devel
mailing list