2000-12-28 22:12:02 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
*
|
2005-09-07 13:22:16 +00:00
|
|
|
* gsttrace.h: Header for tracing functions (deprecated)
|
2000-01-30 09:03:00 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __GST_TRACE_H__
|
|
|
|
#define __GST_TRACE_H__
|
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
#include <glib.h>
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
G_BEGIN_DECLS
|
2000-12-28 22:12:02 +00:00
|
|
|
|
2006-07-18 09:42:31 +00:00
|
|
|
/**
|
|
|
|
* GstAllocTraceFlags:
|
2012-07-10 09:46:41 +00:00
|
|
|
* @GST_ALLOC_TRACE_NONE: No tracing specified or desired.
|
2011-08-25 20:05:26 +00:00
|
|
|
* @GST_ALLOC_TRACE_LIVE: Trace number of non-freed memory.
|
|
|
|
* @GST_ALLOC_TRACE_MEM_LIVE: Trace pointers of unfreed memory.
|
2006-07-18 09:42:31 +00:00
|
|
|
*
|
|
|
|
* Flags indicating which tracing feature to enable.
|
|
|
|
*/
|
|
|
|
typedef enum {
|
2011-08-25 20:05:26 +00:00
|
|
|
GST_ALLOC_TRACE_NONE = 0,
|
|
|
|
GST_ALLOC_TRACE_LIVE = (1 << 0),
|
2011-11-11 15:52:41 +00:00
|
|
|
GST_ALLOC_TRACE_MEM_LIVE = (1 << 1)
|
2006-07-18 09:42:31 +00:00
|
|
|
} GstAllocTraceFlags;
|
|
|
|
|
2011-11-11 15:52:41 +00:00
|
|
|
typedef struct _GstAllocTrace GstAllocTrace;
|
2006-07-18 09:42:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GstAllocTrace:
|
|
|
|
* @name: The name of the tracing object
|
|
|
|
* @flags: Flags for this object
|
2012-01-27 16:50:42 +00:00
|
|
|
* @offset: offset of the GType
|
2006-07-18 09:42:31 +00:00
|
|
|
* @live: counter for live memory
|
|
|
|
* @mem_live: list with pointers to unfreed memory
|
|
|
|
*
|
|
|
|
* The main tracing object
|
|
|
|
*/
|
|
|
|
struct _GstAllocTrace {
|
2011-11-11 15:52:41 +00:00
|
|
|
gchar *name;
|
|
|
|
gint flags;
|
2006-07-18 09:42:31 +00:00
|
|
|
|
2012-01-27 16:50:42 +00:00
|
|
|
goffset offset;
|
2011-11-11 15:52:41 +00:00
|
|
|
gint live;
|
|
|
|
GSList *mem_live;
|
2006-07-18 09:42:31 +00:00
|
|
|
};
|
|
|
|
|
2004-04-05 19:02:39 +00:00
|
|
|
#ifndef GST_DISABLE_TRACE
|
|
|
|
|
2012-01-22 00:42:34 +00:00
|
|
|
GST_EXPORT GMutex _gst_trace_mutex;
|
2009-06-23 11:44:50 +00:00
|
|
|
|
2012-01-27 16:50:42 +00:00
|
|
|
void _priv_gst_alloc_trace_initialize (void);
|
|
|
|
void _priv_gst_alloc_trace_deinit (void);
|
|
|
|
GstAllocTrace* _priv_gst_alloc_trace_register (const gchar *name, goffset offset);
|
2003-02-02 19:10:44 +00:00
|
|
|
|
2012-01-27 16:50:42 +00:00
|
|
|
void _priv_gst_alloc_trace_dump (void);
|
2003-02-02 19:10:44 +00:00
|
|
|
|
2003-05-10 12:42:02 +00:00
|
|
|
#ifndef GST_DISABLE_ALLOC_TRACE
|
2005-09-07 13:22:16 +00:00
|
|
|
/**
|
|
|
|
* gst_alloc_trace_register:
|
|
|
|
* @name: The name of the tracer object
|
|
|
|
*
|
|
|
|
* Register a new alloc tracer with the given name
|
|
|
|
*/
|
2012-01-27 16:50:42 +00:00
|
|
|
#define _gst_alloc_trace_register(name,offset) _priv_gst_alloc_trace_register (name,offset)
|
|
|
|
|
|
|
|
#define _gst_alloc_trace_dump _priv_gst_alloc_trace_dump
|
2005-09-07 13:22:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_alloc_trace_new:
|
|
|
|
* @trace: The tracer to use
|
|
|
|
* @mem: The memory allocated
|
|
|
|
*
|
|
|
|
* Use the tracer to trace a new memory allocation
|
|
|
|
*/
|
2012-01-27 16:50:42 +00:00
|
|
|
#define _gst_alloc_trace_new(trace, mem) \
|
2011-11-11 15:52:41 +00:00
|
|
|
G_STMT_START { \
|
2009-06-23 11:44:50 +00:00
|
|
|
if (G_UNLIKELY ((trace)->flags)) { \
|
2012-01-22 00:42:34 +00:00
|
|
|
g_mutex_lock (&_gst_trace_mutex); \
|
2011-11-11 15:52:41 +00:00
|
|
|
if ((trace)->flags & GST_ALLOC_TRACE_LIVE) \
|
|
|
|
(trace)->live++; \
|
|
|
|
if ((trace)->flags & GST_ALLOC_TRACE_MEM_LIVE) \
|
|
|
|
(trace)->mem_live = \
|
|
|
|
g_slist_prepend ((trace)->mem_live, mem); \
|
2012-01-22 00:42:34 +00:00
|
|
|
g_mutex_unlock (&_gst_trace_mutex); \
|
2009-06-23 11:44:50 +00:00
|
|
|
} \
|
2003-02-02 19:10:44 +00:00
|
|
|
} G_STMT_END
|
|
|
|
|
2005-09-07 13:22:16 +00:00
|
|
|
/**
|
|
|
|
* gst_alloc_trace_free:
|
|
|
|
* @trace: The tracer to use
|
|
|
|
* @mem: The memory that is freed
|
|
|
|
*
|
|
|
|
* Trace a memory free operation
|
|
|
|
*/
|
2012-01-27 16:50:42 +00:00
|
|
|
#define _gst_alloc_trace_free(trace, mem) \
|
2011-11-11 15:52:41 +00:00
|
|
|
G_STMT_START { \
|
2009-06-23 11:44:50 +00:00
|
|
|
if (G_UNLIKELY ((trace)->flags)) { \
|
2012-01-22 00:42:34 +00:00
|
|
|
g_mutex_lock (&_gst_trace_mutex); \
|
2011-11-11 15:52:41 +00:00
|
|
|
if ((trace)->flags & GST_ALLOC_TRACE_LIVE) \
|
|
|
|
(trace)->live--; \
|
|
|
|
if ((trace)->flags & GST_ALLOC_TRACE_MEM_LIVE) \
|
|
|
|
(trace)->mem_live = \
|
|
|
|
g_slist_remove ((trace)->mem_live, mem); \
|
2012-01-22 00:42:34 +00:00
|
|
|
g_mutex_unlock (&_gst_trace_mutex); \
|
2009-06-23 11:44:50 +00:00
|
|
|
} \
|
2003-02-02 19:10:44 +00:00
|
|
|
} G_STMT_END
|
|
|
|
|
|
|
|
#else
|
2012-01-27 16:50:42 +00:00
|
|
|
#define _gst_alloc_trace_register(name) (NULL)
|
|
|
|
#define _gst_alloc_trace_new(trace, mem)
|
|
|
|
#define _gst_alloc_trace_free(trace, mem)
|
|
|
|
#define _gst_alloc_trace_dump()
|
2003-02-02 19:10:44 +00:00
|
|
|
#endif
|
|
|
|
|
2001-12-15 18:15:13 +00:00
|
|
|
#else /* GST_DISABLE_TRACE */
|
2001-06-25 20:36:02 +00:00
|
|
|
|
2012-01-27 16:50:42 +00:00
|
|
|
#define _gst_alloc_trace_register(name, offset) (NULL)
|
|
|
|
#define _gst_alloc_trace_new(trace, mem)
|
|
|
|
#define _gst_alloc_trace_free(trace, mem)
|
|
|
|
#define _gst_alloc_trace_dump()
|
2003-02-10 20:32:32 +00:00
|
|
|
|
2001-12-15 18:15:13 +00:00
|
|
|
#endif /* GST_DISABLE_TRACE */
|
2001-06-25 20:36:02 +00:00
|
|
|
|
2002-07-08 19:07:30 +00:00
|
|
|
G_END_DECLS
|
2004-03-15 14:43:35 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
#endif /* __GST_TRACE_H__ */
|