summaryrefslogtreecommitdiff
path: root/gstreamer_ti_dm81xx/opensource_build/patchfiles/gstreamer-0.10.32/0002-Changes-to-make-it-possible-to-LD_PRELOAD-libttif.patch
blob: 817eae20533844b2f042395a8d7591493d3378fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
From ac55210758bdd06fe0dec6ef67a60a96a86b39f4 Mon Sep 17 00:00:00 2001
From: Rob Clark <rob@ti.com>
Date: Sun, 4 Apr 2010 09:14:34 -0500
Subject: [PATCH 2/5] Changes to make it possible to LD_PRELOAD libttif

1) if GST_USING_PRINTF_EXTENSION, then prepend the fmt string with "<%P> " and
pass object as a normal arg.  When using TTIF, you want the whole fmt string,
including the object name prefix, to be constant.  This way, only the fmt
string pointer needs to be logged.
2) GstDebugTraceLocation: small optimization to stash __FILE__, __LINE__, and
GST_FUNCTION together and pass as a single ptr.. the optimization is probably
lost in the noise with the default printf() based traces, but makes more of a
difference with faster trace systems
---
 gst/gstinfo.c |   64 +++++++++++++++++++++++++++++++++++++++++++++++-----
 gst/gstinfo.h |   70 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 123 insertions(+), 11 deletions(-)

diff --git a/gst/gstinfo.c b/gst/gstinfo.c
index 3688120..dfa8650 100644
--- a/gst/gstinfo.c
+++ b/gst/gstinfo.c
@@ -494,6 +494,31 @@ gst_path_basename (const gchar * file_name)
 #endif
 
 /**
+ * gst_debug_log2:
+ * @category: category to log
+ * @level: level of the message is in
+ * @location: the file, function name, and line number of the location that
+ *    emitted the message
+ * @object: the object this message relates to or NULL if none
+ * @format: a printf style format string
+ * @...: optional arguments for the format
+ *
+ * Logs the given message using the currently registered debugging handlers.
+ */
+void
+gst_debug_log2 (GstDebugCategory * category, GstDebugLevel level,
+    const GstDebugTraceLocation * location,
+    GObject * object, const gchar * format, ...)
+{
+  va_list var_args;
+
+  va_start (var_args, format);
+  gst_debug_log_valist2 (category, level, location, object, format, var_args);
+  va_end (var_args);
+}
+
+
+/**
  * gst_debug_log_valist:
  * @category: category to log
  * @level: level of the message is in
@@ -512,13 +537,39 @@ gst_debug_log_valist (GstDebugCategory * category, GstDebugLevel level,
     const gchar * file, const gchar * function, gint line,
     GObject * object, const gchar * format, va_list args)
 {
+  GstDebugTraceLocation location = {
+    .file = file,
+    .function = function,
+    .line = line
+  };
+  gst_debug_log_valist2 (category, level, &location, object, format, args);
+}
+
+/**
+ * gst_debug_log_valist2:
+ * @category: category to log
+ * @level: level of the message is in
+ * @location: the file, function name, and line number of the location that
+ *    emitted the message
+ * @object: the object this message relates to or NULL if none
+ * @format: a printf style format string
+ * @args: optional arguments for the format
+ *
+ * Logs the given message using the currently registered debugging handlers.
+ */
+void
+gst_debug_log_valist2 (GstDebugCategory * category, GstDebugLevel level,
+    const GstDebugTraceLocation * location,
+    GObject * object, const gchar * format, va_list args)
+{
   GstDebugMessage message;
   LogFuncEntry *entry;
   GSList *handler;
 
   g_return_if_fail (category != NULL);
-  g_return_if_fail (file != NULL);
-  g_return_if_fail (function != NULL);
+  g_return_if_fail (location != NULL);
+  g_return_if_fail (location->file != NULL);
+  g_return_if_fail (location->function != NULL);
   g_return_if_fail (format != NULL);
 
   /* The predefined macro __FILE__ is always the exact path given to the
@@ -536,8 +587,9 @@ gst_debug_log_valist (GstDebugCategory * category, GstDebugLevel level,
   while (handler) {
     entry = handler->data;
     handler = g_slist_next (handler);
-    entry->func (category, level, file, function, line, object, &message,
-        entry->user_data);
+    // TODO: change GstLogFunction and pass GstDebugTraceLocation ptr instead..
+    entry->func (category, level, location->file, location->function,
+        location->line, object, &message, entry->user_data);
   }
   g_free (message.message);
   va_end (message.arguments);
@@ -610,7 +662,7 @@ gst_info_structure_to_string (GstStructure * s)
     return gst_structure_to_string (s);
 }
 
-static gchar *
+gchar *
 gst_debug_print_object (gpointer ptr)
 {
   GObject *object = (GObject *) ptr;
@@ -708,7 +760,7 @@ gst_debug_print_object (gpointer ptr)
 
 #ifdef HAVE_PRINTF_EXTENSION
 
-static gchar *
+gchar *
 gst_debug_print_segment (gpointer ptr)
 {
   GstSegment *segment = (GstSegment *) ptr;
diff --git a/gst/gstinfo.h b/gst/gstinfo.h
index 7c2d86f..24ca706 100644
--- a/gst/gstinfo.h
+++ b/gst/gstinfo.h
@@ -177,6 +177,8 @@ struct _GstDebugCategory {
 
   const gchar *		name;
   const gchar *		description;
+
+  void *ext;                /**< for use by LD_PRELOADED trace extension */
 };
 
 /********** some convenience macros for debugging **********/
