leaks: Do not trace refs for object we do not follow

When the user sets filters, we should not trace ref counts of object that
are not traced. This optimizes the tracer by potentially avoiding
generating useless backtraces.
This commit is contained in:
Thibault Saunier 2020-02-13 17:53:29 -03:00 committed by Thibault Saunier
parent d28e0b4147
commit 14cd8b8348

View file

@ -413,8 +413,8 @@ object_created_cb (GstTracer * tracer, GstClockTime ts, GstObject * object)
}
static void
handle_object_reffed (GstLeaksTracer * self, gpointer object, gint new_refcount,
gboolean reffed, GstClockTime ts)
handle_object_reffed (GstLeaksTracer * self, gpointer object, GType type,
gint new_refcount, gboolean reffed, GstClockTime ts)
{
ObjectRefingInfos *infos;
ObjectRefingInfo *refinfo;
@ -422,6 +422,9 @@ handle_object_reffed (GstLeaksTracer * self, gpointer object, gint new_refcount,
if (!self->check_refs)
return;
if (!should_handle_object_type (self, type))
return;
GST_OBJECT_LOCK (self);
infos = g_hash_table_lookup (self->objects, object);
if (!infos)
@ -446,7 +449,8 @@ object_reffed_cb (GstTracer * tracer, GstClockTime ts, GstObject * object,
{
GstLeaksTracer *self = GST_LEAKS_TRACER_CAST (tracer);
handle_object_reffed (self, object, new_refcount, TRUE, ts);
handle_object_reffed (self, object, G_OBJECT_TYPE (object), new_refcount,
TRUE, ts);
}
static void
@ -455,7 +459,8 @@ object_unreffed_cb (GstTracer * tracer, GstClockTime ts, GstObject * object,
{
GstLeaksTracer *self = GST_LEAKS_TRACER_CAST (tracer);
handle_object_reffed (self, object, new_refcount, FALSE, ts);
handle_object_reffed (self, object, G_OBJECT_TYPE (object), new_refcount,
FALSE, ts);
}
static void
@ -464,7 +469,8 @@ mini_object_reffed_cb (GstTracer * tracer, GstClockTime ts,
{
GstLeaksTracer *self = GST_LEAKS_TRACER_CAST (tracer);
handle_object_reffed (self, object, new_refcount, TRUE, ts);
handle_object_reffed (self, object, GST_MINI_OBJECT_TYPE (object),
new_refcount, TRUE, ts);
}
static void
@ -473,7 +479,8 @@ mini_object_unreffed_cb (GstTracer * tracer, GstClockTime ts,
{
GstLeaksTracer *self = GST_LEAKS_TRACER_CAST (tracer);
handle_object_reffed (self, object, new_refcount, FALSE, ts);
handle_object_reffed (self, object, GST_MINI_OBJECT_TYPE (object),
new_refcount, FALSE, ts);
}
static void