diff options
author | Tim-Philipp Müller <tim@centricular.net> | 2013-03-30 17:20:13 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim.muller@collabora.co.uk> | 2013-04-12 23:05:57 +0100 |
commit | 7b1994428074a05795d7fe4418e29f921c2c0a09 (patch) | |
tree | b62f15cee529449e0aa2d1685ff5fec7f0c6e45d | |
parent | 8fc876f09fb4f76902cedcb2edb650fad9f76021 (diff) |
info: use new internal printf for debug message printing
and remove all the printf extension/specifier stuff for
the system printf. Next we need to add back the custom
specifiers to our own printf implementation.
https://bugzilla.gnome.org/show_bug.cgi?id=613081
-rw-r--r-- | configure.ac | 19 | ||||
-rw-r--r-- | docs/gst/gstreamer-sections.txt | 1 | ||||
-rw-r--r-- | gst/gstconfig.h.in | 49 | ||||
-rw-r--r-- | gst/gstelement.c | 11 | ||||
-rw-r--r-- | gst/gstelement.h | 2 | ||||
-rw-r--r-- | gst/gstinfo.c | 63 | ||||
-rw-r--r-- | gst/gstinfo.h | 31 |
7 files changed, 43 insertions, 133 deletions
diff --git a/configure.ac b/configure.ac index 23a2055e7..26ceca2c0 100644 --- a/configure.ac +++ b/configure.ac @@ -521,25 +521,6 @@ AM_CONDITIONAL(GST_HAVE_MONOTONIC_CLOCK, test "$gst_cv_monotonic_clock" = "yes") dnl Check for a way to display the function name in debug output AG_GST_CHECK_FUNCTION -dnl test for register_printf_specifier or register_printf_function -AC_CHECK_FUNCS([register_printf_specifier register_printf_function], - [HAVE_PRINTF_EXTENSION=yes]) - -if test "$HAVE_PRINTF_EXTENSION" = yes; then - GST_PRINTF_EXTENSION_POINTER_FORMAT_DEFINE="#define GST_PTR_FORMAT \"P\"" - GST_PRINTF_EXTENSION_SEGMENT_FORMAT_DEFINE="#define GST_SEGMENT_FORMAT \"Q\"" - GST_USING_PRINTF_EXTENSION_DEFINE="#define GST_USING_PRINTF_EXTENSION" - AC_DEFINE(HAVE_PRINTF_EXTENSION, 1, - [Defined if we have printf specifier extensions available]) -else - GST_PRINTF_EXTENSION_POINTER_FORMAT_DEFINE="#define GST_PTR_FORMAT \"p\"" - GST_PRINTF_EXTENSION_SEGMENT_FORMAT_DEFINE="#define GST_SEGMENT_FORMAT \"p\"" - GST_USING_PRINTF_EXTENSION_DEFINE="#undef GST_USING_PRINTF_EXTENSION" -fi -AC_SUBST(GST_PRINTF_EXTENSION_POINTER_FORMAT_DEFINE) -AC_SUBST(GST_PRINTF_EXTENSION_SEGMENT_FORMAT_DEFINE) -AC_SUBST(GST_USING_PRINTF_EXTENSION_DEFINE) - dnl test if we have dladdr(); we use it for debugging; see gst/gstinfo.c save_cflags="$CFLAGS" CFLAGS="$CFLAGS -D_GNU_SOURCE" diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 5183a125b..87eaa6bf7 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -667,7 +667,6 @@ GST_PLUGIN_EXPORT GST_PADDING GST_PADDING_LARGE GST_PADDING_INIT -GST_USING_PRINTF_EXTENSION </SECTION> <SECTION> diff --git a/gst/gstconfig.h.in b/gst/gstconfig.h.in index b94748332..e6ea08d0b 100644 --- a/gst/gstconfig.h.in +++ b/gst/gstconfig.h.in @@ -114,55 +114,6 @@ /* Configures the use of external plugins */ @GST_DISABLE_PLUGIN_DEFINE@ -/* printf extension format */ -/** - * GST_PTR_FORMAT: - * - * printf format type used to debug GStreamer types. - * This can only be used on types whose size is >= sizeof(gpointer). - */ -@GST_PRINTF_EXTENSION_POINTER_FORMAT_DEFINE@ -/** - * GST_SEGMENT_FORMAT: - * - * printf format type used to debug GStreamer segments. - * This can only be used on pointers to GstSegment structures. - */ -@GST_PRINTF_EXTENSION_SEGMENT_FORMAT_DEFINE@ - -/* whether or not GST_PTR_FORMAT or GST_SEGMENT_FORMAT are using - * the printf extension mechanism. This is for internal use in our - * header files so we know whether we can use G_GNUC_PRINTF or not */ -@GST_USING_PRINTF_EXTENSION_DEFINE@ - -/* GST_DISABLE_PRINTF_EXTENSION: - * - * Define this to debug your debug log messages and make gcc spew warnings - * if printf format string and arguments don't match up (this is usually - * not the case when libc and gcc are used because printf format warnings - * have to be disabled when the printf extension mechanism is in use). - * - * Note that using this option disables 'pretty logging' of GStreamer objects - * like caps, tags, structures, events, pads etc., so that only their address - * will be printed in the log. - * - * This define only disables use of the special registered printf format - * extensions in the code compiled with it defined. It does not stop - * GStreamer from registering these extensions in the first place if it - * was compiled against a libc that supports this. - * - * (not official API) - */ -/* If GLib is not using the system printf, we can't use the registered - * extensions because the GLib-internal printf won't know how to parse them */ -#if defined(GST_DISABLE_PRINTF_EXTENSION) || !defined(GLIB_USING_SYSTEM_PRINTF) - #undef GST_PTR_FORMAT - #define GST_PTR_FORMAT "p" - #undef GST_SEGMENT_FORMAT - #define GST_SEGMENT_FORMAT "p" - #undef GST_USING_PRINTF_EXTENSION -#endif - /* whether or not the CPU supports unaligned access */ @GST_HAVE_UNALIGNED_ACCESS_DEFINE@ diff --git a/gst/gstelement.c b/gst/gstelement.c index bff97ad77..a46cab593 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -97,6 +97,8 @@ #include "gst-i18n-lib.h" #include "glib-compat-private.h" +#include "printf/printf.h" + /* Element signals and args */ enum { @@ -1745,6 +1747,7 @@ _gst_element_error_printf (const gchar * format, ...) { va_list args; gchar *buffer; + int len; if (format == NULL) return NULL; @@ -1752,8 +1755,14 @@ _gst_element_error_printf (const gchar * format, ...) return NULL; va_start (args, format); - buffer = g_strdup_vprintf (format, args); + + len = __gst_vasprintf (&buffer, format, args); + va_end (args); + + if (len < 0) + buffer = NULL; + return buffer; } diff --git a/gst/gstelement.h b/gst/gstelement.h index 499e60a8c..15d4c751d 100644 --- a/gst/gstelement.h +++ b/gst/gstelement.h @@ -774,7 +774,7 @@ gboolean gst_element_post_message (GstElement * element, G /* error handling */ /* gcc versions < 3.3 warn about NULL being passed as format to printf */ -#if (defined(GST_USING_PRINTF_EXTENSION) || !defined(__GNUC__) || (__GNUC__ < 3) || (__GNUC__ == 3 && __GNUC_MINOR__ < 3)) +#if (!defined(__GNUC__) || (__GNUC__ < 3) || (__GNUC__ == 3 && __GNUC_MINOR__ < 3)) gchar * _gst_element_error_printf (const gchar *format, ...); #else gchar * _gst_element_error_printf (const gchar *format, ...) G_GNUC_PRINTF (1, 2); diff --git a/gst/gstinfo.c b/gst/gstinfo.c index aa83b9c06..dc5a6779f 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -98,9 +98,6 @@ #ifdef HAVE_DLFCN_H # include <dlfcn.h> #endif -#ifdef HAVE_PRINTF_EXTENSION -# include <printf.h> -#endif #include <stdio.h> /* fprintf */ #include <glib/gstdio.h> #include <errno.h> @@ -128,6 +125,9 @@ #endif #include <glib/gprintf.h> /* g_sprintf */ +/* our own printf implementation with custom extensions to %p for caps etc. */ +#include "printf/printf.h" + #endif /* !GST_DISABLE_GST_DEBUG */ extern gboolean gst_is_initialized (void); @@ -223,18 +223,11 @@ dladdr (void *address, Dl_info * dl) static void gst_debug_reset_threshold (gpointer category, gpointer unused); static void gst_debug_reset_all_thresholds (void); -#ifdef GST_USING_PRINTF_EXTENSION +#if 0 static int _gst_info_printf_extension_ptr (FILE * stream, const struct printf_info *info, const void *const *args); static int _gst_info_printf_extension_segment (FILE * stream, const struct printf_info *info, const void *const *args); -#ifdef HAVE_REGISTER_PRINTF_SPECIFIER -static int _gst_info_printf_extension_arginfo (const struct printf_info *info, - size_t n, int *argtypes, int *size); -#else -static int _gst_info_printf_extension_arginfo (const struct printf_info *info, - size_t n, int *argtypes); -#endif #endif struct _GstDebugMessage @@ -335,18 +328,11 @@ _priv_gst_debug_init (void) /* get time we started for debugging messages */ _priv_gst_info_start_time = gst_util_get_timestamp (); -#ifdef GST_USING_PRINTF_EXTENSION -#ifdef HAVE_REGISTER_PRINTF_SPECIFIER +#if 0 register_printf_specifier (GST_PTR_FORMAT[0], _gst_info_printf_extension_ptr, - _gst_info_printf_extension_arginfo); + NULL); register_printf_specifier (GST_SEGMENT_FORMAT[0], - _gst_info_printf_extension_segment, _gst_info_printf_extension_arginfo); -#else - register_printf_function (GST_PTR_FORMAT[0], _gst_info_printf_extension_ptr, - _gst_info_printf_extension_arginfo); - register_printf_function (GST_SEGMENT_FORMAT[0], - _gst_info_printf_extension_segment, _gst_info_printf_extension_arginfo); -#endif + _gst_info_printf_extension_segment, NULL); #endif /* do NOT use a single debug function before this line has been run */ @@ -547,7 +533,13 @@ const gchar * gst_debug_message_get (GstDebugMessage * message) { if (message->message == NULL) { - message->message = g_strdup_vprintf (message->format, message->arguments); + int len; + + len = __gst_vasprintf (&message->message, message->format, + message->arguments); + + if (len < 0) + message->message = NULL; } return message->message; } @@ -742,8 +734,7 @@ gst_debug_print_object (gpointer ptr) return g_strdup_printf ("%p", ptr); } -#ifdef GST_USING_PRINTF_EXTENSION - +#if 0 static gchar * gst_debug_print_segment (gpointer ptr) { @@ -784,8 +775,7 @@ gst_debug_print_segment (gpointer ptr) } } } - -#endif /* GST_USING_PRINTF_EXTENSION */ +#endif /** * gst_debug_construct_term_color: @@ -1787,7 +1777,7 @@ _gst_debug_register_funcptr (GstDebugFuncPtr func, const gchar * ptrname) /*** PRINTF EXTENSIONS ********************************************************/ -#ifdef GST_USING_PRINTF_EXTENSION +#if 0 static int _gst_info_printf_extension_ptr (FILE * stream, const struct printf_info *info, const void *const *args) @@ -1825,26 +1815,7 @@ _gst_info_printf_extension_segment (FILE * stream, g_free (buffer); return len; } - -#ifdef HAVE_REGISTER_PRINTF_SPECIFIER -static int -_gst_info_printf_extension_arginfo (const struct printf_info *info, size_t n, - int *argtypes, int *size) -#else -static int -_gst_info_printf_extension_arginfo (const struct printf_info *info, size_t n, - int *argtypes) -#endif -{ - if (n > 0) { - argtypes[0] = PA_POINTER; -#ifdef HAVE_REGISTER_PRINTF_SPECIFIER - *size = sizeof (gpointer); #endif - } - return 1; -} -#endif /* GST_USING_PRINTF_EXTENSION */ static void gst_info_dump_mem_line (gchar * linebuf, gsize linebuf_size, diff --git a/gst/gstinfo.h b/gst/gstinfo.h index 242d18a89..105afefc2 100644 --- a/gst/gstinfo.h +++ b/gst/gstinfo.h @@ -229,6 +229,21 @@ struct _GstDebugCategory { #endif #endif /* ifndef GST_FUNCTION */ +/** + * GST_PTR_FORMAT: + * + * printf format type used to debug GStreamer types. + * This can only be used on types whose size is >= sizeof(gpointer). + */ +#define GST_PTR_FORMAT "p" /* FIXME: add suffix for differentiation */ + +/** + * GST_SEGMENT_FORMAT: + * + * printf format type used to debug GStreamer segments. + * This can only be used on pointers to GstSegment structures. + */ +#define GST_SEGMENT_FORMAT "p" /* FIXME: add suffix for differentiation */ typedef struct _GstDebugMessage GstDebugMessage; @@ -256,20 +271,6 @@ typedef void (*GstLogFunction) (GstDebugCategory * category, GstDebugMessage * message, gpointer user_data); -#ifdef GST_USING_PRINTF_EXTENSION - -/* not using G_GNUC_PRINTF, since gcc will choke on GST_PTR_FORMAT being %P */ -void gst_debug_log (GstDebugCategory * category, - GstDebugLevel level, - const gchar * file, - const gchar * function, - gint line, - GObject * object, - const gchar * format, - ...) G_GNUC_NO_INSTRUMENT; - -#else /* GST_USING_PRINTF_EXTENSION */ - void gst_debug_log (GstDebugCategory * category, GstDebugLevel level, const gchar * file, @@ -279,8 +280,6 @@ void gst_debug_log (GstDebugCategory * category, const gchar * format, ...) G_GNUC_PRINTF (7, 8) G_GNUC_NO_INSTRUMENT; -#endif /* GST_USING_PRINTF_EXTENSION */ - void gst_debug_log_valist (GstDebugCategory * category, GstDebugLevel level, const gchar * file, |