[vlc-devel] [PATCH] libvlc: help debug object references remaining in debug builds
Rémi Denis-Courmont
remi at remlab.net
Fri Oct 23 16:53:33 CEST 2015
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.
> vlc_object_release( p_libvlc );
> }
--
Rémi Denis-Courmont
http://www.remlab.net/
More information about the vlc-devel
mailing list