summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5187a43)
raw | patch | inline | side by side (parent: 5187a43)
author | Rob Clark <rob@ti.com> | |
Sun, 4 Apr 2010 14:14:34 +0000 (09:14 -0500) | ||
committer | Nikhil Devshatwar <a0132237@ti.com> | |
Wed, 15 May 2013 11:20:48 +0000 (16:50 +0530) |
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
Incorporate modifications by Ricardo Salveti de Araujo in order to work out
some errors from recent versions of GStreamer.
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
Incorporate modifications by Ricardo Salveti de Araujo in order to work out
some errors from recent versions of GStreamer.
gst/gstinfo.c | patch | blob | history | |
gst/gstinfo.h | patch | blob | history |
diff --git a/gst/gstinfo.c b/gst/gstinfo.c
index 266feed04a5bb54d80926dbf925565bf4d5e2649..226876822adb5d8601a14464eb80d105801fcb00 100644 (file)
--- a/gst/gstinfo.c
+++ b/gst/gstinfo.c
/* we can't do this further above, because we initialize the GST_CAT_DEFAULT struct */
#define GST_CAT_DEFAULT _GST_CAT_DEBUG
+
+/**
+ * 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:
* @category: category to log
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
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);
return gst_structure_to_string (s);
}
-static gchar *
+gchar *
gst_debug_print_object (gpointer ptr)
{
GObject *object = (GObject *) 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 f841cd7e2bf4c5a789cf484b3669b5f306c63c69..3abdb2dd42512de0733a3ca29224fa11169f9762 100644 (file)
--- a/gst/gstinfo.h
+++ b/gst/gstinfo.h
const gchar * name;
const gchar * description;
+
+ void *ext; /**< for use by LD_PRELOADED trace extension */
};
/********** some convenience macros for debugging **********/
/* 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
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,
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,
_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,
* 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 */
#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