summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorThibault Saunier <tsaunier@gnome.org>2016-12-02 08:29:11 -0300
committerThibault Saunier <thibault.saunier@osg.samsung.com>2016-12-20 15:29:10 -0300
commit29f0a7988018025aa358a6cf2b26ea4e14b48512 (patch)
tree0dfcd15828a1c5eb78a4b0175565fef3e8e00be4 /plugins
parent30133909cefab53447556a4f82d4ccb63f0027a6 (diff)
leaks: Allow user to set the flags to use to retrieve stack traces
https://bugzilla.gnome.org/show_bug.cgi?id=775541
Diffstat (limited to 'plugins')
-rw-r--r--plugins/tracers/gstleaks.c49
-rw-r--r--plugins/tracers/gstleaks.h2
2 files changed, 30 insertions, 21 deletions
diff --git a/plugins/tracers/gstleaks.c b/plugins/tracers/gstleaks.c
index 950d92069..5960c91a5 100644
--- a/plugins/tracers/gstleaks.c
+++ b/plugins/tracers/gstleaks.c
@@ -25,7 +25,7 @@
* A tracing module tracking the lifetime of objects by logging those still
* alive when program is exiting and raising a warning.
* The type of objects tracked can be filtered using the parameters of the
- * tracer, for example: GST_TRACERS=leaks(filters="GstEvent,GstMessage",print-traces=true)
+ * tracer, for example: GST_TRACERS=leaks(filters="GstEvent,GstMessage",stack-traces-flags=full)
*/
#ifdef HAVE_CONFIG_H
@@ -88,27 +88,36 @@ object_refing_infos_free (ObjectRefingInfos * infos)
}
static void
-set_print_stack_trace (GstLeaksTracer * self, GstStructure * params)
+set_print_stack_trace_from_string (GstLeaksTracer * self, const gchar * str)
{
gchar *trace;
- gboolean check_stack_trace =
- g_getenv ("GST_LEAKS_TRACER_STACK_TRACE") != NULL;
-
- if (!check_stack_trace && params)
- gst_structure_get_boolean (params, "print-traces", &check_stack_trace);
- if (!check_stack_trace)
+ /* Test if we can retrieve backtrace */
+ trace = gst_debug_get_stack_trace (FALSE);
+ if (!trace)
return;
+ g_free (trace);
- /* Test if we can retrieve backtrace */
- trace = gst_debug_get_stack_trace (0);
- if (trace) {
- self->log_stack_trace = TRUE;
- g_free (trace);
- } else {
- g_warning ("Can't retrieve backtrace on this system");
- }
+ if (g_strcmp0 (str, "full") == 0)
+ self->trace_flags = GST_STACK_TRACE_SHOW_FULL;
+ else
+ self->trace_flags = 0;
+}
+
+static void
+set_print_stack_trace (GstLeaksTracer * self, GstStructure * params)
+{
+ const gchar *trace_flags = g_getenv ("GST_LEAKS_TRACER_STACK_TRACE");
+
+ self->trace_flags = -1;
+ if (!trace_flags && params)
+ trace_flags = gst_structure_get_string (params, "stack-traces-flags");
+
+ if (!trace_flags)
+ return;
+
+ set_print_stack_trace_from_string (self, trace_flags);
}
static void
@@ -309,8 +318,8 @@ handle_object_created (GstLeaksTracer * self, gpointer object, GType type,
mini_object_weak_cb, self);
GST_OBJECT_LOCK (self);
- if (self->log_stack_trace)
- infos->creation_trace = gst_debug_get_stack_trace (0);
+ if ((gint) self->trace_flags != -1)
+ infos->creation_trace = gst_debug_get_stack_trace (self->trace_flags);
g_hash_table_insert (self->objects, object, infos);
@@ -362,8 +371,8 @@ handle_object_reffed (GstLeaksTracer * self, gpointer object, gint new_refcount,
refinfo->ts = ts;
refinfo->new_refcount = new_refcount;
refinfo->reffed = reffed;
- if (self->log_stack_trace)
- refinfo->trace = gst_debug_get_stack_trace (0);
+ if ((gint) self->trace_flags != -1)
+ refinfo->trace = gst_debug_get_stack_trace (self->trace_flags);
infos->refing_infos = g_list_prepend (infos->refing_infos, refinfo);
diff --git a/plugins/tracers/gstleaks.h b/plugins/tracers/gstleaks.h
index 7539b26b4..339bae89c 100644
--- a/plugins/tracers/gstleaks.h
+++ b/plugins/tracers/gstleaks.h
@@ -70,7 +70,7 @@ struct _GstLeaksTracer {
gboolean check_refs;
- gboolean log_stack_trace;
+ GstStackTraceFlags trace_flags;
};
struct _GstLeaksTracerClass {