2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
5 * gsttrace.h: Header for tracing functions (deprecated)
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
24 #ifndef __GST_TRACE_H__
25 #define __GST_TRACE_H__
28 #include <gst/gstconfig.h>
34 * @GST_ALLOC_TRACE_NONE: No tracing specified or desired.
35 * @GST_ALLOC_TRACE_LIVE: Trace number of non-freed memory.
36 * @GST_ALLOC_TRACE_MEM_LIVE: Trace pointers of unfreed memory.
38 * Flags indicating which tracing feature to enable.
41 GST_ALLOC_TRACE_NONE = 0,
42 GST_ALLOC_TRACE_LIVE = (1 << 0),
43 GST_ALLOC_TRACE_MEM_LIVE = (1 << 1)
46 typedef struct _GstAllocTrace GstAllocTrace;
50 * @name: The name of the tracing object
51 * @flags: Flags for this object
52 * @offset: offset of the GType
53 * @live: counter for live memory
54 * @mem_live: list with pointers to unfreed memory
56 * The main tracing object
58 struct _GstAllocTrace {
67 #ifndef GST_DISABLE_TRACE
69 GST_EXPORT GMutex _gst_trace_mutex;
71 void _priv_gst_alloc_trace_initialize (void);
72 void _priv_gst_alloc_trace_deinit (void);
73 GstAllocTrace* _priv_gst_alloc_trace_register (const gchar *name, goffset offset);
75 void _priv_gst_alloc_trace_dump (void);
77 #ifndef GST_DISABLE_ALLOC_TRACE
79 * gst_alloc_trace_register:
80 * @name: The name of the tracer object
82 * Register a new alloc tracer with the given name
84 #define _gst_alloc_trace_register(name,offset) _priv_gst_alloc_trace_register (name,offset)
86 #define _gst_alloc_trace_dump _priv_gst_alloc_trace_dump
89 * gst_alloc_trace_new:
90 * @trace: The tracer to use
91 * @mem: The memory allocated
93 * Use the tracer to trace a new memory allocation
95 #define _gst_alloc_trace_new(trace, mem) \
97 if (G_UNLIKELY ((trace)->flags)) { \
98 g_mutex_lock (&_gst_trace_mutex); \
99 if ((trace)->flags & GST_ALLOC_TRACE_LIVE) \
101 if ((trace)->flags & GST_ALLOC_TRACE_MEM_LIVE) \
102 (trace)->mem_live = \
103 g_slist_prepend ((trace)->mem_live, mem); \
104 g_mutex_unlock (&_gst_trace_mutex); \
109 * gst_alloc_trace_free:
110 * @trace: The tracer to use
111 * @mem: The memory that is freed
113 * Trace a memory free operation
115 #define _gst_alloc_trace_free(trace, mem) \
117 if (G_UNLIKELY ((trace)->flags)) { \
118 g_mutex_lock (&_gst_trace_mutex); \
119 if ((trace)->flags & GST_ALLOC_TRACE_LIVE) \
121 if ((trace)->flags & GST_ALLOC_TRACE_MEM_LIVE) \
122 (trace)->mem_live = \
123 g_slist_remove ((trace)->mem_live, mem); \
124 g_mutex_unlock (&_gst_trace_mutex); \
129 #define _gst_alloc_trace_register(name) (NULL)
130 #define _gst_alloc_trace_new(trace, mem)
131 #define _gst_alloc_trace_free(trace, mem)
132 #define _gst_alloc_trace_dump()
135 #else /* GST_DISABLE_TRACE */
137 #define _gst_alloc_trace_register(name, offset) (NULL)
138 #define _gst_alloc_trace_new(trace, mem)
139 #define _gst_alloc_trace_free(trace, mem)
140 #define _gst_alloc_trace_dump()
142 #endif /* GST_DISABLE_TRACE */
146 #endif /* __GST_TRACE_H__ */