X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gst%2Fgstinfo.c;h=2dcf04d5bc56ae30a9468a77b5c907631f4c9d71;hb=a143d9cb0caee85bbe0c5e8b86e9f05918153c9d;hp=781426e380a9c48decbbb9f407d3f90b1f8643c3;hpb=ad0dd860c9145cdcc9bab2887e3da332bccce894;p=platform%2Fupstream%2Fgstreamer.git diff --git a/gst/gstinfo.c b/gst/gstinfo.c index 781426e..2dcf04d 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -240,8 +240,6 @@ dladdr (void *address, Dl_info * dl) #endif /* __sgi__ */ #endif -static const gchar *_gst_debug_filter = NULL; - static void gst_debug_reset_threshold (gpointer category, gpointer unused); static void gst_debug_reset_all_thresholds (void); @@ -408,7 +406,7 @@ _priv_gst_debug_init (void) GST_CAT_ELEMENT_PADS = _gst_debug_category_new ("GST_ELEMENT_PADS", GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL); GST_CAT_PADS = _gst_debug_category_new ("GST_PADS", - GST_DEBUG_BOLD | GST_DEBUG_FG_RED | GST_DEBUG_BG_RED, NULL); + GST_DEBUG_BOLD | GST_DEBUG_FG_RED | GST_DEBUG_BG_BLUE, NULL); GST_CAT_PERFORMANCE = _gst_debug_category_new ("GST_PERFORMANCE", GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL); GST_CAT_PIPELINE = _gst_debug_category_new ("GST_PIPELINE", @@ -464,10 +462,9 @@ _priv_gst_debug_init (void) if (env) gst_debug_set_color_mode_from_string (env); - _gst_debug_filter = g_getenv ("GST_DEBUG"); - if (_gst_debug_filter) { - gst_debug_set_threshold_from_string (_gst_debug_filter, FALSE); - } + env = g_getenv ("GST_DEBUG"); + if (env) + gst_debug_set_threshold_from_string (env, FALSE); } /* we can't do this further above, because we initialize the GST_CAT_DEFAULT struct */ @@ -577,7 +574,7 @@ gst_debug_log_valist (GstDebugCategory * category, GstDebugLevel level, * Gets the string representation of a #GstDebugMessage. This function is used * in debug handlers to extract the message. * - * Returns: the string representation of a #GstDebugMessage. + * Returns: (nullable): the string representation of a #GstDebugMessage. */ const gchar * gst_debug_message_get (GstDebugMessage * message) @@ -1140,9 +1137,19 @@ gst_debug_log_default (GstDebugCategory * category, GstDebugLevel level, GstClockTime elapsed; gchar *obj = NULL; GstDebugColorMode color_mode; + const gchar *message_str; FILE *log_file = user_data ? user_data : stderr; gchar c; + /* Get message string first because printing it might call into our custom + * printf format extension mechanism which in turn might log something, e.g. + * from inside gst_structure_to_string() when something can't be serialised. + * This means we either need to do this outside of any critical section or + * use a recursive lock instead. As we always need the message string in all + * code paths, we might just as well get it here first thing and outside of + * the win_print_mutex critical section. */ + message_str = gst_debug_message_get (message); + /* __FILE__ might be a file name or an absolute path or a * relative path, irrespective of the exact compiler used, * in which case we want to shorten it to the filename for @@ -1189,7 +1196,7 @@ gst_debug_log_default (GstDebugCategory * category, GstDebugLevel level, pidcolor, pid, clear, g_thread_self (), levelcolor, gst_debug_level_get_name (level), clear, color, gst_debug_category_get_name (category), file, line, function, obj, - clear, gst_debug_message_get (message)); + clear, message_str); fflush (log_file); #undef PRINT_FMT g_free (color); @@ -1224,7 +1231,7 @@ gst_debug_log_default (GstDebugCategory * category, GstDebugLevel level, fflush (log_file); /* message */ SET_COLOR (clear); - fprintf (log_file, " %s\n", gst_debug_message_get (message)); + fprintf (log_file, " %s\n", message_str); fflush (log_file); } g_mutex_unlock (&win_print_mutex); @@ -1235,7 +1242,7 @@ gst_debug_log_default (GstDebugCategory * category, GstDebugLevel level, fprintf (log_file, "%" GST_TIME_FORMAT PRINT_FMT, GST_TIME_ARGS (elapsed), pid, g_thread_self (), gst_debug_level_get_name (level), gst_debug_category_get_name (category), file, line, function, obj, - gst_debug_message_get (message)); + message_str); fflush (log_file); #undef PRINT_FMT } @@ -1580,6 +1587,20 @@ gst_debug_get_default_threshold (void) return (GstDebugLevel) g_atomic_int_get (&__default_level); } +static gboolean +gst_debug_apply_entry (GstDebugCategory * cat, LevelNameEntry * entry) +{ + if (!g_pattern_match_string (entry->pat, cat->name)) + return FALSE; + + if (gst_is_initialized ()) + GST_LOG ("category %s matches pattern %p - gets set to level %d", + cat->name, entry->pat, entry->level); + + gst_debug_category_set_threshold (cat, entry->level); + return TRUE; +} + static void gst_debug_reset_threshold (gpointer category, gpointer unused) { @@ -1587,23 +1608,16 @@ gst_debug_reset_threshold (gpointer category, gpointer unused) GSList *walk; g_mutex_lock (&__level_name_mutex); - walk = __level_name; - while (walk) { - LevelNameEntry *entry = walk->data; - walk = g_slist_next (walk); - if (g_pattern_match_string (entry->pat, cat->name)) { - if (gst_is_initialized ()) - GST_LOG ("category %s matches pattern %p - gets set to level %d", - cat->name, entry->pat, entry->level); - gst_debug_category_set_threshold (cat, entry->level); - goto exit; - } + for (walk = __level_name; walk != NULL; walk = walk->next) { + if (gst_debug_apply_entry (cat, walk->data)) + break; } - gst_debug_category_set_threshold (cat, gst_debug_get_default_threshold ()); -exit: g_mutex_unlock (&__level_name_mutex); + + if (walk == NULL) + gst_debug_category_set_threshold (cat, gst_debug_get_default_threshold ()); } static void @@ -1620,12 +1634,7 @@ for_each_threshold_by_entry (gpointer data, gpointer user_data) GstDebugCategory *cat = (GstDebugCategory *) data; LevelNameEntry *entry = (LevelNameEntry *) user_data; - if (g_pattern_match_string (entry->pat, cat->name)) { - if (gst_is_initialized ()) - GST_TRACE ("category %s matches pattern %p - gets set to level %d", - cat->name, entry->pat, entry->level); - gst_debug_category_set_threshold (cat, entry->level); - } + gst_debug_apply_entry (cat, entry); } /** @@ -1724,11 +1733,6 @@ _gst_debug_category_new (const gchar * name, guint color, } g_mutex_unlock (&__cat_mutex); - /* ensure the filter is applied to categories registered after _debug_init */ - if (_gst_debug_filter) { - gst_debug_set_threshold_from_string (_gst_debug_filter, FALSE); - } - return cat; } @@ -1983,7 +1987,7 @@ gst_debug_set_threshold_from_string (const gchar * list, gboolean reset) g_assert (list); if (reset) - gst_debug_set_default_threshold (0); + gst_debug_set_default_threshold (GST_LEVEL_DEFAULT); split = g_strsplit (list, ",", 0); @@ -2432,7 +2436,7 @@ gst_info_vasprintf (gchar ** result, const gchar * format, va_list args) * * Free with g_free(). * - * Returns: a newly allocated null terminated string or %NULL on any error + * Returns: (nullable): a newly allocated null terminated string or %NULL on any error * * Since: 1.8 */ @@ -2459,7 +2463,7 @@ gst_info_strdup_vprintf (const gchar * format, va_list args) * * Free with g_free(). * - * Returns: a newly allocated null terminated string or %NULL on any error + * Returns: (nullable): a newly allocated null terminated string or %NULL on any error * * Since: 1.8 */ @@ -2751,6 +2755,8 @@ generate_backtrace_trace (void) for (j = 0; j < nptrs; j++) g_string_append_printf (trace, "%s\n", strings[j]); + free (strings); + return g_string_free (trace, FALSE); } #else @@ -2762,8 +2768,8 @@ generate_backtrace_trace (void) * @flags: A set of #GstStackTraceFlags to determine how the stack * trace should look like. Pass 0 to retrieve a minimal backtrace. * - * If libunwind or glibc backtrace are present, a stack trace - * is returned. + * Returns: (nullable): a stack trace, if libunwind or glibc backtrace are + * present, else %NULL. * * Since: 1.12 */ @@ -2807,6 +2813,7 @@ gst_debug_print_stack_trace (void) g_free (trace); } +#ifndef GST_DISABLE_GST_DEBUG typedef struct { guint max_size_per_thread; @@ -3071,3 +3078,26 @@ gst_debug_remove_ring_buffer_logger (void) { gst_debug_remove_log_function (gst_ring_buffer_logger_log); } + +#else /* GST_DISABLE_GST_DEBUG */ +#ifndef GST_REMOVE_DISABLED + +gchar ** +gst_debug_ring_buffer_logger_get_logs (void) +{ + return NULL; +} + +void +gst_debug_add_ring_buffer_logger (guint max_size_per_thread, + guint thread_timeout) +{ +} + +void +gst_debug_remove_ring_buffer_logger (void) +{ +} + +#endif /* GST_REMOVE_DISABLED */ +#endif /* GST_DISABLE_GST_DEBUG */