@@ -260,6 +262,14 @@ typedef void (*GstLogFunction)  (GstDebugCategory * category,
 /* FIXME 0.11: move this into private headers */
 void            _gst_debug_init (void);
 
+typedef struct {
+	const gchar *file;
+	const gchar *function;
+	const gint   line;
+} GstDebugTraceLocation;
+
+#define GST_DEBUG_TRACE_LOCATION() \
+	{ __FILE__, GST_FUNCTION, __LINE__ }
 
 #ifdef GST_USING_PRINTF_EXTENSION
 
@@ -273,6 +283,13 @@ void		    gst_debug_log            (GstDebugCategory * category,
                                           const gchar      * format,
                                           ...) G_GNUC_NO_INSTRUMENT;
 
+void		    gst_debug_log2           (GstDebugCategory * category,
+                                          GstDebugLevel      level,
+                                          const GstDebugTraceLocation *location,
+                                          GObject          * object,
+                                          const gchar      * format,
+                                          ...) G_GNUC_NO_INSTRUMENT;
+
 #else /* GST_USING_PRINTF_EXTENSION */
 
 void		    gst_debug_log            (GstDebugCategory * category,
@@ -284,6 +301,13 @@ void		    gst_debug_log            (GstDebugCategory * category,
                                           const gchar      * format,
                                           ...) G_GNUC_PRINTF (7, 8) G_GNUC_NO_INSTRUMENT;
 
+void		    gst_debug_log2           (GstDebugCategory * category,
+                                          GstDebugLevel      level,
+                                          const GstDebugTraceLocation *location,
+                                          GObject          * object,
+                                          const gchar      * format,
+                                          ...) G_GNUC_PRINTF (5, 6) G_GNUC_NO_INSTRUMENT;
+
 #endif /* GST_USING_PRINTF_EXTENSION */
 
 void            gst_debug_log_valist     (GstDebugCategory * category,
@@ -321,8 +345,21 @@ G_CONST_RETURN gchar *
 	_gst_debug_nameof_funcptr	(GstDebugFuncPtr	func) G_GNUC_NO_INSTRUMENT;
 
 
+void            gst_debug_log_valist2    (GstDebugCategory * category,
+                                          GstDebugLevel      level,
+                                          const GstDebugTraceLocation *location,
+                                          GObject          * object,
+                                          const gchar      * format,
+                                          va_list            args) G_GNUC_NO_INSTRUMENT;
+
 const gchar   * gst_debug_message_get    (GstDebugMessage  * message);
 
+gchar *         gst_debug_print_object (gpointer ptr);
+
+#ifdef HAVE_PRINTF_EXTENSION
+gchar *         gst_debug_print_segment (gpointer ptr);
+#endif
+
 void            gst_debug_log_default    (GstDebugCategory * category,
                                           GstDebugLevel      level,
                                           const gchar      * file,
@@ -495,19 +532,41 @@ GST_EXPORT GstDebugLevel            __gst_debug_min;
  * debugging messages. You will probably want to use one of the ones described
  * below.
  */
+#if defined(GST_USING_PRINTF_EXTENSION) && defined(G_HAVE_GNUC_VARARGS)
+#define GST_CAT_LEVEL_LOG_obj(cat,level,object,str,args...) G_STMT_START{  \
+  if (G_UNLIKELY (level <= __gst_debug_min)) {                             \
+    const GstDebugTraceLocation loc = GST_DEBUG_TRACE_LOCATION();          \
+    gst_debug_log2 ((cat), (level), &loc, NULL, "%"GST_PTR_FORMAT" "str,   \
+        (object), ##args );                                                \
+  }                                                                        \
+}G_STMT_END
+#define GST_CAT_LEVEL_LOG_noobj(cat,level,object,str,args...) G_STMT_START{\
+  if (G_UNLIKELY (level <= __gst_debug_min)) {                             \
+    const GstDebugTraceLocation loc = GST_DEBUG_TRACE_LOCATION();          \
+    gst_debug_log2 ((cat), (level), &loc, NULL, (str), ##args );           \
+  }                                                                        \
+}G_STMT_END
+#else
+#  define GST_CAT_LEVEL_LOG_obj   GST_CAT_LEVEL_LOG
+#  define GST_CAT_LEVEL_LOG_noobj GST_CAT_LEVEL_LOG
+#endif
+
+
 #ifdef G_HAVE_ISO_VARARGS
 #define GST_CAT_LEVEL_LOG(cat,level,object,...) G_STMT_START{		\
-  if (G_UNLIKELY (level <= __gst_debug_min)) {						\
-    gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__,	\
-        (GObject *) (object), __VA_ARGS__);				\
+  if (G_UNLIKELY (level <= __gst_debug_min)) {	\
+	const GstDebugTraceLocation loc = GST_DEBUG_TRACE_LOCATION();	\
+    gst_debug_log2 ((cat), (level), &loc, (GObject *) (object),		\
+            __VA_ARGS__);											\
   }									\
 }G_STMT_END
 #else /* G_HAVE_GNUC_VARARGS */
 #ifdef G_HAVE_GNUC_VARARGS
 #define GST_CAT_LEVEL_LOG(cat,level,object,args...) G_STMT_START{	\
   if (G_UNLIKELY (level <= __gst_debug_min)) {						\
-    gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__,	\
-        (GObject *) (object), ##args );					\
+    const GstDebugTraceLocation loc = GST_DEBUG_TRACE_LOCATION();	\
+    gst_debug_log2 ((cat), (level), &loc, (GObject *) (object),		\
+            ##args );											    \
   }									\
 }G_STMT_END
 #else /* no variadic macros, use inline */
@@ -1244,6 +1303,7 @@ GST_TRACE (const char *format, ...)
 
 #if defined(__GNUC__) && __GNUC__ >= 3
 #  pragma GCC poison gst_debug_log
+#  pragma GCC poison gst_debug_log2
 #  pragma GCC poison gst_debug_log_valist
 #  pragma GCC poison _gst_debug_category_new
 #endif
-- 
1.7.0.4