|
1 /* GStreamer |
|
2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu> |
|
3 * 2000 Wim Taymans <wtay@chello.be> |
|
4 * |
|
5 * gsttrace.h: Header for tracing functions (deprecated) |
|
6 * |
|
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. |
|
11 * |
|
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. |
|
16 * |
|
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. |
|
21 */ |
|
22 |
|
23 |
|
24 #ifndef __GST_TRACE_H__ |
|
25 #define __GST_TRACE_H__ |
|
26 |
|
27 #include <glib.h> |
|
28 |
|
29 G_BEGIN_DECLS |
|
30 |
|
31 /** |
|
32 * GstAllocTraceFlags: |
|
33 * @GST_ALLOC_TRACE_LIVE: Trace number of non-freed memory |
|
34 * @GST_ALLOC_TRACE_MEM_LIVE: trace pointers of unfreed memory |
|
35 * |
|
36 * Flags indicating which tracing feature to enable. |
|
37 */ |
|
38 typedef enum { |
|
39 GST_ALLOC_TRACE_LIVE = (1 << 0), |
|
40 GST_ALLOC_TRACE_MEM_LIVE = (1 << 1) |
|
41 } GstAllocTraceFlags; |
|
42 |
|
43 typedef struct _GstAllocTrace GstAllocTrace; |
|
44 |
|
45 /** |
|
46 * GstAllocTrace: |
|
47 * @name: The name of the tracing object |
|
48 * @flags: Flags for this object |
|
49 * @live: counter for live memory |
|
50 * @mem_live: list with pointers to unfreed memory |
|
51 * |
|
52 * The main tracing object |
|
53 */ |
|
54 struct _GstAllocTrace { |
|
55 gchar *name; |
|
56 gint flags; |
|
57 |
|
58 gint live; |
|
59 GSList *mem_live; |
|
60 }; |
|
61 |
|
62 #ifndef GST_DISABLE_TRACE |
|
63 |
|
64 typedef struct _GstTrace GstTrace; |
|
65 typedef struct _GstTraceEntry GstTraceEntry; |
|
66 |
|
67 /** |
|
68 * GstTrace: |
|
69 * |
|
70 * Opaque #GstTrace structure. |
|
71 */ |
|
72 struct _GstTrace { |
|
73 /*< private >*/ |
|
74 /* where this trace is going */ |
|
75 gchar *filename; |
|
76 int fd; |
|
77 |
|
78 /* current buffer, size, head offset */ |
|
79 GstTraceEntry *buf; |
|
80 gint bufsize; |
|
81 gint bufoffset; |
|
82 }; |
|
83 |
|
84 struct _GstTraceEntry { |
|
85 gint64 timestamp; |
|
86 guint32 sequence; |
|
87 guint32 data; |
|
88 gchar message[112]; |
|
89 }; |
|
90 #ifdef __SYMBIAN32__ |
|
91 IMPORT_C |
|
92 #endif |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 GstTrace* gst_trace_new (gchar *filename, gint size); |
|
98 #ifdef __SYMBIAN32__ |
|
99 IMPORT_C |
|
100 #endif |
|
101 |
|
102 |
|
103 void gst_trace_destroy (GstTrace *trace); |
|
104 #ifdef __SYMBIAN32__ |
|
105 IMPORT_C |
|
106 #endif |
|
107 |
|
108 void gst_trace_flush (GstTrace *trace); |
|
109 #ifdef __SYMBIAN32__ |
|
110 IMPORT_C |
|
111 #endif |
|
112 |
|
113 void gst_trace_text_flush (GstTrace *trace); |
|
114 /** |
|
115 * gst_trace_get_size: |
|
116 * @trace: a #GstTrace |
|
117 * |
|
118 * Retrieve the buffer size of @trace. |
|
119 */ |
|
120 #define gst_trace_get_size(trace) ((trace)->bufsize) |
|
121 /** |
|
122 * gst_trace_get_offset: |
|
123 * @trace: a #GstTrace |
|
124 * |
|
125 * Retrieve the current buffer offset of @trace. |
|
126 */ |
|
127 #define gst_trace_get_offset(trace) ((trace)->bufoffset) |
|
128 /** |
|
129 * gst_trace_get_remaining: |
|
130 * @trace: a #GstTrace |
|
131 * |
|
132 * Retrieve the remaining size in the @trace buffer. |
|
133 */ |
|
134 #define gst_trace_get_remaining(trace) ((trace)->bufsize - (trace)->bufoffset) |
|
135 void gst_trace_set_default (GstTrace *trace); |
|
136 #ifdef __SYMBIAN32__ |
|
137 IMPORT_C |
|
138 #endif |
|
139 |
|
140 |
|
141 void _gst_trace_add_entry (GstTrace *trace, guint32 seq, |
|
142 guint32 data, gchar *msg); |
|
143 #ifdef __SYMBIAN32__ |
|
144 IMPORT_C |
|
145 #endif |
|
146 |
|
147 |
|
148 void gst_trace_read_tsc (gint64 *dst); |
|
149 #ifdef __SYMBIAN32__ |
|
150 IMPORT_C |
|
151 #endif |
|
152 |
|
153 |
|
154 |
|
155 gboolean gst_alloc_trace_available (void); |
|
156 #ifdef __SYMBIAN32__ |
|
157 IMPORT_C |
|
158 #endif |
|
159 |
|
160 G_CONST_RETURN GList* gst_alloc_trace_list (void); |
|
161 #ifdef __SYMBIAN32__ |
|
162 IMPORT_C |
|
163 #endif |
|
164 |
|
165 GstAllocTrace* _gst_alloc_trace_register (const gchar *name); |
|
166 #ifdef __SYMBIAN32__ |
|
167 IMPORT_C |
|
168 #endif |
|
169 |
|
170 |
|
171 int gst_alloc_trace_live_all (void); |
|
172 #ifdef __SYMBIAN32__ |
|
173 IMPORT_C |
|
174 #endif |
|
175 |
|
176 void gst_alloc_trace_print_all (void); |
|
177 #ifdef __SYMBIAN32__ |
|
178 IMPORT_C |
|
179 #endif |
|
180 |
|
181 void gst_alloc_trace_print_live (void); |
|
182 #ifdef __SYMBIAN32__ |
|
183 IMPORT_C |
|
184 #endif |
|
185 |
|
186 void gst_alloc_trace_set_flags_all (GstAllocTraceFlags flags); |
|
187 #ifdef __SYMBIAN32__ |
|
188 IMPORT_C |
|
189 #endif |
|
190 |
|
191 |
|
192 GstAllocTrace* gst_alloc_trace_get (const gchar *name); |
|
193 #ifdef __SYMBIAN32__ |
|
194 IMPORT_C |
|
195 #endif |
|
196 |
|
197 void gst_alloc_trace_print (const GstAllocTrace *trace); |
|
198 #ifdef __SYMBIAN32__ |
|
199 IMPORT_C |
|
200 #endif |
|
201 |
|
202 void gst_alloc_trace_set_flags (GstAllocTrace *trace, GstAllocTraceFlags flags); |
|
203 |
|
204 |
|
205 #ifndef GST_DISABLE_ALLOC_TRACE |
|
206 /** |
|
207 * gst_alloc_trace_register: |
|
208 * @name: The name of the tracer object |
|
209 * |
|
210 * Register a new alloc tracer with the given name |
|
211 */ |
|
212 #define gst_alloc_trace_register(name) _gst_alloc_trace_register (name); |
|
213 |
|
214 /** |
|
215 * gst_alloc_trace_new: |
|
216 * @trace: The tracer to use |
|
217 * @mem: The memory allocated |
|
218 * |
|
219 * Use the tracer to trace a new memory allocation |
|
220 */ |
|
221 #define gst_alloc_trace_new(trace, mem) \ |
|
222 G_STMT_START { \ |
|
223 if ((trace)->flags & GST_ALLOC_TRACE_LIVE) \ |
|
224 (trace)->live++; \ |
|
225 if ((trace)->flags & GST_ALLOC_TRACE_MEM_LIVE) \ |
|
226 (trace)->mem_live = \ |
|
227 g_slist_prepend ((trace)->mem_live, mem); \ |
|
228 } G_STMT_END |
|
229 |
|
230 /** |
|
231 * gst_alloc_trace_free: |
|
232 * @trace: The tracer to use |
|
233 * @mem: The memory that is freed |
|
234 * |
|
235 * Trace a memory free operation |
|
236 */ |
|
237 #define gst_alloc_trace_free(trace, mem) \ |
|
238 G_STMT_START { \ |
|
239 if ((trace)->flags & GST_ALLOC_TRACE_LIVE) \ |
|
240 (trace)->live--; \ |
|
241 if ((trace)->flags & GST_ALLOC_TRACE_MEM_LIVE) \ |
|
242 (trace)->mem_live = \ |
|
243 g_slist_remove ((trace)->mem_live, mem); \ |
|
244 } G_STMT_END |
|
245 |
|
246 #else |
|
247 #define gst_alloc_trace_register(name) (NULL) |
|
248 #define gst_alloc_trace_new(trace, mem) |
|
249 #define gst_alloc_trace_free(trace, mem) |
|
250 #endif |
|
251 |
|
252 |
|
253 extern gint _gst_trace_on; |
|
254 /** |
|
255 * gst_trace_add_entry: |
|
256 * @trace: a #GstTrace |
|
257 * @seq: a sequence number |
|
258 * @data: the data to trace |
|
259 * @msg: the trace message |
|
260 * |
|
261 * Add an entry to @trace with sequence number @seq, @data and @msg. |
|
262 * If @trace is NULL, the entry will be added to the default #GstTrace. |
|
263 */ |
|
264 #define gst_trace_add_entry(trace,seq,data,msg) \ |
|
265 if (_gst_trace_on) { \ |
|
266 _gst_trace_add_entry(trace,(guint32)seq,(guint32)data,msg); \ |
|
267 } |
|
268 |
|
269 #else /* GST_DISABLE_TRACE */ |
|
270 |
|
271 #if defined _GNUC_ && _GNUC_ >= 3 |
|
272 #pragma GCC poison gst_trace_new |
|
273 #pragma GCC poison gst_trace_destroy |
|
274 #pragma GCC poison gst_trace_flush |
|
275 #pragma GCC poison gst_trace_text_flush |
|
276 #pragma GCC poison gst_trace_get_size |
|
277 #pragma GCC poison gst_trace_get_offset |
|
278 #pragma GCC poison gst_trace_get_remaining |
|
279 #pragma GCC poison gst_trace_set_default |
|
280 #pragma GCC poison _gst_trace_add_entry |
|
281 #pragma GCC poison gst_trace_read_tsc |
|
282 #pragma GCC poison gst_trace_add_entry |
|
283 #endif |
|
284 |
|
285 #define gst_alloc_trace_register(name) (NULL) |
|
286 #define gst_alloc_trace_new(trace, mem) |
|
287 #define gst_alloc_trace_free(trace, mem) |
|
288 |
|
289 #define gst_alloc_trace_available() (FALSE) |
|
290 #define gst_alloc_trace_list() (NULL) |
|
291 #define _gst_alloc_trace_register(name) (NULL) |
|
292 |
|
293 #define gst_alloc_trace_live_all() (0) |
|
294 #define gst_alloc_trace_print_all() |
|
295 #define gst_alloc_trace_print_live() |
|
296 #define gst_alloc_trace_set_flags_all(flags) |
|
297 |
|
298 #define gst_alloc_trace_get(name) (NULL) |
|
299 #define gst_alloc_trace_print(trace) |
|
300 #define gst_alloc_trace_set_flags(trace,flags) |
|
301 |
|
302 #define gst_trace_add_entry(trace,seq,data,msg) |
|
303 |
|
304 #endif /* GST_DISABLE_TRACE */ |
|
305 |
|
306 G_END_DECLS |
|
307 |
|
308 #endif /* __GST_TRACE_H__ */ |