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__
31 #ifndef GST_DISABLE_TRACE
33 typedef struct _GstTrace GstTrace;
34 typedef struct _GstTraceEntry GstTraceEntry;
39 * Opaque #GstTrace structure.
43 /* where this trace is going */
47 /* current buffer, size, head offset */
53 struct _GstTraceEntry {
62 GstTrace* gst_trace_new (gchar *filename, gint size);
64 void gst_trace_destroy (GstTrace *trace);
65 void gst_trace_flush (GstTrace *trace);
66 void gst_trace_text_flush (GstTrace *trace);
71 * Retrieve the buffer size of @trace.
73 #define gst_trace_get_size(trace) ((trace)->bufsize)
75 * gst_trace_get_offset:
78 * Retrieve the current buffer offset of @trace.
80 #define gst_trace_get_offset(trace) ((trace)->bufoffset)
82 * gst_trace_get_remaining:
85 * Retrieve the remaining size in the @trace buffer.
87 #define gst_trace_get_remaining(trace) ((trace)->bufsize - (trace)->bufoffset)
88 void gst_trace_set_default (GstTrace *trace);
90 void _gst_trace_add_entry (GstTrace *trace, guint32 seq,
91 guint32 data, gchar *msg);
93 void gst_trace_read_tsc (gint64 *dst);
98 * @GST_ALLOC_TRACE_LIVE: Trace number of non-freed memory
99 * @GST_ALLOC_TRACE_MEM_LIVE: trace pointers of unfreed memory
101 * Flags indicating which tracing feature to enable.
104 GST_ALLOC_TRACE_LIVE = (1 << 0),
105 GST_ALLOC_TRACE_MEM_LIVE = (1 << 1)
106 } GstAllocTraceFlags;
108 typedef struct _GstAllocTrace GstAllocTrace;
112 * @name: The name of the tracing object
113 * @flags: Flags for this object
114 * @live: counter for live memory
115 * @mem_live: list with pointers to unfreed memory
117 * The main tracing object
119 struct _GstAllocTrace {
127 gboolean gst_alloc_trace_available (void);
128 G_CONST_RETURN GList* gst_alloc_trace_list (void);
129 GstAllocTrace* _gst_alloc_trace_register (const gchar *name);
131 int gst_alloc_trace_live_all (void);
132 void gst_alloc_trace_print_all (void);
133 void gst_alloc_trace_print_live (void);
134 void gst_alloc_trace_set_flags_all (GstAllocTraceFlags flags);
136 GstAllocTrace* gst_alloc_trace_get (const gchar *name);
137 void gst_alloc_trace_print (const GstAllocTrace *trace);
138 void gst_alloc_trace_set_flags (GstAllocTrace *trace, GstAllocTraceFlags flags);
141 #ifndef GST_DISABLE_ALLOC_TRACE
143 * gst_alloc_trace_register:
144 * @name: The name of the tracer object
146 * Register a new alloc tracer with the given name
148 #define gst_alloc_trace_register(name) _gst_alloc_trace_register (name);
151 * gst_alloc_trace_new:
152 * @trace: The tracer to use
153 * @mem: The memory allocated
155 * Use the tracer to trace a new memory allocation
157 #define gst_alloc_trace_new(trace, mem) \
159 if ((trace)->flags & GST_ALLOC_TRACE_LIVE) \
161 if ((trace)->flags & GST_ALLOC_TRACE_MEM_LIVE) \
162 (trace)->mem_live = \
163 g_slist_prepend ((trace)->mem_live, mem); \
167 * gst_alloc_trace_free:
168 * @trace: The tracer to use
169 * @mem: The memory that is freed
171 * Trace a memory free operation
173 #define gst_alloc_trace_free(trace, mem) \
175 if ((trace)->flags & GST_ALLOC_TRACE_LIVE) \
177 if ((trace)->flags & GST_ALLOC_TRACE_MEM_LIVE) \
178 (trace)->mem_live = \
179 g_slist_remove ((trace)->mem_live, mem); \
183 #define gst_alloc_trace_register(name) (NULL)
184 #define gst_alloc_trace_new(trace, mem)
185 #define gst_alloc_trace_free(trace, mem)
189 extern gint _gst_trace_on;
191 * gst_trace_add_entry:
192 * @trace: a #GstTrace
193 * @seq: a sequence number
194 * @data: the data to trace
195 * @msg: the trace message
197 * Add an entry to @trace with sequence number @seq, @data and @msg.
198 * If @trace is NULL, the entry will be added to the default #GstTrace.
200 #define gst_trace_add_entry(trace,seq,data,msg) \
201 if (_gst_trace_on) { \
202 _gst_trace_add_entry(trace,(guint32)seq,(guint32)data,msg); \
205 #else /* GST_DISABLE_TRACE */
207 #if defined _GNUC_ && _GNUC_ >= 3
208 #pragma GCC poison gst_trace_new
209 #pragma GCC poison gst_trace_destroy
210 #pragma GCC poison gst_trace_flush
211 #pragma GCC poison gst_trace_text_flush
212 #pragma GCC poison gst_trace_get_size
213 #pragma GCC poison gst_trace_get_offset
214 #pragma GCC poison gst_trace_get_remaining
215 #pragma GCC poison gst_trace_set_default
216 #pragma GCC poison _gst_trace_add_entry
217 #pragma GCC poison gst_trace_read_tsc
218 #pragma GCC poison gst_trace_add_entry
221 #define gst_alloc_trace_register(name)
222 #define gst_alloc_trace_new(trace, mem)
223 #define gst_alloc_trace_free(trace, mem)
225 #define gst_alloc_trace_available() (FALSE)
226 #define gst_alloc_trace_list() (NULL)
227 #define _gst_alloc_trace_register(name) (NULL)
229 #define gst_alloc_trace_print_all()
230 #define gst_alloc_trace_set_flags_all(flags)
232 #define gst_alloc_trace_get(name) (NULL)
233 #define gst_alloc_trace_print(trace)
234 #define gst_alloc_trace_set_flags(trace,flags)
236 #define gst_trace_add_entry(trace,seq,data,msg)
238 #endif /* GST_DISABLE_TRACE */
242 #endif /* __GST_TRACE_H__ */