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., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
24 #ifndef __GST_TRACE_H__
25 #define __GST_TRACE_H__
33 * @GST_ALLOC_TRACE_NONE: No tracing specified or desired.
34 * @GST_ALLOC_TRACE_LIVE: Trace number of non-freed memory.
35 * @GST_ALLOC_TRACE_MEM_LIVE: Trace pointers of unfreed memory.
37 * Flags indicating which tracing feature to enable.
40 GST_ALLOC_TRACE_NONE = 0,
41 GST_ALLOC_TRACE_LIVE = (1 << 0),
42 GST_ALLOC_TRACE_MEM_LIVE = (1 << 1)
45 typedef struct _GstAllocTrace GstAllocTrace;
49 * @name: The name of the tracing object
50 * @flags: Flags for this object
51 * @offset: offset of the GType
52 * @live: counter for live memory
53 * @mem_live: list with pointers to unfreed memory
55 * The main tracing object
57 struct _GstAllocTrace {
66 #ifndef GST_DISABLE_TRACE
68 GST_EXPORT GMutex _gst_trace_mutex;
70 void _priv_gst_alloc_trace_initialize (void);
71 void _priv_gst_alloc_trace_deinit (void);
72 GstAllocTrace* _priv_gst_alloc_trace_register (const gchar *name, goffset offset);
74 void _priv_gst_alloc_trace_dump (void);
76 #ifndef GST_DISABLE_ALLOC_TRACE
78 * gst_alloc_trace_register:
79 * @name: The name of the tracer object
81 * Register a new alloc tracer with the given name
83 #define _gst_alloc_trace_register(name,offset) _priv_gst_alloc_trace_register (name,offset)
85 #define _gst_alloc_trace_dump _priv_gst_alloc_trace_dump
88 * gst_alloc_trace_new:
89 * @trace: The tracer to use
90 * @mem: The memory allocated
92 * Use the tracer to trace a new memory allocation
94 #define _gst_alloc_trace_new(trace, mem) \
96 if (G_UNLIKELY ((trace)->flags)) { \
97 g_mutex_lock (&_gst_trace_mutex); \
98 if ((trace)->flags & GST_ALLOC_TRACE_LIVE) \
100 if ((trace)->flags & GST_ALLOC_TRACE_MEM_LIVE) \
101 (trace)->mem_live = \
102 g_slist_prepend ((trace)->mem_live, mem); \
103 g_mutex_unlock (&_gst_trace_mutex); \
108 * gst_alloc_trace_free:
109 * @trace: The tracer to use
110 * @mem: The memory that is freed
112 * Trace a memory free operation
114 #define _gst_alloc_trace_free(trace, mem) \
116 if (G_UNLIKELY ((trace)->flags)) { \
117 g_mutex_lock (&_gst_trace_mutex); \
118 if ((trace)->flags & GST_ALLOC_TRACE_LIVE) \
120 if ((trace)->flags & GST_ALLOC_TRACE_MEM_LIVE) \
121 (trace)->mem_live = \
122 g_slist_remove ((trace)->mem_live, mem); \
123 g_mutex_unlock (&_gst_trace_mutex); \
128 #define _gst_alloc_trace_register(name) (NULL)
129 #define _gst_alloc_trace_new(trace, mem)
130 #define _gst_alloc_trace_free(trace, mem)
131 #define _gst_alloc_trace_dump()
134 #else /* GST_DISABLE_TRACE */
136 #define _gst_alloc_trace_register(name, offset) (NULL)
137 #define _gst_alloc_trace_new(trace, mem)
138 #define _gst_alloc_trace_free(trace, mem)
139 #define _gst_alloc_trace_dump()
141 #endif /* GST_DISABLE_TRACE */
145 #endif /* __GST_TRACE_H__ */