enable allocation tracing for GstObjects and make allocation tracing a configure switch (enable by default for now)

Original commit message from CVS:
enable allocation tracing for GstObjects and make allocation tracing a configure switch (enable by default for now)
This commit is contained in:
Benjamin Otte 2003-05-10 12:42:02 +00:00
parent b41c935ff7
commit b74e6f24f2
4 changed files with 54 additions and 12 deletions

View file

@ -327,6 +327,9 @@ translit(dnm, m, l) AM_CONDITIONAL(GST_DISABLE_PARSE, true)
GST_SUBSYSTEM_DISABLE(PARSE,[command-line parser])
translit(dnm, m, l) AM_CONDITIONAL(GST_DISABLE_TRACE, true)
GST_SUBSYSTEM_DISABLE(TRACE,[tracing subsystem])
translit(dnm, m, l) AM_CONDITIONAL(GST_DISABLE_ALLOC_TRACE, true)
GST_SUBSYSTEM_DISABLE(ALLOC_TRACE,[allocation tracing])
translit(dnm, m, l) AM_CONDITIONAL(GST_DISABLE_REGISTRY, true)
GST_SUBSYSTEM_DISABLE(REGISTRY,[plugin registry])
translit(dnm, m, l) AM_CONDITIONAL(GST_DISABLE_ENUMTYPES, true)

View file

@ -24,6 +24,9 @@
#include "gstobject.h"
#include "gstlog.h"
#ifndef GST_DISABLE_TRACE
#include "gsttrace.h"
#endif
/* Object signals and args */
enum {
@ -64,6 +67,10 @@ static guint gst_signal_object_signals[SO_LAST_SIGNAL] = { 0 };
static void gst_object_class_init (GstObjectClass *klass);
static void gst_object_init (GstObject *object);
#ifndef GST_DISABLE_TRACE
static GObject * gst_object_constructor (GType type, guint n_construct_properties,
GObjectConstructParam *construct_params);
#endif
static void gst_object_set_property (GObject * object, guint prop_id, const GValue * value,
GParamSpec * pspec);
@ -156,6 +163,9 @@ gst_object_class_init (GstObjectClass *klass)
gobject_class->dispose = gst_object_dispose;
gobject_class->finalize = gst_object_finalize;
#ifndef GST_DISABLE_TRACE
gobject_class->constructor = gst_object_constructor;
#endif
}
static void
@ -169,6 +179,25 @@ gst_object_init (GstObject *object)
GST_FLAG_SET (object, GST_FLOATING);
}
#ifndef GST_DISABLE_TRACE
static GObject *
gst_object_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_params)
{
const gchar *name;
GstAllocTrace *trace;
GObject *obj = G_OBJECT_CLASS (parent_class)->constructor (type, n_construct_properties, construct_params);
name = g_type_name (type);
trace = gst_alloc_trace_get (name);
if (!trace) {
trace = gst_alloc_trace_register (name);
}
gst_alloc_trace_new (trace, obj);
return obj;
}
#endif
/**
* gst_object_ref:
* @object: GstObject to reference
@ -281,6 +310,18 @@ gst_object_finalize (GObject *object)
g_mutex_free (gstobject->lock);
#ifndef GST_DISABLE_TRACE
{
const gchar *name;
GstAllocTrace *trace;
name = g_type_name (G_OBJECT_TYPE (object));
trace = gst_alloc_trace_get (name);
g_assert (trace);
gst_alloc_trace_free (trace, object);
}
#endif
parent_class->finalize (object);
}

View file

@ -171,10 +171,10 @@ static GList *_gst_alloc_tracers = NULL;
gboolean
gst_alloc_trace_available (void)
{
#ifdef GST_WITH_ALLOC_TRACE
return TRUE;
#else
#ifdef GST_DISABLE_ALLOC_TRACE
return FALSE;
#else
return TRUE;
#endif
}
@ -227,7 +227,7 @@ void
gst_alloc_trace_print_all (void)
{
GList *walk = _gst_alloc_tracers;
while (walk) {
GstAllocTrace *trace = (GstAllocTrace *) walk->data;
@ -338,5 +338,3 @@ gst_alloc_trace_set_flags (GstAllocTrace *trace, GstAllocTraceFlags flags)
trace->flags = flags;
}

View file

@ -97,7 +97,7 @@ void gst_alloc_trace_print (const GstAllocTrace *trace);
void gst_alloc_trace_set_flags (GstAllocTrace *trace, GstAllocTraceFlags flags);
#ifdef GST_WITH_ALLOC_TRACE
#ifndef GST_DISABLE_ALLOC_TRACE
#define gst_alloc_trace_register(name) _gst_alloc_trace_register (name);
#define gst_alloc_trace_new(trace, mem) \
G_STMT_START { \
@ -118,7 +118,7 @@ G_STMT_START { \
} G_STMT_END
#else
#define gst_alloc_trace_register(name) NULL
#define gst_alloc_trace_register(name) (NULL)
#define gst_alloc_trace_new(trace, mem)
#define gst_alloc_trace_free(trace, mem)
#endif
@ -152,14 +152,14 @@ extern gint _gst_trace_on;
#define gst_alloc_trace_new(trace, mem)
#define gst_alloc_trace_free(trace, mem)
#define gst_alloc_trace_available() FALSE
#define gst_alloc_trace_list() NULL
#define _gst_alloc_trace_register(name) NULL
#define gst_alloc_trace_available() (FALSE)
#define gst_alloc_trace_list() (NULL)
#define _gst_alloc_trace_register(name) (NULL)
#define gst_alloc_trace_print_all()
#define gst_alloc_trace_set_flags_all(flags)
#define gst_alloc_trace_get(name) NULL
#define gst_alloc_trace_get(name) (NULL)
#define gst_alloc_trace_print(trace)
#define gst_alloc_trace_set_flags(trace,flags)