2000-12-29 10:02:17 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
2003-06-29 14:05:49 +00:00
|
|
|
* 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
2009-06-08 18:33:55 +00:00
|
|
|
* Copyright (C) 2008-2009 Tim-Philipp Müller <tim centricular net>
|
2000-12-29 10:02:17 +00:00
|
|
|
*
|
2003-06-29 14:05:49 +00:00
|
|
|
* gstinfo.c: debugging functions
|
2000-12-29 10:02:17 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-03 20:44:48 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2000-12-29 10:02:17 +00:00
|
|
|
*/
|
2005-10-15 16:01:57 +00:00
|
|
|
|
2005-09-23 14:31:21 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gstinfo
|
2017-01-16 14:26:16 +00:00
|
|
|
* @title: GstInfo
|
2007-10-15 06:52:01 +00:00
|
|
|
* @short_description: Debugging and logging facilities
|
2015-04-06 17:56:25 +00:00
|
|
|
* @see_also: #gst-running for command line parameters
|
2005-09-23 14:31:21 +00:00
|
|
|
* and environment variables that affect the debugging output.
|
|
|
|
*
|
|
|
|
* GStreamer's debugging subsystem is an easy way to get information about what
|
2005-10-15 16:01:57 +00:00
|
|
|
* the application is doing. It is not meant for programming errors. Use GLib
|
|
|
|
* methods (g_warning and friends) for that.
|
2005-09-23 14:31:21 +00:00
|
|
|
*
|
2005-10-06 09:49:42 +00:00
|
|
|
* The debugging subsystem works only after GStreamer has been initialized
|
2005-09-23 14:31:21 +00:00
|
|
|
* - for example by calling gst_init().
|
|
|
|
*
|
|
|
|
* The debugging subsystem is used to log informational messages while the
|
2005-10-15 16:01:57 +00:00
|
|
|
* application runs. Each messages has some properties attached to it. Among
|
|
|
|
* these properties are the debugging category, the severity (called "level"
|
|
|
|
* here) and an optional #GObject it belongs to. Each of these messages is sent
|
|
|
|
* to all registered debugging handlers, which then handle the messages.
|
|
|
|
* GStreamer attaches a default handler on startup, which outputs requested
|
|
|
|
* messages to stderr.
|
2005-09-23 14:31:21 +00:00
|
|
|
*
|
2005-10-15 15:30:24 +00:00
|
|
|
* Messages are output by using shortcut macros like #GST_DEBUG,
|
2005-09-23 14:31:21 +00:00
|
|
|
* #GST_CAT_ERROR_OBJECT or similar. These all expand to calling gst_debug_log()
|
|
|
|
* with the right parameters.
|
2005-10-15 15:30:24 +00:00
|
|
|
* The only thing a developer will probably want to do is define his own
|
2005-10-06 09:49:42 +00:00
|
|
|
* categories. This is easily done with 3 lines. At the top of your code,
|
|
|
|
* declare
|
2005-09-23 14:31:21 +00:00
|
|
|
* the variables and set the default category.
|
2014-06-05 20:27:28 +00:00
|
|
|
* |[<!-- language="C" -->
|
2014-02-27 17:06:56 +00:00
|
|
|
* GST_DEBUG_CATEGORY_STATIC (my_category); // define category (statically)
|
|
|
|
* #define GST_CAT_DEFAULT my_category // set as default
|
|
|
|
* ]|
|
2005-09-23 14:31:21 +00:00
|
|
|
* After that you only need to initialize the category.
|
2014-06-05 20:27:28 +00:00
|
|
|
* |[<!-- language="C" -->
|
2014-02-27 17:06:56 +00:00
|
|
|
* GST_DEBUG_CATEGORY_INIT (my_category, "my category",
|
|
|
|
* 0, "This is my very own");
|
|
|
|
* ]|
|
2005-10-06 09:49:42 +00:00
|
|
|
* Initialization must be done before the category is used first.
|
2005-10-15 15:30:24 +00:00
|
|
|
* Plugins do this
|
2005-09-23 14:31:21 +00:00
|
|
|
* in their plugin_init function, libraries and applications should do that
|
|
|
|
* during their initialization.
|
|
|
|
*
|
|
|
|
* The whole debugging subsystem can be disabled at build time with passing the
|
2005-10-06 09:49:42 +00:00
|
|
|
* --disable-gst-debug switch to configure. If this is done, every function,
|
2005-11-04 20:12:01 +00:00
|
|
|
* macro and even structs described in this file evaluate to default values or
|
|
|
|
* nothing at all.
|
|
|
|
* So don't take addresses of these functions or use other tricks.
|
2005-10-06 09:49:42 +00:00
|
|
|
* If you must do that for some reason, there is still an option.
|
|
|
|
* If the debugging
|
|
|
|
* subsystem was compiled out, #GST_DISABLE_GST_DEBUG is defined in
|
|
|
|
* <gst/gst.h>,
|
2005-09-23 14:31:21 +00:00
|
|
|
* so you can check that before doing your trick.
|
2007-10-15 06:52:01 +00:00
|
|
|
* Disabling the debugging subsystem will give you a slight (read: unnoticeable)
|
2005-10-15 15:30:24 +00:00
|
|
|
* speed increase and will reduce the size of your compiled code. The GStreamer
|
2005-09-23 14:31:21 +00:00
|
|
|
* library itself becomes around 10% smaller.
|
|
|
|
*
|
2005-10-15 15:30:24 +00:00
|
|
|
* Please note that there are naming conventions for the names of debugging
|
2005-09-23 14:31:21 +00:00
|
|
|
* categories. These are explained at GST_DEBUG_CATEGORY_INIT().
|
|
|
|
*/
|
2000-12-29 10:02:17 +00:00
|
|
|
|
2009-04-15 20:12:11 +00:00
|
|
|
#define GST_INFO_C
|
2003-06-29 14:05:49 +00:00
|
|
|
#include "gst_private.h"
|
|
|
|
#include "gstinfo.h"
|
|
|
|
|
2011-02-03 10:53:27 +00:00
|
|
|
#undef gst_debug_remove_log_function
|
|
|
|
#undef gst_debug_add_log_function
|
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
#ifndef GST_DISABLE_GST_DEBUG
|
2003-08-06 03:00:21 +00:00
|
|
|
#ifdef HAVE_DLFCN_H
|
2005-10-16 10:38:02 +00:00
|
|
|
# include <dlfcn.h>
|
2003-08-06 03:00:21 +00:00
|
|
|
#endif
|
2004-03-15 19:27:17 +00:00
|
|
|
#include <stdio.h> /* fprintf */
|
2010-06-04 10:24:59 +00:00
|
|
|
#include <glib/gstdio.h>
|
|
|
|
#include <errno.h>
|
2004-04-28 23:26:06 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2005-10-16 10:38:02 +00:00
|
|
|
# include <unistd.h> /* getpid on UNIX */
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_PROCESS_H
|
|
|
|
# include <process.h> /* getpid on win32 */
|
2004-04-28 23:26:06 +00:00
|
|
|
#endif
|
2004-03-15 19:27:17 +00:00
|
|
|
#include <string.h> /* G_VA_COPY */
|
2009-03-18 16:30:12 +00:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
# define WIN32_LEAN_AND_MEAN /* prevents from including too many things */
|
|
|
|
# include <windows.h> /* GetStdHandle, windows console */
|
|
|
|
#endif
|
2007-10-15 06:52:01 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
#include "gst_private.h"
|
2005-04-24 22:49:45 +00:00
|
|
|
#include "gstutils.h"
|
2009-06-08 18:33:55 +00:00
|
|
|
#include "gstquark.h"
|
2006-08-09 15:13:14 +00:00
|
|
|
#include "gstsegment.h"
|
2012-07-14 17:52:50 +00:00
|
|
|
#include "gstvalue.h"
|
2013-03-30 14:35:19 +00:00
|
|
|
#include "gstcapsfeatures.h"
|
2012-07-14 17:52:50 +00:00
|
|
|
|
2010-08-24 01:20:23 +00:00
|
|
|
#ifdef HAVE_VALGRIND_VALGRIND_H
|
2005-10-16 10:38:02 +00:00
|
|
|
# include <valgrind/valgrind.h>
|
2004-04-05 21:42:07 +00:00
|
|
|
#endif
|
gst/gstinfo.c: don't do dummy g_strdup()s
Original commit message from CVS:
* gst/gstinfo.c: (gst_debug_log_default):
don't do dummy g_strdup()s
* libs/gst/controller/gstcontroller.c:
(on_object_controlled_property_changed),
(gst_controlled_property_new), (gst_controller_new_valist),
(gst_controller_new_list),
(gst_controller_remove_properties_valist), (gst_controller_set),
(gst_controller_get), (gst_controller_sync_values),
(gst_controller_get_value_array), (_gst_controller_class_init),
(gst_controller_get_type):
* libs/gst/controller/gstcontroller.h:
* libs/gst/controller/gstinterpolation.c:
(gst_controlled_property_find_timed_value_node):
convert // to /**/ comments
2005-09-28 17:30:13 +00:00
|
|
|
#include <glib/gprintf.h> /* g_sprintf */
|
2003-06-29 14:05:49 +00:00
|
|
|
|
2013-03-30 17:20:13 +00:00
|
|
|
/* our own printf implementation with custom extensions to %p for caps etc. */
|
|
|
|
#include "printf/printf.h"
|
2013-03-30 18:28:38 +00:00
|
|
|
#include "printf/printf-extension.h"
|
|
|
|
|
|
|
|
static char *gst_info_printf_pointer_extension_func (const char *format,
|
|
|
|
void *ptr);
|
2016-10-07 09:38:27 +00:00
|
|
|
#else /* GST_DISABLE_GST_DEBUG */
|
2013-03-30 17:20:13 +00:00
|
|
|
|
2016-10-07 09:38:27 +00:00
|
|
|
#include <glib/gprintf.h>
|
2009-06-19 12:40:13 +00:00
|
|
|
#endif /* !GST_DISABLE_GST_DEBUG */
|
|
|
|
|
2016-10-07 09:38:27 +00:00
|
|
|
#ifdef HAVE_UNWIND
|
|
|
|
/* No need for remote debugging so turn on the 'local only' optimizations in
|
|
|
|
* libunwind */
|
|
|
|
#define UNW_LOCAL_ONLY
|
|
|
|
|
|
|
|
#include <libunwind.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_DW
|
|
|
|
#include <elfutils/libdwfl.h>
|
|
|
|
#endif /* HAVE_DW */
|
|
|
|
#endif /* HAVE_UNWIND */
|
|
|
|
|
|
|
|
#ifdef HAVE_BACKTRACE
|
|
|
|
#include <execinfo.h>
|
|
|
|
#define BT_BUF_SIZE 100
|
|
|
|
#endif /* HAVE_BACKTRACE */
|
|
|
|
|
2019-01-25 01:36:18 +00:00
|
|
|
#ifdef HAVE_DBGHELP
|
|
|
|
#include <Windows.h>
|
|
|
|
#include <dbghelp.h>
|
|
|
|
#include <tlhelp32.h>
|
|
|
|
#endif /* HAVE_DBGHELP */
|
|
|
|
|
2012-10-22 08:25:40 +00:00
|
|
|
extern gboolean gst_is_initialized (void);
|
|
|
|
|
2009-06-19 12:40:13 +00:00
|
|
|
/* we want these symbols exported even if debug is disabled, to maintain
|
|
|
|
* ABI compatibility. Unless GST_REMOVE_DISABLED is defined. */
|
|
|
|
#if !defined(GST_DISABLE_GST_DEBUG) || !defined(GST_REMOVE_DISABLED)
|
|
|
|
|
|
|
|
/* disabled by default, as soon as some threshold is set > NONE,
|
|
|
|
* it becomes enabled. */
|
2011-10-08 12:37:09 +00:00
|
|
|
gboolean _gst_debug_enabled = FALSE;
|
|
|
|
GstDebugLevel _gst_debug_min = GST_LEVEL_NONE;
|
2009-06-19 12:40:13 +00:00
|
|
|
|
|
|
|
GstDebugCategory *GST_CAT_DEFAULT = NULL;
|
|
|
|
|
|
|
|
GstDebugCategory *GST_CAT_GST_INIT = NULL;
|
2012-02-02 14:54:28 +00:00
|
|
|
GstDebugCategory *GST_CAT_MEMORY = NULL;
|
2009-06-19 12:40:13 +00:00
|
|
|
GstDebugCategory *GST_CAT_PARENTAGE = NULL;
|
|
|
|
GstDebugCategory *GST_CAT_STATES = NULL;
|
|
|
|
GstDebugCategory *GST_CAT_SCHEDULING = NULL;
|
|
|
|
|
|
|
|
GstDebugCategory *GST_CAT_BUFFER = NULL;
|
|
|
|
GstDebugCategory *GST_CAT_BUFFER_LIST = NULL;
|
|
|
|
GstDebugCategory *GST_CAT_BUS = NULL;
|
|
|
|
GstDebugCategory *GST_CAT_CAPS = NULL;
|
|
|
|
GstDebugCategory *GST_CAT_CLOCK = NULL;
|
|
|
|
GstDebugCategory *GST_CAT_ELEMENT_PADS = NULL;
|
|
|
|
GstDebugCategory *GST_CAT_PADS = NULL;
|
2009-06-29 08:24:04 +00:00
|
|
|
GstDebugCategory *GST_CAT_PERFORMANCE = NULL;
|
2009-06-19 12:40:13 +00:00
|
|
|
GstDebugCategory *GST_CAT_PIPELINE = NULL;
|
|
|
|
GstDebugCategory *GST_CAT_PLUGIN_LOADING = NULL;
|
|
|
|
GstDebugCategory *GST_CAT_PLUGIN_INFO = NULL;
|
|
|
|
GstDebugCategory *GST_CAT_PROPERTIES = NULL;
|
|
|
|
GstDebugCategory *GST_CAT_NEGOTIATION = NULL;
|
|
|
|
GstDebugCategory *GST_CAT_REFCOUNTING = NULL;
|
|
|
|
GstDebugCategory *GST_CAT_ERROR_SYSTEM = NULL;
|
|
|
|
GstDebugCategory *GST_CAT_EVENT = NULL;
|
|
|
|
GstDebugCategory *GST_CAT_MESSAGE = NULL;
|
|
|
|
GstDebugCategory *GST_CAT_PARAMS = NULL;
|
|
|
|
GstDebugCategory *GST_CAT_CALL_TRACE = NULL;
|
|
|
|
GstDebugCategory *GST_CAT_SIGNAL = NULL;
|
|
|
|
GstDebugCategory *GST_CAT_PROBE = NULL;
|
|
|
|
GstDebugCategory *GST_CAT_REGISTRY = NULL;
|
|
|
|
GstDebugCategory *GST_CAT_QOS = NULL;
|
2009-10-12 13:24:04 +00:00
|
|
|
GstDebugCategory *_priv_GST_CAT_POLL = NULL;
|
2012-03-01 16:39:17 +00:00
|
|
|
GstDebugCategory *GST_CAT_META = NULL;
|
2012-07-04 14:04:28 +00:00
|
|
|
GstDebugCategory *GST_CAT_LOCKING = NULL;
|
2013-03-28 14:35:13 +00:00
|
|
|
GstDebugCategory *GST_CAT_CONTEXT = NULL;
|
2015-04-15 14:33:31 +00:00
|
|
|
GstDebugCategory *_priv_GST_CAT_PROTECTION = NULL;
|
2009-10-12 07:50:00 +00:00
|
|
|
|
2009-06-19 12:40:13 +00:00
|
|
|
|
|
|
|
#endif /* !defined(GST_DISABLE_GST_DEBUG) || !defined(GST_REMOVE_DISABLED) */
|
|
|
|
|
|
|
|
#ifndef GST_DISABLE_GST_DEBUG
|
|
|
|
|
2004-04-15 23:25:39 +00:00
|
|
|
/* underscore is to prevent conflict with GST_CAT_DEBUG define */
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (_GST_CAT_DEBUG);
|
2007-10-17 12:58:23 +00:00
|
|
|
|
2003-08-06 03:00:21 +00:00
|
|
|
#if 0
|
2001-12-18 17:02:02 +00:00
|
|
|
#if defined __sgi__
|
|
|
|
#include <rld_interface.h>
|
2004-03-13 15:27:01 +00:00
|
|
|
typedef struct DL_INFO
|
|
|
|
{
|
|
|
|
const char *dli_fname;
|
|
|
|
void *dli_fbase;
|
|
|
|
const char *dli_sname;
|
|
|
|
void *dli_saddr;
|
|
|
|
int dli_version;
|
|
|
|
int dli_reserved1;
|
|
|
|
long dli_reserved[4];
|
2004-03-15 19:27:17 +00:00
|
|
|
}
|
|
|
|
Dl_info;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-12-18 17:02:02 +00:00
|
|
|
#define _RLD_DLADDR 14
|
2004-03-13 15:27:01 +00:00
|
|
|
int dladdr (void *address, Dl_info * dl);
|
2001-12-18 17:02:02 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
int
|
|
|
|
dladdr (void *address, Dl_info * dl)
|
2001-12-18 17:02:02 +00:00
|
|
|
{
|
|
|
|
void *v;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
v = _rld_new_interface (_RLD_DLADDR, address, dl);
|
|
|
|
return (int) v;
|
2001-12-18 17:02:02 +00:00
|
|
|
}
|
2003-06-29 14:05:49 +00:00
|
|
|
#endif /* __sgi__ */
|
2003-08-06 03:00:21 +00:00
|
|
|
#endif
|
2001-12-18 17:02:02 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void gst_debug_reset_threshold (gpointer category, gpointer unused);
|
|
|
|
static void gst_debug_reset_all_thresholds (void);
|
2003-06-29 14:05:49 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
struct _GstDebugMessage
|
|
|
|
{
|
|
|
|
gchar *message;
|
|
|
|
const gchar *format;
|
|
|
|
va_list arguments;
|
2004-01-10 01:49:00 +00:00
|
|
|
};
|
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
/* list of all name/level pairs from --gst-debug and GST_DEBUG */
|
2012-01-22 22:44:59 +00:00
|
|
|
static GMutex __level_name_mutex;
|
2003-06-29 14:05:49 +00:00
|
|
|
static GSList *__level_name = NULL;
|
2004-03-13 15:27:01 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GPatternSpec *pat;
|
|
|
|
GstDebugLevel level;
|
2004-03-15 19:27:17 +00:00
|
|
|
}
|
|
|
|
LevelNameEntry;
|
2003-06-29 14:05:49 +00:00
|
|
|
|
|
|
|
/* list of all categories */
|
2012-01-22 22:44:59 +00:00
|
|
|
static GMutex __cat_mutex;
|
2003-06-29 14:05:49 +00:00
|
|
|
static GSList *__categories = NULL;
|
|
|
|
|
2013-12-04 22:35:18 +00:00
|
|
|
static GstDebugCategory *_gst_debug_get_category_locked (const gchar * name);
|
|
|
|
|
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
/* all registered debug handlers */
|
2004-03-13 15:27:01 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GstLogFunction func;
|
|
|
|
gpointer user_data;
|
2012-06-20 11:28:08 +00:00
|
|
|
GDestroyNotify notify;
|
2004-03-15 19:27:17 +00:00
|
|
|
}
|
|
|
|
LogFuncEntry;
|
2012-01-22 22:44:59 +00:00
|
|
|
static GMutex __log_func_mutex;
|
2003-06-29 14:05:49 +00:00
|
|
|
static GSList *__log_functions = NULL;
|
|
|
|
|
2016-02-29 19:04:16 +00:00
|
|
|
/* whether to add the default log function in gst_init() */
|
|
|
|
static gboolean add_default_log_func = TRUE;
|
|
|
|
|
2009-06-08 18:33:55 +00:00
|
|
|
#define PRETTY_TAGS_DEFAULT TRUE
|
|
|
|
static gboolean pretty_tags = PRETTY_TAGS_DEFAULT;
|
|
|
|
|
2010-07-28 01:24:44 +00:00
|
|
|
static volatile gint G_GNUC_MAY_ALIAS __default_level = GST_LEVEL_DEFAULT;
|
2013-07-18 11:10:10 +00:00
|
|
|
static volatile gint G_GNUC_MAY_ALIAS __use_color = GST_DEBUG_COLOR_MODE_ON;
|
2006-03-13 11:08:28 +00:00
|
|
|
|
2004-04-05 21:42:07 +00:00
|
|
|
/* FIXME: export this? */
|
|
|
|
gboolean
|
Makefile.am: Add check-exports target and run it as part of 'make check' (see #499140 and #493983).
Original commit message from CVS:
* Makefile.am:
Add check-exports target and run it as part of 'make check'
(see #499140 and #493983).
* gst/gst_private.h:
* gst/gstelementfactory.h:
* gst/gstghostpad.c: (gst_proxy_pad_class_init):
* gst/gstinfo.c: (_priv_gst_in_valgrind), (_gst_debug_init),
(_priv_gst_in_valgrind):
* gst/gstinfo.h: (GstLogFunction):
* gst/gsttypefind.c: (type_find_debug), (GST_CAT_DEFAULT),
(gst_type_find_register):
* gst/gsttypefindfactory.c: (type_find_debug), (GST_CAT_DEFAULT),
(gst_type_find_factory_get_type):
* libs/gst/controller/gstcontroller.c: (GST_CAT_DEFAULT),
(GST_CAT_DEFAULT), (parent_class), (priv_gst_controller_key),
(gst_controller_new_valist), (gst_controller_new_list),
(_gst_controller_dispose), (_gst_controller_class_init):
* libs/gst/controller/gstcontrolsource.c: (GST_CAT_DEFAULT):
* libs/gst/controller/gsthelper.c: (GST_CAT_DEFAULT),
(GST_CAT_DEFAULT), (gst_object_uncontrol_properties),
(gst_object_get_controller), (gst_object_set_controller),
(gst_object_suggest_next_sync), (gst_object_sync_values),
(gst_object_set_control_source), (gst_object_get_control_source),
(gst_object_get_value_arrays), (gst_object_get_value_array),
(gst_object_get_control_rate), (gst_object_set_control_rate):
* libs/gst/controller/gstinterpolation.c: (GST_CAT_DEFAULT):
* libs/gst/controller/lib.c: (GST_CAT_DEFAULT):
Make some functions that should be static static; rename some
private symbols so that they don't get exported; add some FIXME
comments so we can move accidentally exported functions into
our private section in 0.11.
* win32/common/libgstreamer.def:
Add gst_utils_get_timestamp().
2007-12-12 23:20:00 +00:00
|
|
|
_priv_gst_in_valgrind (void)
|
2004-04-05 21:42:07 +00:00
|
|
|
{
|
|
|
|
static enum
|
|
|
|
{
|
|
|
|
GST_VG_UNCHECKED,
|
|
|
|
GST_VG_NO_VALGRIND,
|
|
|
|
GST_VG_INSIDE
|
|
|
|
}
|
|
|
|
in_valgrind = GST_VG_UNCHECKED;
|
|
|
|
|
|
|
|
if (in_valgrind == GST_VG_UNCHECKED) {
|
2010-08-24 01:20:23 +00:00
|
|
|
#ifdef HAVE_VALGRIND_VALGRIND_H
|
2004-04-05 21:42:07 +00:00
|
|
|
if (RUNNING_ON_VALGRIND) {
|
|
|
|
GST_CAT_INFO (GST_CAT_GST_INIT, "we're running inside valgrind");
|
|
|
|
in_valgrind = GST_VG_INSIDE;
|
|
|
|
} else {
|
|
|
|
GST_CAT_LOG (GST_CAT_GST_INIT, "not doing extra valgrind stuff");
|
|
|
|
in_valgrind = GST_VG_NO_VALGRIND;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
in_valgrind = GST_VG_NO_VALGRIND;
|
|
|
|
#endif
|
|
|
|
g_assert (in_valgrind == GST_VG_NO_VALGRIND ||
|
|
|
|
in_valgrind == GST_VG_INSIDE);
|
|
|
|
}
|
2009-04-10 06:51:02 +00:00
|
|
|
return (in_valgrind == GST_VG_INSIDE);
|
2004-04-05 21:42:07 +00:00
|
|
|
}
|
|
|
|
|
2015-10-29 21:51:18 +00:00
|
|
|
static gchar *
|
2016-11-29 20:34:40 +00:00
|
|
|
_replace_pattern_in_gst_debug_file_name (gchar * name, const char *token,
|
|
|
|
guint val)
|
2015-10-29 21:51:18 +00:00
|
|
|
{
|
2016-11-29 20:34:40 +00:00
|
|
|
gchar *token_start;
|
2015-10-29 21:51:18 +00:00
|
|
|
if ((token_start = strstr (name, token))) {
|
|
|
|
gsize token_len = strlen (token);
|
2016-11-29 20:34:40 +00:00
|
|
|
gchar *name_prefix = name;
|
|
|
|
gchar *name_suffix = token_start + token_len;
|
2015-10-29 21:51:18 +00:00
|
|
|
token_start[0] = '\0';
|
|
|
|
name = g_strdup_printf ("%s%u%s", name_prefix, val, name_suffix);
|
|
|
|
g_free (name_prefix);
|
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
_priv_gst_debug_file_name (const gchar * env)
|
|
|
|
{
|
|
|
|
gchar *name;
|
|
|
|
|
|
|
|
name = g_strdup (env);
|
|
|
|
name = _replace_pattern_in_gst_debug_file_name (name, "%p", getpid ());
|
|
|
|
name = _replace_pattern_in_gst_debug_file_name (name, "%r", g_random_int ());
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2011-10-08 19:15:46 +00:00
|
|
|
/* Initialize the debugging system */
|
2004-03-13 15:27:01 +00:00
|
|
|
void
|
2011-10-08 19:15:46 +00:00
|
|
|
_priv_gst_debug_init (void)
|
2003-06-29 14:05:49 +00:00
|
|
|
{
|
2009-06-08 18:33:55 +00:00
|
|
|
const gchar *env;
|
2014-09-12 12:42:23 +00:00
|
|
|
FILE *log_file;
|
2009-06-08 18:33:55 +00:00
|
|
|
|
2016-03-31 10:46:03 +00:00
|
|
|
if (add_default_log_func) {
|
|
|
|
env = g_getenv ("GST_DEBUG_FILE");
|
|
|
|
if (env != NULL && *env != '\0') {
|
|
|
|
if (strcmp (env, "-") == 0) {
|
|
|
|
log_file = stdout;
|
|
|
|
} else {
|
2015-10-29 21:51:18 +00:00
|
|
|
gchar *name = _priv_gst_debug_file_name (env);
|
|
|
|
log_file = g_fopen (name, "w");
|
|
|
|
g_free (name);
|
2016-03-31 10:46:03 +00:00
|
|
|
if (log_file == NULL) {
|
|
|
|
g_printerr ("Could not open log file '%s' for writing: %s\n", env,
|
|
|
|
g_strerror (errno));
|
|
|
|
log_file = stderr;
|
|
|
|
}
|
2010-06-04 10:24:59 +00:00
|
|
|
}
|
2016-03-31 10:46:03 +00:00
|
|
|
} else {
|
|
|
|
log_file = stderr;
|
2010-06-04 10:24:59 +00:00
|
|
|
}
|
2016-03-31 10:46:03 +00:00
|
|
|
|
|
|
|
gst_debug_add_log_function (gst_debug_log_default, log_file, NULL);
|
2010-06-04 10:24:59 +00:00
|
|
|
}
|
|
|
|
|
2013-03-30 18:28:38 +00:00
|
|
|
__gst_printf_pointer_extension_set_func
|
|
|
|
(gst_info_printf_pointer_extension_func);
|
configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
Original commit message from CVS:
* configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
GST_PRINTF_EXTENSION_FORMAT_DEFINE.
* docs/random/ds/0.9-suggested-changes: Notes from Company.
* gst/gstcaps.c: (gst_caps_to_string): Add comment.
* gst/gstconfig.h.in: Add define for GST_PTR_FORMAT
* gst/gstinfo.c: (_gst_debug_init), (gst_debug_print_object),
(gst_debug_log_default), (_gst_info_printf_extension),
(_gst_info_printf_extension_arginfo): Add printf extension.
* gst/gstinfo.h: remove G_GNUC_PRINTF, because it doesn't work with %P
* gst/gststructure.c: (gst_structure_to_string),
(_gst_structure_parse_value): Use gst_value_deserialize() and
remove old code.
* gst/gstvalue.c: (gst_value_deserialize_fourcc),
(gst_value_deserialize_boolean), (gst_strtoi),
(gst_value_deserialize_int), (gst_value_deserialize_double),
(gst_value_deserialize_string), (gst_value_deserialize): Implement
a bunch of deserialize functions and gst_value_deserialize.
* gst/gstvalue.h: er, _de_serialize, not unserialize
* testsuite/caps/string-conversions.c: (main): We don't currently
handle (float) in caps, so convert these to (double).
* testsuite/debug/Makefile.am: Add new test for the printf extension
* testsuite/debug/printf_extension.c: (main): same
2004-01-29 01:20:23 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
/* do NOT use a single debug function before this line has been run */
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_CAT_DEFAULT = _gst_debug_category_new ("default",
|
|
|
|
GST_DEBUG_UNDERLINE, NULL);
|
2004-04-15 23:25:39 +00:00
|
|
|
_GST_CAT_DEBUG = _gst_debug_category_new ("GST_DEBUG",
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_YELLOW, "debugging subsystem");
|
2003-06-29 14:05:49 +00:00
|
|
|
|
|
|
|
/* FIXME: add descriptions here */
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_CAT_GST_INIT = _gst_debug_category_new ("GST_INIT",
|
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_RED, NULL);
|
2012-02-02 14:54:28 +00:00
|
|
|
GST_CAT_MEMORY = _gst_debug_category_new ("GST_MEMORY",
|
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE, "memory");
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_CAT_PARENTAGE = _gst_debug_category_new ("GST_PARENTAGE",
|
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL);
|
|
|
|
GST_CAT_STATES = _gst_debug_category_new ("GST_STATES",
|
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_RED, NULL);
|
|
|
|
GST_CAT_SCHEDULING = _gst_debug_category_new ("GST_SCHEDULING",
|
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_MAGENTA, NULL);
|
|
|
|
GST_CAT_BUFFER = _gst_debug_category_new ("GST_BUFFER",
|
2005-10-06 09:49:42 +00:00
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_BG_GREEN, NULL);
|
2009-05-12 10:08:56 +00:00
|
|
|
GST_CAT_BUFFER_LIST = _gst_debug_category_new ("GST_BUFFER_LIST",
|
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_BG_GREEN, NULL);
|
2005-10-06 09:49:42 +00:00
|
|
|
GST_CAT_BUS = _gst_debug_category_new ("GST_BUS", GST_DEBUG_BG_YELLOW, NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_CAT_CAPS = _gst_debug_category_new ("GST_CAPS",
|
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE, NULL);
|
|
|
|
GST_CAT_CLOCK = _gst_debug_category_new ("GST_CLOCK",
|
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_YELLOW, NULL);
|
|
|
|
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",
|
2018-04-17 12:33:02 +00:00
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_RED | GST_DEBUG_BG_BLUE, NULL);
|
2009-06-29 08:24:04 +00:00
|
|
|
GST_CAT_PERFORMANCE = _gst_debug_category_new ("GST_PERFORMANCE",
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL);
|
|
|
|
GST_CAT_PIPELINE = _gst_debug_category_new ("GST_PIPELINE",
|
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL);
|
2003-06-29 14:05:49 +00:00
|
|
|
GST_CAT_PLUGIN_LOADING = _gst_debug_category_new ("GST_PLUGIN_LOADING",
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_CYAN, NULL);
|
|
|
|
GST_CAT_PLUGIN_INFO = _gst_debug_category_new ("GST_PLUGIN_INFO",
|
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_CYAN, NULL);
|
|
|
|
GST_CAT_PROPERTIES = _gst_debug_category_new ("GST_PROPERTIES",
|
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_BLUE, NULL);
|
|
|
|
GST_CAT_NEGOTIATION = _gst_debug_category_new ("GST_NEGOTIATION",
|
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE, NULL);
|
|
|
|
GST_CAT_REFCOUNTING = _gst_debug_category_new ("GST_REFCOUNTING",
|
2005-09-28 15:45:21 +00:00
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_RED | GST_DEBUG_BG_BLUE, NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_CAT_ERROR_SYSTEM = _gst_debug_category_new ("GST_ERROR_SYSTEM",
|
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_RED | GST_DEBUG_BG_WHITE, NULL);
|
|
|
|
|
|
|
|
GST_CAT_EVENT = _gst_debug_category_new ("GST_EVENT",
|
2005-01-10 17:23:42 +00:00
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE, NULL);
|
Bump version number, we're now 0.9.0
Original commit message from CVS:
* configure.ac:
* gst/gst_private.h:
* gst/gstbin.c: (gst_bin_add_func), (gst_bin_add),
(gst_bin_remove_func), (gst_bin_remove),
(gst_bin_get_by_name_recurse_up):
* gst/gstclock.c: (gst_clock_id_ref), (gst_clock_id_unref),
(gst_clock_id_compare_func), (gst_clock_id_wait),
(gst_clock_id_wait_async), (gst_clock_init),
(gst_clock_adjust_unlocked), (gst_clock_get_time):
* gst/gstelement.h:
* gst/gstinfo.c: (_gst_debug_init):
* gst/gstobject.h:
* gst/gstpad.c: (_gst_pad_default_fixate_foreach),
(gst_pad_collectv), (gst_pad_collect_valist), (gst_pad_query):
* gst/gstpad.h:
Bump version number, we're now 0.9.0
Add future debugging category.
Fix NULL _unref() in _get_by_name_recurse_up
Rearrange gstpad.h.
Update some docs.
2005-03-09 11:08:18 +00:00
|
|
|
GST_CAT_MESSAGE = _gst_debug_category_new ("GST_MESSAGE",
|
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_CAT_PARAMS = _gst_debug_category_new ("GST_PARAMS",
|
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_BLACK | GST_DEBUG_BG_YELLOW, NULL);
|
|
|
|
GST_CAT_CALL_TRACE = _gst_debug_category_new ("GST_CALL_TRACE",
|
|
|
|
GST_DEBUG_BOLD, NULL);
|
2005-01-13 16:50:49 +00:00
|
|
|
GST_CAT_SIGNAL = _gst_debug_category_new ("GST_SIGNAL",
|
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL);
|
|
|
|
GST_CAT_PROBE = _gst_debug_category_new ("GST_PROBE",
|
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_GREEN, "pad probes");
|
2005-09-15 00:13:26 +00:00
|
|
|
GST_CAT_REGISTRY = _gst_debug_category_new ("GST_REGISTRY", 0, "registry");
|
2006-03-13 11:08:28 +00:00
|
|
|
GST_CAT_QOS = _gst_debug_category_new ("GST_QOS", 0, "QoS");
|
2009-10-12 13:24:04 +00:00
|
|
|
_priv_GST_CAT_POLL = _gst_debug_category_new ("GST_POLL", 0, "poll");
|
2012-03-01 16:39:17 +00:00
|
|
|
GST_CAT_META = _gst_debug_category_new ("GST_META", 0, "meta");
|
2012-07-04 14:04:28 +00:00
|
|
|
GST_CAT_LOCKING = _gst_debug_category_new ("GST_LOCKING", 0, "locking");
|
2013-03-28 14:35:13 +00:00
|
|
|
GST_CAT_CONTEXT = _gst_debug_category_new ("GST_CONTEXT", 0, NULL);
|
2015-04-15 14:33:31 +00:00
|
|
|
_priv_GST_CAT_PROTECTION =
|
|
|
|
_gst_debug_category_new ("GST_PROTECTION", 0, "protection");
|
2004-04-05 21:42:07 +00:00
|
|
|
|
|
|
|
/* print out the valgrind message if we're in valgrind */
|
Makefile.am: Add check-exports target and run it as part of 'make check' (see #499140 and #493983).
Original commit message from CVS:
* Makefile.am:
Add check-exports target and run it as part of 'make check'
(see #499140 and #493983).
* gst/gst_private.h:
* gst/gstelementfactory.h:
* gst/gstghostpad.c: (gst_proxy_pad_class_init):
* gst/gstinfo.c: (_priv_gst_in_valgrind), (_gst_debug_init),
(_priv_gst_in_valgrind):
* gst/gstinfo.h: (GstLogFunction):
* gst/gsttypefind.c: (type_find_debug), (GST_CAT_DEFAULT),
(gst_type_find_register):
* gst/gsttypefindfactory.c: (type_find_debug), (GST_CAT_DEFAULT),
(gst_type_find_factory_get_type):
* libs/gst/controller/gstcontroller.c: (GST_CAT_DEFAULT),
(GST_CAT_DEFAULT), (parent_class), (priv_gst_controller_key),
(gst_controller_new_valist), (gst_controller_new_list),
(_gst_controller_dispose), (_gst_controller_class_init):
* libs/gst/controller/gstcontrolsource.c: (GST_CAT_DEFAULT):
* libs/gst/controller/gsthelper.c: (GST_CAT_DEFAULT),
(GST_CAT_DEFAULT), (gst_object_uncontrol_properties),
(gst_object_get_controller), (gst_object_set_controller),
(gst_object_suggest_next_sync), (gst_object_sync_values),
(gst_object_set_control_source), (gst_object_get_control_source),
(gst_object_get_value_arrays), (gst_object_get_value_array),
(gst_object_get_control_rate), (gst_object_set_control_rate):
* libs/gst/controller/gstinterpolation.c: (GST_CAT_DEFAULT):
* libs/gst/controller/lib.c: (GST_CAT_DEFAULT):
Make some functions that should be static static; rename some
private symbols so that they don't get exported; add some FIXME
comments so we can move accidentally exported functions into
our private section in 0.11.
* win32/common/libgstreamer.def:
Add gst_utils_get_timestamp().
2007-12-12 23:20:00 +00:00
|
|
|
_priv_gst_in_valgrind ();
|
2009-06-08 18:33:55 +00:00
|
|
|
|
|
|
|
env = g_getenv ("GST_DEBUG_OPTIONS");
|
|
|
|
if (env != NULL) {
|
|
|
|
if (strstr (env, "full_tags") || strstr (env, "full-tags"))
|
|
|
|
pretty_tags = FALSE;
|
|
|
|
else if (strstr (env, "pretty_tags") || strstr (env, "pretty-tags"))
|
|
|
|
pretty_tags = TRUE;
|
|
|
|
}
|
2014-01-16 19:11:03 +00:00
|
|
|
|
|
|
|
if (g_getenv ("GST_DEBUG_NO_COLOR") != NULL)
|
|
|
|
gst_debug_set_color_mode (GST_DEBUG_COLOR_MODE_OFF);
|
|
|
|
env = g_getenv ("GST_DEBUG_COLOR_MODE");
|
|
|
|
if (env)
|
|
|
|
gst_debug_set_color_mode_from_string (env);
|
|
|
|
|
2017-12-02 12:29:20 +00:00
|
|
|
env = g_getenv ("GST_DEBUG");
|
|
|
|
if (env)
|
|
|
|
gst_debug_set_threshold_from_string (env, FALSE);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
/* we can't do this further above, because we initialize the GST_CAT_DEFAULT struct */
|
2004-04-15 23:25:39 +00:00
|
|
|
#define GST_CAT_DEFAULT _GST_CAT_DEBUG
|
2001-04-27 20:31:22 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
/**
|
|
|
|
* gst_debug_log:
|
|
|
|
* @category: category to log
|
|
|
|
* @level: level of the message is in
|
|
|
|
* @file: the file that emitted the message, usually the __FILE__ identifier
|
|
|
|
* @function: the function that emitted the message
|
|
|
|
* @line: the line from that the message was emitted, usually __LINE__
|
2010-12-07 18:35:04 +00:00
|
|
|
* @object: (transfer none) (allow-none): the object this message relates to,
|
2014-05-29 21:54:34 +00:00
|
|
|
* or %NULL if none
|
2003-06-29 14:05:49 +00:00
|
|
|
* @format: a printf style format string
|
|
|
|
* @...: optional arguments for the format
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2003-06-29 14:05:49 +00:00
|
|
|
* Logs the given message using the currently registered debugging handlers.
|
2001-05-25 21:00:07 +00:00
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
void
|
|
|
|
gst_debug_log (GstDebugCategory * category, GstDebugLevel level,
|
|
|
|
const gchar * file, const gchar * function, gint line,
|
|
|
|
GObject * object, const gchar * format, ...)
|
2003-06-29 14:05:49 +00:00
|
|
|
{
|
|
|
|
va_list var_args;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
va_start (var_args, format);
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_debug_log_valist (category, level, file, function, line, object, format,
|
|
|
|
var_args);
|
2003-06-29 14:05:49 +00:00
|
|
|
va_end (var_args);
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2010-09-23 11:49:59 +00:00
|
|
|
/* based on g_basename(), which we can't use because it was deprecated */
|
|
|
|
static inline const gchar *
|
|
|
|
gst_path_basename (const gchar * file_name)
|
|
|
|
{
|
|
|
|
register const gchar *base;
|
|
|
|
|
|
|
|
base = strrchr (file_name, G_DIR_SEPARATOR);
|
|
|
|
|
|
|
|
{
|
|
|
|
const gchar *q = strrchr (file_name, '/');
|
|
|
|
if (base == NULL || (q != NULL && q > base))
|
|
|
|
base = q;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (base)
|
|
|
|
return base + 1;
|
|
|
|
|
|
|
|
if (g_ascii_isalpha (file_name[0]) && file_name[1] == ':')
|
|
|
|
return file_name + 2;
|
|
|
|
|
|
|
|
return file_name;
|
|
|
|
}
|
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
/**
|
2003-11-24 02:09:23 +00:00
|
|
|
* gst_debug_log_valist:
|
2003-06-29 14:05:49 +00:00
|
|
|
* @category: category to log
|
|
|
|
* @level: level of the message is in
|
|
|
|
* @file: the file that emitted the message, usually the __FILE__ identifier
|
|
|
|
* @function: the function that emitted the message
|
|
|
|
* @line: the line from that the message was emitted, usually __LINE__
|
2010-12-07 18:35:04 +00:00
|
|
|
* @object: (transfer none) (allow-none): the object this message relates to,
|
2014-05-29 21:54:34 +00:00
|
|
|
* or %NULL if none
|
2003-06-29 14:05:49 +00:00
|
|
|
* @format: a printf style format string
|
|
|
|
* @args: optional arguments for the format
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2003-06-29 14:05:49 +00:00
|
|
|
* Logs the given message using the currently registered debugging handlers.
|
2001-05-25 21:00:07 +00:00
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
void
|
|
|
|
gst_debug_log_valist (GstDebugCategory * category, GstDebugLevel level,
|
|
|
|
const gchar * file, const gchar * function, gint line,
|
|
|
|
GObject * object, const gchar * format, va_list args)
|
2003-06-29 14:05:49 +00:00
|
|
|
{
|
2004-01-10 01:49:00 +00:00
|
|
|
GstDebugMessage message;
|
2003-06-29 14:05:49 +00:00
|
|
|
LogFuncEntry *entry;
|
|
|
|
GSList *handler;
|
|
|
|
|
|
|
|
g_return_if_fail (category != NULL);
|
2015-03-12 13:14:52 +00:00
|
|
|
|
|
|
|
if (level > gst_debug_category_get_threshold (category))
|
|
|
|
return;
|
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
g_return_if_fail (file != NULL);
|
|
|
|
g_return_if_fail (function != NULL);
|
|
|
|
g_return_if_fail (format != NULL);
|
|
|
|
|
2004-01-10 01:49:00 +00:00
|
|
|
message.message = NULL;
|
|
|
|
message.format = format;
|
2004-01-12 22:33:11 +00:00
|
|
|
G_VA_COPY (message.arguments, args);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2004-01-06 21:41:05 +00:00
|
|
|
handler = __log_functions;
|
|
|
|
while (handler) {
|
|
|
|
entry = handler->data;
|
|
|
|
handler = g_slist_next (handler);
|
2004-03-13 15:27:01 +00:00
|
|
|
entry->func (category, level, file, function, line, object, &message,
|
2004-03-15 19:27:17 +00:00
|
|
|
entry->user_data);
|
2004-01-10 01:49:00 +00:00
|
|
|
}
|
|
|
|
g_free (message.message);
|
2004-01-12 22:44:38 +00:00
|
|
|
va_end (message.arguments);
|
2004-01-10 01:49:00 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2004-01-10 01:49:00 +00:00
|
|
|
/**
|
|
|
|
* gst_debug_message_get:
|
|
|
|
* @message: a debug message
|
|
|
|
*
|
2004-03-30 09:15:47 +00:00
|
|
|
* Gets the string representation of a #GstDebugMessage. This function is used
|
2004-01-10 01:49:00 +00:00
|
|
|
* in debug handlers to extract the message.
|
2004-03-30 07:36:19 +00:00
|
|
|
*
|
2017-10-22 12:35:30 +00:00
|
|
|
* Returns: (nullable): the string representation of a #GstDebugMessage.
|
2004-01-10 01:49:00 +00:00
|
|
|
*/
|
|
|
|
const gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_debug_message_get (GstDebugMessage * message)
|
2004-01-10 01:49:00 +00:00
|
|
|
{
|
|
|
|
if (message->message == NULL) {
|
2013-03-30 17:20:13 +00:00
|
|
|
int len;
|
|
|
|
|
|
|
|
len = __gst_vasprintf (&message->message, message->format,
|
|
|
|
message->arguments);
|
|
|
|
|
|
|
|
if (len < 0)
|
|
|
|
message->message = NULL;
|
2003-06-29 14:05:49 +00:00
|
|
|
}
|
2004-01-10 01:49:00 +00:00
|
|
|
return message->message;
|
2003-06-29 14:05:49 +00:00
|
|
|
}
|
2004-01-10 01:49:00 +00:00
|
|
|
|
2009-06-08 18:33:55 +00:00
|
|
|
#define MAX_BUFFER_DUMP_STRING_LEN 100
|
|
|
|
|
|
|
|
/* structure_to_pretty_string:
|
2013-03-30 16:03:44 +00:00
|
|
|
* @str: a serialized #GstStructure
|
2009-06-08 18:33:55 +00:00
|
|
|
*
|
2013-03-30 16:03:44 +00:00
|
|
|
* If the serialized structure contains large buffers such as images the hex
|
|
|
|
* representation of those buffers will be shortened so that the string remains
|
|
|
|
* readable.
|
2009-06-08 18:33:55 +00:00
|
|
|
*
|
2013-03-30 16:03:44 +00:00
|
|
|
* Returns: the filtered string
|
2009-06-08 18:33:55 +00:00
|
|
|
*/
|
|
|
|
static gchar *
|
2013-03-30 16:03:44 +00:00
|
|
|
prettify_structure_string (gchar * str)
|
2009-06-08 18:33:55 +00:00
|
|
|
{
|
2013-03-30 16:03:44 +00:00
|
|
|
gchar *pos = str, *end;
|
2009-06-08 18:33:55 +00:00
|
|
|
|
|
|
|
while ((pos = strstr (pos, "(buffer)"))) {
|
|
|
|
guint count = 0;
|
|
|
|
|
|
|
|
pos += strlen ("(buffer)");
|
|
|
|
for (end = pos; *end != '\0' && *end != ';' && *end != ' '; ++end)
|
|
|
|
++count;
|
|
|
|
if (count > MAX_BUFFER_DUMP_STRING_LEN) {
|
|
|
|
memcpy (pos + MAX_BUFFER_DUMP_STRING_LEN - 6, "..", 2);
|
|
|
|
memcpy (pos + MAX_BUFFER_DUMP_STRING_LEN - 4, pos + count - 4, 4);
|
2013-11-21 15:04:04 +00:00
|
|
|
memmove (pos + MAX_BUFFER_DUMP_STRING_LEN, pos + count,
|
2009-06-08 18:33:55 +00:00
|
|
|
strlen (pos + count) + 1);
|
|
|
|
pos += MAX_BUFFER_DUMP_STRING_LEN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline gchar *
|
2011-05-10 13:33:53 +00:00
|
|
|
gst_info_structure_to_string (const GstStructure * s)
|
2009-06-08 18:33:55 +00:00
|
|
|
{
|
2013-03-30 16:03:44 +00:00
|
|
|
if (G_LIKELY (s)) {
|
2015-03-10 09:21:22 +00:00
|
|
|
gchar *str = gst_structure_to_string (s);
|
2013-03-30 16:03:44 +00:00
|
|
|
if (G_UNLIKELY (pretty_tags && s->name == GST_QUARK (TAGLIST)))
|
|
|
|
return prettify_structure_string (str);
|
|
|
|
else
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline gchar *
|
2013-04-01 21:13:10 +00:00
|
|
|
gst_info_describe_buffer (GstBuffer * buffer)
|
2013-03-30 16:03:44 +00:00
|
|
|
{
|
2015-02-16 19:24:44 +00:00
|
|
|
const gchar *offset_str = "none";
|
|
|
|
const gchar *offset_end_str = "none";
|
|
|
|
gchar offset_buf[32], offset_end_buf[32];
|
|
|
|
|
|
|
|
if (GST_BUFFER_OFFSET_IS_VALID (buffer)) {
|
|
|
|
g_snprintf (offset_buf, sizeof (offset_buf), "%" G_GUINT64_FORMAT,
|
|
|
|
GST_BUFFER_OFFSET (buffer));
|
|
|
|
offset_str = offset_buf;
|
|
|
|
}
|
|
|
|
if (GST_BUFFER_OFFSET_END_IS_VALID (buffer)) {
|
|
|
|
g_snprintf (offset_end_buf, sizeof (offset_end_buf), "%" G_GUINT64_FORMAT,
|
|
|
|
GST_BUFFER_OFFSET_END (buffer));
|
|
|
|
offset_end_str = offset_end_buf;
|
|
|
|
}
|
|
|
|
|
2013-03-30 16:03:44 +00:00
|
|
|
return g_strdup_printf ("buffer: %p, pts %" GST_TIME_FORMAT ", dts %"
|
|
|
|
GST_TIME_FORMAT ", dur %" GST_TIME_FORMAT ", size %" G_GSIZE_FORMAT
|
2015-02-16 19:24:44 +00:00
|
|
|
", offset %s, offset_end %s, flags 0x%x", buffer,
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_PTS (buffer)),
|
2013-03-30 16:03:44 +00:00
|
|
|
GST_TIME_ARGS (GST_BUFFER_DTS (buffer)),
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_DURATION (buffer)),
|
2015-02-16 19:24:44 +00:00
|
|
|
gst_buffer_get_size (buffer), offset_str, offset_end_str,
|
|
|
|
GST_BUFFER_FLAGS (buffer));
|
2013-03-30 16:03:44 +00:00
|
|
|
}
|
|
|
|
|
2016-01-08 19:25:24 +00:00
|
|
|
static inline gchar *
|
|
|
|
gst_info_describe_buffer_list (GstBufferList * list)
|
|
|
|
{
|
|
|
|
GstClockTime pts = GST_CLOCK_TIME_NONE;
|
|
|
|
GstClockTime dts = GST_CLOCK_TIME_NONE;
|
|
|
|
gsize total_size = 0;
|
|
|
|
guint n, i;
|
|
|
|
|
|
|
|
n = gst_buffer_list_length (list);
|
|
|
|
for (i = 0; i < n; ++i) {
|
|
|
|
GstBuffer *buf = gst_buffer_list_get (list, i);
|
|
|
|
|
|
|
|
if (i == 0) {
|
|
|
|
pts = GST_BUFFER_PTS (buf);
|
|
|
|
dts = GST_BUFFER_DTS (buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
total_size += gst_buffer_get_size (buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
return g_strdup_printf ("bufferlist: %p, %u buffers, pts %" GST_TIME_FORMAT
|
|
|
|
", dts %" GST_TIME_FORMAT ", size %" G_GSIZE_FORMAT, list, n,
|
|
|
|
GST_TIME_ARGS (pts), GST_TIME_ARGS (dts), total_size);
|
|
|
|
}
|
|
|
|
|
2013-03-30 16:03:44 +00:00
|
|
|
static inline gchar *
|
2013-04-01 21:13:10 +00:00
|
|
|
gst_info_describe_event (GstEvent * event)
|
2013-03-30 16:03:44 +00:00
|
|
|
{
|
|
|
|
gchar *s, *ret;
|
|
|
|
|
|
|
|
s = gst_info_structure_to_string (gst_event_get_structure (event));
|
|
|
|
ret = g_strdup_printf ("%s event: %p, time %" GST_TIME_FORMAT
|
|
|
|
", seq-num %d, %s", GST_EVENT_TYPE_NAME (event), event,
|
|
|
|
GST_TIME_ARGS (GST_EVENT_TIMESTAMP (event)), GST_EVENT_SEQNUM (event),
|
|
|
|
(s ? s : "(NULL)"));
|
|
|
|
g_free (s);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline gchar *
|
2013-04-01 21:13:10 +00:00
|
|
|
gst_info_describe_message (GstMessage * message)
|
2013-03-30 16:03:44 +00:00
|
|
|
{
|
|
|
|
gchar *s, *ret;
|
|
|
|
|
|
|
|
s = gst_info_structure_to_string (gst_message_get_structure (message));
|
|
|
|
ret = g_strdup_printf ("%s message: %p, time %" GST_TIME_FORMAT
|
|
|
|
", seq-num %d, element '%s', %s", GST_MESSAGE_TYPE_NAME (message),
|
|
|
|
message, GST_TIME_ARGS (GST_MESSAGE_TIMESTAMP (message)),
|
|
|
|
GST_MESSAGE_SEQNUM (message),
|
|
|
|
((message->src) ? GST_ELEMENT_NAME (message->src) : "(NULL)"),
|
|
|
|
(s ? s : "(NULL)"));
|
|
|
|
g_free (s);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline gchar *
|
2013-04-01 21:13:10 +00:00
|
|
|
gst_info_describe_query (GstQuery * query)
|
2013-03-30 16:03:44 +00:00
|
|
|
{
|
|
|
|
gchar *s, *ret;
|
|
|
|
|
|
|
|
s = gst_info_structure_to_string (gst_query_get_structure (query));
|
|
|
|
ret = g_strdup_printf ("%s query: %p, %s", GST_QUERY_TYPE_NAME (query),
|
|
|
|
query, (s ? s : "(NULL)"));
|
|
|
|
g_free (s);
|
|
|
|
return ret;
|
2009-06-08 18:33:55 +00:00
|
|
|
}
|
configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
Original commit message from CVS:
* configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
GST_PRINTF_EXTENSION_FORMAT_DEFINE.
* docs/random/ds/0.9-suggested-changes: Notes from Company.
* gst/gstcaps.c: (gst_caps_to_string): Add comment.
* gst/gstconfig.h.in: Add define for GST_PTR_FORMAT
* gst/gstinfo.c: (_gst_debug_init), (gst_debug_print_object),
(gst_debug_log_default), (_gst_info_printf_extension),
(_gst_info_printf_extension_arginfo): Add printf extension.
* gst/gstinfo.h: remove G_GNUC_PRINTF, because it doesn't work with %P
* gst/gststructure.c: (gst_structure_to_string),
(_gst_structure_parse_value): Use gst_value_deserialize() and
remove old code.
* gst/gstvalue.c: (gst_value_deserialize_fourcc),
(gst_value_deserialize_boolean), (gst_strtoi),
(gst_value_deserialize_int), (gst_value_deserialize_double),
(gst_value_deserialize_string), (gst_value_deserialize): Implement
a bunch of deserialize functions and gst_value_deserialize.
* gst/gstvalue.h: er, _de_serialize, not unserialize
* testsuite/caps/string-conversions.c: (main): We don't currently
handle (float) in caps, so convert these to (double).
* testsuite/debug/Makefile.am: Add new test for the printf extension
* testsuite/debug/printf_extension.c: (main): same
2004-01-29 01:20:23 +00:00
|
|
|
|
2016-07-27 11:39:50 +00:00
|
|
|
static inline gchar *
|
|
|
|
gst_info_describe_stream (GstStream * stream)
|
|
|
|
{
|
|
|
|
gchar *ret, *caps_str = NULL, *tags_str = NULL;
|
|
|
|
GstCaps *caps;
|
|
|
|
GstTagList *tags;
|
|
|
|
|
|
|
|
caps = gst_stream_get_caps (stream);
|
|
|
|
if (caps) {
|
|
|
|
caps_str = gst_caps_to_string (caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
}
|
|
|
|
|
|
|
|
tags = gst_stream_get_tags (stream);
|
|
|
|
if (tags) {
|
|
|
|
tags_str = gst_tag_list_to_string (tags);
|
|
|
|
gst_tag_list_unref (tags);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret =
|
|
|
|
g_strdup_printf ("stream %s %p, ID %s, flags 0x%x, caps [%s], tags [%s]",
|
|
|
|
gst_stream_type_get_name (gst_stream_get_stream_type (stream)), stream,
|
|
|
|
gst_stream_get_stream_id (stream), gst_stream_get_stream_flags (stream),
|
|
|
|
caps_str ? caps_str : "", tags_str ? tags_str : "");
|
|
|
|
|
|
|
|
g_free (caps_str);
|
|
|
|
g_free (tags_str);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline gchar *
|
|
|
|
gst_info_describe_stream_collection (GstStreamCollection * collection)
|
|
|
|
{
|
|
|
|
gchar *ret;
|
|
|
|
GString *streams_str;
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
streams_str = g_string_new ("<");
|
|
|
|
for (i = 0; i < gst_stream_collection_get_size (collection); i++) {
|
|
|
|
GstStream *stream = gst_stream_collection_get_stream (collection, i);
|
|
|
|
gchar *s;
|
|
|
|
|
|
|
|
s = gst_info_describe_stream (stream);
|
|
|
|
g_string_append_printf (streams_str, " %s,", s);
|
|
|
|
g_free (s);
|
|
|
|
}
|
|
|
|
g_string_append (streams_str, " >");
|
|
|
|
|
|
|
|
ret = g_strdup_printf ("collection %p (%d streams) %s", collection,
|
|
|
|
gst_stream_collection_get_size (collection), streams_str->str);
|
|
|
|
|
|
|
|
g_string_free (streams_str, TRUE);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
Original commit message from CVS:
* configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
GST_PRINTF_EXTENSION_FORMAT_DEFINE.
* docs/random/ds/0.9-suggested-changes: Notes from Company.
* gst/gstcaps.c: (gst_caps_to_string): Add comment.
* gst/gstconfig.h.in: Add define for GST_PTR_FORMAT
* gst/gstinfo.c: (_gst_debug_init), (gst_debug_print_object),
(gst_debug_log_default), (_gst_info_printf_extension),
(_gst_info_printf_extension_arginfo): Add printf extension.
* gst/gstinfo.h: remove G_GNUC_PRINTF, because it doesn't work with %P
* gst/gststructure.c: (gst_structure_to_string),
(_gst_structure_parse_value): Use gst_value_deserialize() and
remove old code.
* gst/gstvalue.c: (gst_value_deserialize_fourcc),
(gst_value_deserialize_boolean), (gst_strtoi),
(gst_value_deserialize_int), (gst_value_deserialize_double),
(gst_value_deserialize_string), (gst_value_deserialize): Implement
a bunch of deserialize functions and gst_value_deserialize.
* gst/gstvalue.h: er, _de_serialize, not unserialize
* testsuite/caps/string-conversions.c: (main): We don't currently
handle (float) in caps, so convert these to (double).
* testsuite/debug/Makefile.am: Add new test for the printf extension
* testsuite/debug/printf_extension.c: (main): same
2004-01-29 01:20:23 +00:00
|
|
|
static gchar *
|
|
|
|
gst_debug_print_object (gpointer ptr)
|
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
GObject *object = (GObject *) ptr;
|
configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
Original commit message from CVS:
* configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
GST_PRINTF_EXTENSION_FORMAT_DEFINE.
* docs/random/ds/0.9-suggested-changes: Notes from Company.
* gst/gstcaps.c: (gst_caps_to_string): Add comment.
* gst/gstconfig.h.in: Add define for GST_PTR_FORMAT
* gst/gstinfo.c: (_gst_debug_init), (gst_debug_print_object),
(gst_debug_log_default), (_gst_info_printf_extension),
(_gst_info_printf_extension_arginfo): Add printf extension.
* gst/gstinfo.h: remove G_GNUC_PRINTF, because it doesn't work with %P
* gst/gststructure.c: (gst_structure_to_string),
(_gst_structure_parse_value): Use gst_value_deserialize() and
remove old code.
* gst/gstvalue.c: (gst_value_deserialize_fourcc),
(gst_value_deserialize_boolean), (gst_strtoi),
(gst_value_deserialize_int), (gst_value_deserialize_double),
(gst_value_deserialize_string), (gst_value_deserialize): Implement
a bunch of deserialize functions and gst_value_deserialize.
* gst/gstvalue.h: er, _de_serialize, not unserialize
* testsuite/caps/string-conversions.c: (main): We don't currently
handle (float) in caps, so convert these to (double).
* testsuite/debug/Makefile.am: Add new test for the printf extension
* testsuite/debug/printf_extension.c: (main): same
2004-01-29 01:20:23 +00:00
|
|
|
|
|
|
|
#ifdef unused
|
|
|
|
/* This is a cute trick to detect unmapped memory, but is unportable,
|
|
|
|
* slow, screws around with madvise, and not actually that useful. */
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
ret = madvise ((void *) ((unsigned long) ptr & (~0xfff)), 4096, 0);
|
configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
Original commit message from CVS:
* configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
GST_PRINTF_EXTENSION_FORMAT_DEFINE.
* docs/random/ds/0.9-suggested-changes: Notes from Company.
* gst/gstcaps.c: (gst_caps_to_string): Add comment.
* gst/gstconfig.h.in: Add define for GST_PTR_FORMAT
* gst/gstinfo.c: (_gst_debug_init), (gst_debug_print_object),
(gst_debug_log_default), (_gst_info_printf_extension),
(_gst_info_printf_extension_arginfo): Add printf extension.
* gst/gstinfo.h: remove G_GNUC_PRINTF, because it doesn't work with %P
* gst/gststructure.c: (gst_structure_to_string),
(_gst_structure_parse_value): Use gst_value_deserialize() and
remove old code.
* gst/gstvalue.c: (gst_value_deserialize_fourcc),
(gst_value_deserialize_boolean), (gst_strtoi),
(gst_value_deserialize_int), (gst_value_deserialize_double),
(gst_value_deserialize_string), (gst_value_deserialize): Implement
a bunch of deserialize functions and gst_value_deserialize.
* gst/gstvalue.h: er, _de_serialize, not unserialize
* testsuite/caps/string-conversions.c: (main): We don't currently
handle (float) in caps, so convert these to (double).
* testsuite/debug/Makefile.am: Add new test for the printf extension
* testsuite/debug/printf_extension.c: (main): same
2004-01-29 01:20:23 +00:00
|
|
|
if (ret == -1 && errno == ENOMEM) {
|
|
|
|
buffer = g_strdup_printf ("%p (unmapped memory)", ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* nicely printed object */
|
|
|
|
if (object == NULL) {
|
2004-02-20 13:18:32 +00:00
|
|
|
return g_strdup ("(NULL)");
|
configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
Original commit message from CVS:
* configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
GST_PRINTF_EXTENSION_FORMAT_DEFINE.
* docs/random/ds/0.9-suggested-changes: Notes from Company.
* gst/gstcaps.c: (gst_caps_to_string): Add comment.
* gst/gstconfig.h.in: Add define for GST_PTR_FORMAT
* gst/gstinfo.c: (_gst_debug_init), (gst_debug_print_object),
(gst_debug_log_default), (_gst_info_printf_extension),
(_gst_info_printf_extension_arginfo): Add printf extension.
* gst/gstinfo.h: remove G_GNUC_PRINTF, because it doesn't work with %P
* gst/gststructure.c: (gst_structure_to_string),
(_gst_structure_parse_value): Use gst_value_deserialize() and
remove old code.
* gst/gstvalue.c: (gst_value_deserialize_fourcc),
(gst_value_deserialize_boolean), (gst_strtoi),
(gst_value_deserialize_int), (gst_value_deserialize_double),
(gst_value_deserialize_string), (gst_value_deserialize): Implement
a bunch of deserialize functions and gst_value_deserialize.
* gst/gstvalue.h: er, _de_serialize, not unserialize
* testsuite/caps/string-conversions.c: (main): We don't currently
handle (float) in caps, so convert these to (double).
* testsuite/debug/Makefile.am: Add new test for the printf extension
* testsuite/debug/printf_extension.c: (main): same
2004-01-29 01:20:23 +00:00
|
|
|
}
|
2014-06-03 12:45:22 +00:00
|
|
|
if (GST_IS_CAPS (ptr)) {
|
2011-05-10 13:33:53 +00:00
|
|
|
return gst_caps_to_string ((const GstCaps *) ptr);
|
configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
Original commit message from CVS:
* configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
GST_PRINTF_EXTENSION_FORMAT_DEFINE.
* docs/random/ds/0.9-suggested-changes: Notes from Company.
* gst/gstcaps.c: (gst_caps_to_string): Add comment.
* gst/gstconfig.h.in: Add define for GST_PTR_FORMAT
* gst/gstinfo.c: (_gst_debug_init), (gst_debug_print_object),
(gst_debug_log_default), (_gst_info_printf_extension),
(_gst_info_printf_extension_arginfo): Add printf extension.
* gst/gstinfo.h: remove G_GNUC_PRINTF, because it doesn't work with %P
* gst/gststructure.c: (gst_structure_to_string),
(_gst_structure_parse_value): Use gst_value_deserialize() and
remove old code.
* gst/gstvalue.c: (gst_value_deserialize_fourcc),
(gst_value_deserialize_boolean), (gst_strtoi),
(gst_value_deserialize_int), (gst_value_deserialize_double),
(gst_value_deserialize_string), (gst_value_deserialize): Implement
a bunch of deserialize functions and gst_value_deserialize.
* gst/gstvalue.h: er, _de_serialize, not unserialize
* testsuite/caps/string-conversions.c: (main): We don't currently
handle (float) in caps, so convert these to (double).
* testsuite/debug/Makefile.am: Add new test for the printf extension
* testsuite/debug/printf_extension.c: (main): same
2004-01-29 01:20:23 +00:00
|
|
|
}
|
2014-06-03 12:45:22 +00:00
|
|
|
if (GST_IS_STRUCTURE (ptr)) {
|
2011-05-10 13:33:53 +00:00
|
|
|
return gst_info_structure_to_string ((const GstStructure *) ptr);
|
configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
Original commit message from CVS:
* configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
GST_PRINTF_EXTENSION_FORMAT_DEFINE.
* docs/random/ds/0.9-suggested-changes: Notes from Company.
* gst/gstcaps.c: (gst_caps_to_string): Add comment.
* gst/gstconfig.h.in: Add define for GST_PTR_FORMAT
* gst/gstinfo.c: (_gst_debug_init), (gst_debug_print_object),
(gst_debug_log_default), (_gst_info_printf_extension),
(_gst_info_printf_extension_arginfo): Add printf extension.
* gst/gstinfo.h: remove G_GNUC_PRINTF, because it doesn't work with %P
* gst/gststructure.c: (gst_structure_to_string),
(_gst_structure_parse_value): Use gst_value_deserialize() and
remove old code.
* gst/gstvalue.c: (gst_value_deserialize_fourcc),
(gst_value_deserialize_boolean), (gst_strtoi),
(gst_value_deserialize_int), (gst_value_deserialize_double),
(gst_value_deserialize_string), (gst_value_deserialize): Implement
a bunch of deserialize functions and gst_value_deserialize.
* gst/gstvalue.h: er, _de_serialize, not unserialize
* testsuite/caps/string-conversions.c: (main): We don't currently
handle (float) in caps, so convert these to (double).
* testsuite/debug/Makefile.am: Add new test for the printf extension
* testsuite/debug/printf_extension.c: (main): same
2004-01-29 01:20:23 +00:00
|
|
|
}
|
2013-04-01 20:23:21 +00:00
|
|
|
if (*(GType *) ptr == GST_TYPE_CAPS_FEATURES) {
|
2013-03-30 14:35:19 +00:00
|
|
|
return gst_caps_features_to_string ((const GstCapsFeatures *) ptr);
|
|
|
|
}
|
2014-06-03 12:45:22 +00:00
|
|
|
if (GST_IS_TAG_LIST (ptr)) {
|
2013-03-30 16:03:44 +00:00
|
|
|
gchar *str = gst_tag_list_to_string ((GstTagList *) ptr);
|
|
|
|
if (G_UNLIKELY (pretty_tags))
|
|
|
|
return prettify_structure_string (str);
|
|
|
|
else
|
|
|
|
return str;
|
2012-07-14 17:52:50 +00:00
|
|
|
}
|
|
|
|
if (*(GType *) ptr == GST_TYPE_DATE_TIME) {
|
|
|
|
return __gst_date_time_serialize ((GstDateTime *) ptr, TRUE);
|
|
|
|
}
|
2011-10-07 14:36:10 +00:00
|
|
|
if (GST_IS_BUFFER (ptr)) {
|
2013-04-01 21:13:10 +00:00
|
|
|
return gst_info_describe_buffer (GST_BUFFER_CAST (ptr));
|
2011-10-07 14:36:10 +00:00
|
|
|
}
|
2016-01-08 19:25:24 +00:00
|
|
|
if (GST_IS_BUFFER_LIST (ptr)) {
|
|
|
|
return gst_info_describe_buffer_list (GST_BUFFER_LIST_CAST (ptr));
|
|
|
|
}
|
configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
Original commit message from CVS:
* configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
GST_PRINTF_EXTENSION_FORMAT_DEFINE.
* docs/random/ds/0.9-suggested-changes: Notes from Company.
* gst/gstcaps.c: (gst_caps_to_string): Add comment.
* gst/gstconfig.h.in: Add define for GST_PTR_FORMAT
* gst/gstinfo.c: (_gst_debug_init), (gst_debug_print_object),
(gst_debug_log_default), (_gst_info_printf_extension),
(_gst_info_printf_extension_arginfo): Add printf extension.
* gst/gstinfo.h: remove G_GNUC_PRINTF, because it doesn't work with %P
* gst/gststructure.c: (gst_structure_to_string),
(_gst_structure_parse_value): Use gst_value_deserialize() and
remove old code.
* gst/gstvalue.c: (gst_value_deserialize_fourcc),
(gst_value_deserialize_boolean), (gst_strtoi),
(gst_value_deserialize_int), (gst_value_deserialize_double),
(gst_value_deserialize_string), (gst_value_deserialize): Implement
a bunch of deserialize functions and gst_value_deserialize.
* gst/gstvalue.h: er, _de_serialize, not unserialize
* testsuite/caps/string-conversions.c: (main): We don't currently
handle (float) in caps, so convert these to (double).
* testsuite/debug/Makefile.am: Add new test for the printf extension
* testsuite/debug/printf_extension.c: (main): same
2004-01-29 01:20:23 +00:00
|
|
|
#ifdef USE_POISONING
|
2004-03-13 15:27:01 +00:00
|
|
|
if (*(guint32 *) ptr == 0xffffffff) {
|
configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
Original commit message from CVS:
* configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
GST_PRINTF_EXTENSION_FORMAT_DEFINE.
* docs/random/ds/0.9-suggested-changes: Notes from Company.
* gst/gstcaps.c: (gst_caps_to_string): Add comment.
* gst/gstconfig.h.in: Add define for GST_PTR_FORMAT
* gst/gstinfo.c: (_gst_debug_init), (gst_debug_print_object),
(gst_debug_log_default), (_gst_info_printf_extension),
(_gst_info_printf_extension_arginfo): Add printf extension.
* gst/gstinfo.h: remove G_GNUC_PRINTF, because it doesn't work with %P
* gst/gststructure.c: (gst_structure_to_string),
(_gst_structure_parse_value): Use gst_value_deserialize() and
remove old code.
* gst/gstvalue.c: (gst_value_deserialize_fourcc),
(gst_value_deserialize_boolean), (gst_strtoi),
(gst_value_deserialize_int), (gst_value_deserialize_double),
(gst_value_deserialize_string), (gst_value_deserialize): Implement
a bunch of deserialize functions and gst_value_deserialize.
* gst/gstvalue.h: er, _de_serialize, not unserialize
* testsuite/caps/string-conversions.c: (main): We don't currently
handle (float) in caps, so convert these to (double).
* testsuite/debug/Makefile.am: Add new test for the printf extension
* testsuite/debug/printf_extension.c: (main): same
2004-01-29 01:20:23 +00:00
|
|
|
return g_strdup_printf ("<poisoned@%p>", ptr);
|
|
|
|
}
|
|
|
|
#endif
|
2006-08-14 17:29:31 +00:00
|
|
|
if (GST_IS_MESSAGE (object)) {
|
2013-04-01 21:13:10 +00:00
|
|
|
return gst_info_describe_message (GST_MESSAGE_CAST (object));
|
2006-08-14 17:29:31 +00:00
|
|
|
}
|
2009-03-20 00:42:51 +00:00
|
|
|
if (GST_IS_QUERY (object)) {
|
2013-04-01 21:13:10 +00:00
|
|
|
return gst_info_describe_query (GST_QUERY_CAST (object));
|
2009-03-20 00:42:51 +00:00
|
|
|
}
|
2010-02-23 21:50:36 +00:00
|
|
|
if (GST_IS_EVENT (object)) {
|
2013-04-01 21:13:10 +00:00
|
|
|
return gst_info_describe_event (GST_EVENT_CAST (object));
|
2010-02-23 21:50:36 +00:00
|
|
|
}
|
2013-03-28 14:35:13 +00:00
|
|
|
if (GST_IS_CONTEXT (object)) {
|
|
|
|
GstContext *context = GST_CONTEXT_CAST (object);
|
|
|
|
gchar *s, *ret;
|
2013-09-17 11:28:42 +00:00
|
|
|
const gchar *type;
|
2013-03-28 14:35:13 +00:00
|
|
|
const GstStructure *structure;
|
|
|
|
|
2013-09-17 11:28:42 +00:00
|
|
|
type = gst_context_get_context_type (context);
|
2013-03-28 14:35:13 +00:00
|
|
|
structure = gst_context_get_structure (context);
|
|
|
|
|
2013-09-17 11:28:42 +00:00
|
|
|
s = gst_info_structure_to_string (structure);
|
2013-03-28 14:35:13 +00:00
|
|
|
|
2013-09-17 11:28:42 +00:00
|
|
|
ret = g_strdup_printf ("context '%s'='%s'", type, s);
|
2013-03-28 14:35:13 +00:00
|
|
|
g_free (s);
|
|
|
|
return ret;
|
|
|
|
}
|
2016-07-27 11:39:50 +00:00
|
|
|
if (GST_IS_STREAM (object)) {
|
|
|
|
return gst_info_describe_stream (GST_STREAM_CAST (object));
|
|
|
|
}
|
|
|
|
if (GST_IS_STREAM_COLLECTION (object)) {
|
|
|
|
return
|
|
|
|
gst_info_describe_stream_collection (GST_STREAM_COLLECTION_CAST
|
|
|
|
(object));
|
|
|
|
}
|
2014-06-03 12:47:17 +00:00
|
|
|
if (GST_IS_PAD (object) && GST_OBJECT_NAME (object)) {
|
|
|
|
return g_strdup_printf ("<%s:%s>", GST_DEBUG_PAD_NAME (object));
|
|
|
|
}
|
|
|
|
if (GST_IS_OBJECT (object) && GST_OBJECT_NAME (object)) {
|
|
|
|
return g_strdup_printf ("<%s>", GST_OBJECT_NAME (object));
|
|
|
|
}
|
|
|
|
if (G_IS_OBJECT (object)) {
|
|
|
|
return g_strdup_printf ("<%s@%p>", G_OBJECT_TYPE_NAME (object), object);
|
|
|
|
}
|
configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
Original commit message from CVS:
* configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
GST_PRINTF_EXTENSION_FORMAT_DEFINE.
* docs/random/ds/0.9-suggested-changes: Notes from Company.
* gst/gstcaps.c: (gst_caps_to_string): Add comment.
* gst/gstconfig.h.in: Add define for GST_PTR_FORMAT
* gst/gstinfo.c: (_gst_debug_init), (gst_debug_print_object),
(gst_debug_log_default), (_gst_info_printf_extension),
(_gst_info_printf_extension_arginfo): Add printf extension.
* gst/gstinfo.h: remove G_GNUC_PRINTF, because it doesn't work with %P
* gst/gststructure.c: (gst_structure_to_string),
(_gst_structure_parse_value): Use gst_value_deserialize() and
remove old code.
* gst/gstvalue.c: (gst_value_deserialize_fourcc),
(gst_value_deserialize_boolean), (gst_strtoi),
(gst_value_deserialize_int), (gst_value_deserialize_double),
(gst_value_deserialize_string), (gst_value_deserialize): Implement
a bunch of deserialize functions and gst_value_deserialize.
* gst/gstvalue.h: er, _de_serialize, not unserialize
* testsuite/caps/string-conversions.c: (main): We don't currently
handle (float) in caps, so convert these to (double).
* testsuite/debug/Makefile.am: Add new test for the printf extension
* testsuite/debug/printf_extension.c: (main): same
2004-01-29 01:20:23 +00:00
|
|
|
|
|
|
|
return g_strdup_printf ("%p", ptr);
|
|
|
|
}
|
|
|
|
|
2006-08-09 15:13:14 +00:00
|
|
|
static gchar *
|
|
|
|
gst_debug_print_segment (gpointer ptr)
|
|
|
|
{
|
|
|
|
GstSegment *segment = (GstSegment *) ptr;
|
|
|
|
|
|
|
|
/* nicely printed segment */
|
|
|
|
if (segment == NULL) {
|
|
|
|
return g_strdup ("(NULL)");
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (segment->format) {
|
|
|
|
case GST_FORMAT_UNDEFINED:{
|
|
|
|
return g_strdup_printf ("UNDEFINED segment");
|
|
|
|
}
|
|
|
|
case GST_FORMAT_TIME:{
|
|
|
|
return g_strdup_printf ("time segment start=%" GST_TIME_FORMAT
|
2014-01-08 13:50:29 +00:00
|
|
|
", offset=%" GST_TIME_FORMAT ", stop=%" GST_TIME_FORMAT
|
|
|
|
", rate=%f, applied_rate=%f" ", flags=0x%02x, time=%" GST_TIME_FORMAT
|
|
|
|
", base=%" GST_TIME_FORMAT ", position %" GST_TIME_FORMAT
|
|
|
|
", duration %" GST_TIME_FORMAT, GST_TIME_ARGS (segment->start),
|
|
|
|
GST_TIME_ARGS (segment->offset), GST_TIME_ARGS (segment->stop),
|
2006-08-09 15:13:14 +00:00
|
|
|
segment->rate, segment->applied_rate, (guint) segment->flags,
|
2012-02-17 23:03:13 +00:00
|
|
|
GST_TIME_ARGS (segment->time), GST_TIME_ARGS (segment->base),
|
2012-02-20 13:22:00 +00:00
|
|
|
GST_TIME_ARGS (segment->position), GST_TIME_ARGS (segment->duration));
|
2006-08-09 15:13:14 +00:00
|
|
|
}
|
|
|
|
default:{
|
|
|
|
const gchar *format_name;
|
|
|
|
|
|
|
|
format_name = gst_format_get_name (segment->format);
|
|
|
|
if (G_UNLIKELY (format_name == NULL))
|
|
|
|
format_name = "(UNKNOWN FORMAT)";
|
|
|
|
return g_strdup_printf ("%s segment start=%" G_GINT64_FORMAT
|
2014-01-08 13:50:29 +00:00
|
|
|
", offset=%" G_GINT64_FORMAT ", stop=%" G_GINT64_FORMAT
|
|
|
|
", rate=%f, applied_rate=%f" ", flags=0x%02x, time=%" G_GINT64_FORMAT
|
|
|
|
", base=%" G_GINT64_FORMAT ", position %" G_GINT64_FORMAT
|
|
|
|
", duration %" G_GINT64_FORMAT, format_name, segment->start,
|
|
|
|
segment->offset, segment->stop, segment->rate, segment->applied_rate,
|
|
|
|
(guint) segment->flags, segment->time, segment->base,
|
|
|
|
segment->position, segment->duration);
|
2006-08-09 15:13:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-03-30 18:28:38 +00:00
|
|
|
|
|
|
|
static char *
|
|
|
|
gst_info_printf_pointer_extension_func (const char *format, void *ptr)
|
|
|
|
{
|
|
|
|
char *s = NULL;
|
|
|
|
|
|
|
|
if (format[0] == 'p' && format[1] == '\a') {
|
|
|
|
switch (format[2]) {
|
|
|
|
case 'A': /* GST_PTR_FORMAT */
|
|
|
|
s = gst_debug_print_object (ptr);
|
|
|
|
break;
|
|
|
|
case 'B': /* GST_SEGMENT_FORMAT */
|
|
|
|
s = gst_debug_print_segment (ptr);
|
|
|
|
break;
|
2016-01-18 20:12:53 +00:00
|
|
|
case 'a': /* GST_WRAPPED_PTR_FORMAT */
|
|
|
|
s = priv_gst_string_take_and_wrap (gst_debug_print_object (ptr));
|
|
|
|
break;
|
2013-03-30 18:28:38 +00:00
|
|
|
default:
|
|
|
|
/* must have been compiled against a newer version with an extension
|
|
|
|
* we don't known about yet - just ignore and fallback to %p below */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (s == NULL)
|
|
|
|
s = g_strdup_printf ("%p", ptr);
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
2006-09-25 10:36:23 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
/**
|
|
|
|
* gst_debug_construct_term_color:
|
|
|
|
* @colorinfo: the color info
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2003-06-29 14:05:49 +00:00
|
|
|
* Constructs a string that can be used for getting the desired color in color
|
|
|
|
* terminals.
|
|
|
|
* You need to free the string after use.
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2010-12-07 18:35:04 +00:00
|
|
|
* Returns: (transfer full) (type gchar*): a string containing the color
|
|
|
|
* definition
|
2003-06-29 14:05:49 +00:00
|
|
|
*/
|
|
|
|
gchar *
|
|
|
|
gst_debug_construct_term_color (guint colorinfo)
|
|
|
|
{
|
|
|
|
GString *color;
|
2001-09-10 19:46:01 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
color = g_string_new ("\033[00");
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
if (colorinfo & GST_DEBUG_BOLD) {
|
2007-12-28 14:15:53 +00:00
|
|
|
g_string_append_len (color, ";01", 3);
|
2003-06-29 14:05:49 +00:00
|
|
|
}
|
|
|
|
if (colorinfo & GST_DEBUG_UNDERLINE) {
|
2007-12-28 14:15:53 +00:00
|
|
|
g_string_append_len (color, ";04", 3);
|
2003-06-29 14:05:49 +00:00
|
|
|
}
|
|
|
|
if (colorinfo & GST_DEBUG_FG_MASK) {
|
|
|
|
g_string_append_printf (color, ";3%1d", colorinfo & GST_DEBUG_FG_MASK);
|
|
|
|
}
|
|
|
|
if (colorinfo & GST_DEBUG_BG_MASK) {
|
2004-03-13 15:27:01 +00:00
|
|
|
g_string_append_printf (color, ";4%1d",
|
2004-03-15 19:27:17 +00:00
|
|
|
(colorinfo & GST_DEBUG_BG_MASK) >> 4);
|
2003-06-29 14:05:49 +00:00
|
|
|
}
|
2007-12-28 14:15:53 +00:00
|
|
|
g_string_append_c (color, 'm');
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2007-12-28 14:15:53 +00:00
|
|
|
return g_string_free (color, FALSE);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2009-03-18 16:30:12 +00:00
|
|
|
/**
|
|
|
|
* gst_debug_construct_win_color:
|
|
|
|
* @colorinfo: the color info
|
|
|
|
*
|
|
|
|
* Constructs an integer that can be used for getting the desired color in
|
|
|
|
* windows' terminals (cmd.exe). As there is no mean to underline, we simply
|
|
|
|
* ignore this attribute.
|
|
|
|
*
|
2009-03-18 17:45:41 +00:00
|
|
|
* This function returns 0 on non-windows machines.
|
|
|
|
*
|
2009-03-18 16:30:12 +00:00
|
|
|
* Returns: an integer containing the color definition
|
|
|
|
*/
|
|
|
|
gint
|
|
|
|
gst_debug_construct_win_color (guint colorinfo)
|
|
|
|
{
|
|
|
|
gint color = 0;
|
2009-03-18 17:45:41 +00:00
|
|
|
#ifdef G_OS_WIN32
|
2009-03-18 16:30:12 +00:00
|
|
|
static const guchar ansi_to_win_fg[8] = {
|
|
|
|
0, /* black */
|
|
|
|
FOREGROUND_RED, /* red */
|
|
|
|
FOREGROUND_GREEN, /* green */
|
|
|
|
FOREGROUND_RED | FOREGROUND_GREEN, /* yellow */
|
|
|
|
FOREGROUND_BLUE, /* blue */
|
|
|
|
FOREGROUND_RED | FOREGROUND_BLUE, /* magenta */
|
|
|
|
FOREGROUND_GREEN | FOREGROUND_BLUE, /* cyan */
|
|
|
|
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE /* white */
|
|
|
|
};
|
|
|
|
static const guchar ansi_to_win_bg[8] = {
|
|
|
|
0,
|
|
|
|
BACKGROUND_RED,
|
|
|
|
BACKGROUND_GREEN,
|
|
|
|
BACKGROUND_RED | BACKGROUND_GREEN,
|
|
|
|
BACKGROUND_BLUE,
|
|
|
|
BACKGROUND_RED | BACKGROUND_BLUE,
|
|
|
|
BACKGROUND_GREEN | FOREGROUND_BLUE,
|
|
|
|
BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE
|
|
|
|
};
|
|
|
|
|
|
|
|
/* we draw black as white, as cmd.exe can only have black bg */
|
2012-04-18 10:35:32 +00:00
|
|
|
if ((colorinfo & (GST_DEBUG_FG_MASK | GST_DEBUG_BG_MASK)) == 0) {
|
|
|
|
color = ansi_to_win_fg[7];
|
|
|
|
}
|
|
|
|
if (colorinfo & GST_DEBUG_UNDERLINE) {
|
|
|
|
color |= BACKGROUND_INTENSITY;
|
2009-03-18 16:30:12 +00:00
|
|
|
}
|
|
|
|
if (colorinfo & GST_DEBUG_BOLD) {
|
|
|
|
color |= FOREGROUND_INTENSITY;
|
|
|
|
}
|
|
|
|
if (colorinfo & GST_DEBUG_FG_MASK) {
|
|
|
|
color |= ansi_to_win_fg[colorinfo & GST_DEBUG_FG_MASK];
|
|
|
|
}
|
|
|
|
if (colorinfo & GST_DEBUG_BG_MASK) {
|
|
|
|
color |= ansi_to_win_bg[(colorinfo & GST_DEBUG_BG_MASK) >> 4];
|
|
|
|
}
|
2009-03-18 17:45:41 +00:00
|
|
|
#endif
|
2009-03-18 16:30:12 +00:00
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
2009-03-18 17:45:41 +00:00
|
|
|
/* width of %p varies depending on actual value of pointer, which can make
|
|
|
|
* output unevenly aligned if multiple threads are involved, hence the %14p
|
|
|
|
* (should really be %18p, but %14p seems a good compromise between too many
|
|
|
|
* white spaces and likely unalignment on my system) */
|
|
|
|
#if defined (GLIB_SIZEOF_VOID_P) && GLIB_SIZEOF_VOID_P == 8
|
|
|
|
#define PTR_FMT "%14p"
|
|
|
|
#else
|
|
|
|
#define PTR_FMT "%10p"
|
|
|
|
#endif
|
|
|
|
#define PID_FMT "%5d"
|
|
|
|
#define CAT_FMT "%20s %s:%d:%s:%s"
|
|
|
|
|
|
|
|
#ifdef G_OS_WIN32
|
2013-07-18 11:10:10 +00:00
|
|
|
static const guchar levelcolormap_w32[GST_LEVEL_COUNT] = {
|
2009-03-18 17:45:41 +00:00
|
|
|
/* GST_LEVEL_NONE */
|
|
|
|
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE,
|
|
|
|
/* GST_LEVEL_ERROR */
|
|
|
|
FOREGROUND_RED | FOREGROUND_INTENSITY,
|
|
|
|
/* GST_LEVEL_WARNING */
|
|
|
|
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY,
|
|
|
|
/* GST_LEVEL_INFO */
|
|
|
|
FOREGROUND_GREEN | FOREGROUND_INTENSITY,
|
|
|
|
/* GST_LEVEL_DEBUG */
|
|
|
|
FOREGROUND_GREEN | FOREGROUND_BLUE,
|
|
|
|
/* GST_LEVEL_LOG */
|
2009-04-06 00:27:26 +00:00
|
|
|
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE,
|
|
|
|
/* GST_LEVEL_FIXME */
|
|
|
|
FOREGROUND_RED | FOREGROUND_GREEN,
|
2010-06-03 00:49:51 +00:00
|
|
|
/* GST_LEVEL_TRACE */
|
|
|
|
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE,
|
2009-04-06 00:27:26 +00:00
|
|
|
/* placeholder for log level 8 */
|
|
|
|
0,
|
|
|
|
/* GST_LEVEL_MEMDUMP */
|
2009-03-18 17:45:41 +00:00
|
|
|
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE
|
|
|
|
};
|
|
|
|
|
2009-04-06 00:27:26 +00:00
|
|
|
static const guchar available_colors[] = {
|
2009-03-18 17:45:41 +00:00
|
|
|
FOREGROUND_RED, FOREGROUND_GREEN, FOREGROUND_RED | FOREGROUND_GREEN,
|
|
|
|
FOREGROUND_BLUE, FOREGROUND_RED | FOREGROUND_BLUE,
|
|
|
|
FOREGROUND_GREEN | FOREGROUND_BLUE,
|
|
|
|
};
|
2013-07-18 11:10:10 +00:00
|
|
|
#endif /* G_OS_WIN32 */
|
2009-04-06 00:27:26 +00:00
|
|
|
static const gchar *levelcolormap[GST_LEVEL_COUNT] = {
|
2009-03-18 17:45:41 +00:00
|
|
|
"\033[37m", /* GST_LEVEL_NONE */
|
|
|
|
"\033[31;01m", /* GST_LEVEL_ERROR */
|
|
|
|
"\033[33;01m", /* GST_LEVEL_WARNING */
|
|
|
|
"\033[32;01m", /* GST_LEVEL_INFO */
|
|
|
|
"\033[36m", /* GST_LEVEL_DEBUG */
|
2009-04-06 00:27:26 +00:00
|
|
|
"\033[37m", /* GST_LEVEL_LOG */
|
|
|
|
"\033[33;01m", /* GST_LEVEL_FIXME */
|
2010-06-03 00:49:51 +00:00
|
|
|
"\033[37m", /* GST_LEVEL_TRACE */
|
2009-04-06 00:27:26 +00:00
|
|
|
"\033[37m", /* placeholder for log level 8 */
|
|
|
|
"\033[37m" /* GST_LEVEL_MEMDUMP */
|
2009-03-18 17:45:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_debug_log_default:
|
|
|
|
* @category: category to log
|
|
|
|
* @level: level of the message
|
|
|
|
* @file: the file that emitted the message, usually the __FILE__ identifier
|
|
|
|
* @function: the function that emitted the message
|
|
|
|
* @line: the line from that the message was emitted, usually __LINE__
|
|
|
|
* @message: the actual message
|
2010-12-07 18:35:04 +00:00
|
|
|
* @object: (transfer none) (allow-none): the object this message relates to,
|
2014-05-29 21:54:34 +00:00
|
|
|
* or %NULL if none
|
2014-09-12 12:42:23 +00:00
|
|
|
* @user_data: the FILE* to log to
|
2009-03-18 17:45:41 +00:00
|
|
|
*
|
|
|
|
* The default logging handler used by GStreamer. Logging functions get called
|
2014-09-12 12:42:23 +00:00
|
|
|
* whenever a macro like GST_DEBUG or similar is used. By default this function
|
|
|
|
* is setup to output the message and additional info to stderr (or the log file
|
|
|
|
* specified via the GST_DEBUG_FILE environment variable) as received via
|
|
|
|
* @user_data.
|
2010-06-04 10:24:59 +00:00
|
|
|
*
|
2009-03-18 17:45:41 +00:00
|
|
|
* You can add other handlers by using gst_debug_add_log_function().
|
|
|
|
* And you can remove this handler by calling
|
|
|
|
* gst_debug_remove_log_function(gst_debug_log_default);
|
|
|
|
*/
|
2009-03-18 16:30:12 +00:00
|
|
|
void
|
|
|
|
gst_debug_log_default (GstDebugCategory * category, GstDebugLevel level,
|
|
|
|
const gchar * file, const gchar * function, gint line,
|
2014-09-12 12:42:23 +00:00
|
|
|
GObject * object, GstDebugMessage * message, gpointer user_data)
|
2009-03-18 16:30:12 +00:00
|
|
|
{
|
2009-03-18 17:45:41 +00:00
|
|
|
gint pid;
|
2009-03-18 16:30:12 +00:00
|
|
|
GstClockTime elapsed;
|
2009-03-18 17:45:41 +00:00
|
|
|
gchar *obj = NULL;
|
2013-07-18 11:10:10 +00:00
|
|
|
GstDebugColorMode color_mode;
|
2018-04-11 18:56:01 +00:00
|
|
|
const gchar *message_str;
|
2014-09-12 12:42:23 +00:00
|
|
|
FILE *log_file = user_data ? user_data : stderr;
|
2015-03-05 17:54:04 +00:00
|
|
|
gchar c;
|
2009-03-18 16:30:12 +00:00
|
|
|
|
2018-04-11 18:56:01 +00:00
|
|
|
/* 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);
|
|
|
|
|
2015-03-05 17:54:04 +00:00
|
|
|
/* __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
|
|
|
|
* readability. */
|
|
|
|
c = file[0];
|
|
|
|
if (c == '.' || c == '/' || c == '\\' || (c != '\0' && file[1] == ':')) {
|
|
|
|
file = gst_path_basename (file);
|
|
|
|
}
|
|
|
|
|
2009-03-18 16:30:12 +00:00
|
|
|
pid = getpid ();
|
2013-07-18 11:10:10 +00:00
|
|
|
color_mode = gst_debug_get_color_mode ();
|
2009-03-18 17:45:41 +00:00
|
|
|
|
2009-03-18 16:30:12 +00:00
|
|
|
if (object) {
|
|
|
|
obj = gst_debug_print_object (object);
|
|
|
|
} else {
|
2015-03-05 18:30:45 +00:00
|
|
|
obj = (gchar *) "";
|
2009-03-18 16:30:12 +00:00
|
|
|
}
|
|
|
|
|
2016-01-07 16:41:25 +00:00
|
|
|
elapsed = GST_CLOCK_DIFF (_priv_gst_start_time, gst_util_get_timestamp ());
|
2010-08-05 07:32:53 +00:00
|
|
|
|
2013-07-18 11:10:10 +00:00
|
|
|
if (color_mode != GST_DEBUG_COLOR_MODE_OFF) {
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
/* We take a lock to keep colors and content together.
|
2009-04-14 08:32:07 +00:00
|
|
|
* Maybe there is a better way but for now this will do the right
|
|
|
|
* thing. */
|
2012-01-22 22:44:59 +00:00
|
|
|
static GMutex win_print_mutex;
|
2013-07-18 11:10:10 +00:00
|
|
|
g_mutex_lock (&win_print_mutex);
|
|
|
|
if (color_mode == GST_DEBUG_COLOR_MODE_UNIX) {
|
|
|
|
#endif
|
|
|
|
/* colors, non-windows */
|
|
|
|
gchar *color = NULL;
|
|
|
|
const gchar *clear;
|
|
|
|
gchar pidcolor[10];
|
|
|
|
const gchar *levelcolor;
|
|
|
|
|
|
|
|
color = gst_debug_construct_term_color (gst_debug_category_get_color
|
|
|
|
(category));
|
|
|
|
clear = "\033[00m";
|
|
|
|
g_sprintf (pidcolor, "\033[3%1dm", pid % 6 + 31);
|
|
|
|
levelcolor = levelcolormap[level];
|
|
|
|
|
|
|
|
#define PRINT_FMT " %s"PID_FMT"%s "PTR_FMT" %s%s%s %s"CAT_FMT"%s %s\n"
|
|
|
|
fprintf (log_file, "%" GST_TIME_FORMAT PRINT_FMT, GST_TIME_ARGS (elapsed),
|
|
|
|
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,
|
2018-04-11 18:56:01 +00:00
|
|
|
clear, message_str);
|
2013-07-18 11:10:10 +00:00
|
|
|
fflush (log_file);
|
|
|
|
#undef PRINT_FMT
|
|
|
|
g_free (color);
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
} else {
|
|
|
|
/* colors, windows. */
|
|
|
|
const gint clear = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
|
2010-07-26 16:53:57 +00:00
|
|
|
#define SET_COLOR(c) G_STMT_START { \
|
2010-07-27 12:30:51 +00:00
|
|
|
if (log_file == stderr) \
|
2010-07-26 16:53:57 +00:00
|
|
|
SetConsoleTextAttribute (GetStdHandle (STD_ERROR_HANDLE), (c)); \
|
|
|
|
} G_STMT_END
|
2013-07-18 11:10:10 +00:00
|
|
|
/* timestamp */
|
|
|
|
fprintf (log_file, "%" GST_TIME_FORMAT " ", GST_TIME_ARGS (elapsed));
|
|
|
|
fflush (log_file);
|
|
|
|
/* pid */
|
|
|
|
SET_COLOR (available_colors[pid % G_N_ELEMENTS (available_colors)]);
|
|
|
|
fprintf (log_file, PID_FMT, pid);
|
|
|
|
fflush (log_file);
|
|
|
|
/* thread */
|
|
|
|
SET_COLOR (clear);
|
|
|
|
fprintf (log_file, " " PTR_FMT " ", g_thread_self ());
|
|
|
|
fflush (log_file);
|
|
|
|
/* level */
|
|
|
|
SET_COLOR (levelcolormap_w32[level]);
|
|
|
|
fprintf (log_file, "%s ", gst_debug_level_get_name (level));
|
|
|
|
fflush (log_file);
|
|
|
|
/* category */
|
|
|
|
SET_COLOR (gst_debug_construct_win_color (gst_debug_category_get_color
|
|
|
|
(category)));
|
|
|
|
fprintf (log_file, CAT_FMT, gst_debug_category_get_name (category),
|
|
|
|
file, line, function, obj);
|
|
|
|
fflush (log_file);
|
|
|
|
/* message */
|
|
|
|
SET_COLOR (clear);
|
2018-04-11 18:56:01 +00:00
|
|
|
fprintf (log_file, " %s\n", message_str);
|
2013-07-18 11:10:10 +00:00
|
|
|
fflush (log_file);
|
|
|
|
}
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_unlock (&win_print_mutex);
|
2009-03-18 17:45:41 +00:00
|
|
|
#endif
|
2009-03-18 16:30:12 +00:00
|
|
|
} else {
|
2009-04-14 08:32:07 +00:00
|
|
|
/* no color, all platforms */
|
2009-03-18 17:45:41 +00:00
|
|
|
#define PRINT_FMT " "PID_FMT" "PTR_FMT" %s "CAT_FMT" %s\n"
|
2010-07-26 16:53:57 +00:00
|
|
|
fprintf (log_file, "%" GST_TIME_FORMAT PRINT_FMT, GST_TIME_ARGS (elapsed),
|
2010-06-04 10:24:59 +00:00
|
|
|
pid, g_thread_self (), gst_debug_level_get_name (level),
|
2009-03-18 16:30:12 +00:00
|
|
|
gst_debug_category_get_name (category), file, line, function, obj,
|
2018-04-11 18:56:01 +00:00
|
|
|
message_str);
|
2010-07-26 16:53:57 +00:00
|
|
|
fflush (log_file);
|
2009-03-18 17:45:41 +00:00
|
|
|
#undef PRINT_FMT
|
2009-03-18 16:30:12 +00:00
|
|
|
}
|
|
|
|
|
2015-03-05 18:30:45 +00:00
|
|
|
if (object != NULL)
|
|
|
|
g_free (obj);
|
2009-03-18 16:30:12 +00:00
|
|
|
}
|
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
/**
|
2003-06-29 14:05:49 +00:00
|
|
|
* gst_debug_level_get_name:
|
|
|
|
* @level: the level to get the name for
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2007-10-15 06:52:01 +00:00
|
|
|
* Get the string representation of a debugging level
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2003-06-29 14:05:49 +00:00
|
|
|
* Returns: the name
|
2001-05-25 21:00:07 +00:00
|
|
|
*/
|
2003-06-29 14:05:49 +00:00
|
|
|
const gchar *
|
|
|
|
gst_debug_level_get_name (GstDebugLevel level)
|
|
|
|
{
|
|
|
|
switch (level) {
|
2004-03-13 15:27:01 +00:00
|
|
|
case GST_LEVEL_NONE:
|
|
|
|
return "";
|
|
|
|
case GST_LEVEL_ERROR:
|
2009-06-01 19:26:53 +00:00
|
|
|
return "ERROR ";
|
2004-03-13 15:27:01 +00:00
|
|
|
case GST_LEVEL_WARNING:
|
2009-06-01 19:26:53 +00:00
|
|
|
return "WARN ";
|
2004-03-13 15:27:01 +00:00
|
|
|
case GST_LEVEL_INFO:
|
2009-06-01 19:26:53 +00:00
|
|
|
return "INFO ";
|
2004-03-13 15:27:01 +00:00
|
|
|
case GST_LEVEL_DEBUG:
|
2009-06-01 19:26:53 +00:00
|
|
|
return "DEBUG ";
|
2004-03-13 15:27:01 +00:00
|
|
|
case GST_LEVEL_LOG:
|
2009-06-01 19:26:53 +00:00
|
|
|
return "LOG ";
|
2009-04-06 00:27:26 +00:00
|
|
|
case GST_LEVEL_FIXME:
|
2009-06-01 19:26:53 +00:00
|
|
|
return "FIXME ";
|
2010-06-03 00:49:51 +00:00
|
|
|
case GST_LEVEL_TRACE:
|
|
|
|
return "TRACE ";
|
2009-04-06 00:27:26 +00:00
|
|
|
case GST_LEVEL_MEMDUMP:
|
2009-06-01 19:26:53 +00:00
|
|
|
return "MEMDUMP";
|
2003-06-29 14:05:49 +00:00
|
|
|
default:
|
|
|
|
g_warning ("invalid level specified for gst_debug_level_get_name");
|
|
|
|
return "";
|
|
|
|
}
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
/**
|
2003-06-29 14:05:49 +00:00
|
|
|
* gst_debug_add_log_function:
|
|
|
|
* @func: the function to use
|
2012-06-20 11:28:08 +00:00
|
|
|
* @user_data: user data
|
|
|
|
* @notify: called when @user_data is not used anymore
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2003-06-29 14:05:49 +00:00
|
|
|
* Adds the logging function to the list of logging functions.
|
2010-08-12 19:08:44 +00:00
|
|
|
* Be sure to use #G_GNUC_NO_INSTRUMENT on that function, it is needed.
|
2001-05-25 21:00:07 +00:00
|
|
|
*/
|
|
|
|
void
|
2012-06-20 11:28:08 +00:00
|
|
|
gst_debug_add_log_function (GstLogFunction func, gpointer user_data,
|
|
|
|
GDestroyNotify notify)
|
2003-06-29 14:05:49 +00:00
|
|
|
{
|
|
|
|
LogFuncEntry *entry;
|
2003-08-03 17:18:40 +00:00
|
|
|
GSList *list;
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2011-02-03 10:53:27 +00:00
|
|
|
if (func == NULL)
|
|
|
|
func = gst_debug_log_default;
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2010-03-28 16:05:36 +00:00
|
|
|
entry = g_slice_new (LogFuncEntry);
|
2003-06-29 14:05:49 +00:00
|
|
|
entry->func = func;
|
2012-06-20 11:28:08 +00:00
|
|
|
entry->user_data = user_data;
|
|
|
|
entry->notify = notify;
|
2003-08-03 17:18:40 +00:00
|
|
|
/* FIXME: we leak the old list here - other threads might access it right now
|
|
|
|
* in gst_debug_logv. Another solution is to lock the mutex in gst_debug_logv,
|
|
|
|
* but that is waaay costly.
|
2005-10-15 15:30:24 +00:00
|
|
|
* It'd probably be clever to use some kind of RCU here, but I don't know
|
2003-08-03 17:18:40 +00:00
|
|
|
* anything about that.
|
|
|
|
*/
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_lock (&__log_func_mutex);
|
2003-08-03 17:18:40 +00:00
|
|
|
list = g_slist_copy (__log_functions);
|
|
|
|
__log_functions = g_slist_prepend (list, entry);
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_unlock (&__log_func_mutex);
|
2003-06-29 14:05:49 +00:00
|
|
|
|
2012-10-22 08:25:40 +00:00
|
|
|
if (gst_is_initialized ())
|
|
|
|
GST_DEBUG ("prepended log function %p (user data %p) to log functions",
|
|
|
|
func, user_data);
|
2003-06-29 14:05:49 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
static gint
|
|
|
|
gst_debug_compare_log_function_by_func (gconstpointer entry, gconstpointer func)
|
|
|
|
{
|
2006-10-06 14:46:04 +00:00
|
|
|
gpointer entryfunc = (gpointer) (((LogFuncEntry *) entry)->func);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
return (entryfunc < func) ? -1 : (entryfunc > func) ? 1 : 0;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
static gint
|
|
|
|
gst_debug_compare_log_function_by_data (gconstpointer entry, gconstpointer data)
|
|
|
|
{
|
|
|
|
gpointer entrydata = ((LogFuncEntry *) entry)->user_data;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
return (entrydata < data) ? -1 : (entrydata > data) ? 1 : 0;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-08-03 17:18:40 +00:00
|
|
|
static guint
|
|
|
|
gst_debug_remove_with_compare_func (GCompareFunc func, gpointer data)
|
|
|
|
{
|
|
|
|
GSList *found;
|
2012-06-20 11:28:08 +00:00
|
|
|
GSList *new, *cleanup = NULL;
|
2003-08-03 17:18:40 +00:00
|
|
|
guint removals = 0;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_lock (&__log_func_mutex);
|
2003-08-03 17:18:40 +00:00
|
|
|
new = __log_functions;
|
2012-06-20 11:28:08 +00:00
|
|
|
cleanup = NULL;
|
2003-08-17 16:45:09 +00:00
|
|
|
while ((found = g_slist_find_custom (new, data, func))) {
|
|
|
|
if (new == __log_functions) {
|
2008-05-14 18:17:34 +00:00
|
|
|
/* make a copy when we have the first hit, so that we modify the copy and
|
|
|
|
* make that the new list later */
|
2003-08-03 17:18:40 +00:00
|
|
|
new = g_slist_copy (new);
|
2003-08-17 16:45:09 +00:00
|
|
|
continue;
|
2003-08-03 17:18:40 +00:00
|
|
|
}
|
2012-06-20 11:28:08 +00:00
|
|
|
cleanup = g_slist_prepend (cleanup, found->data);
|
2003-08-17 20:18:58 +00:00
|
|
|
new = g_slist_delete_link (new, found);
|
2003-08-03 17:18:40 +00:00
|
|
|
removals++;
|
|
|
|
}
|
|
|
|
/* FIXME: We leak the old list here. See _add_log_function for why. */
|
|
|
|
__log_functions = new;
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_unlock (&__log_func_mutex);
|
2003-08-03 17:18:40 +00:00
|
|
|
|
2012-06-20 11:28:08 +00:00
|
|
|
while (cleanup) {
|
|
|
|
LogFuncEntry *entry = cleanup->data;
|
|
|
|
|
|
|
|
if (entry->notify)
|
|
|
|
entry->notify (entry->user_data);
|
|
|
|
|
|
|
|
g_slice_free (LogFuncEntry, entry);
|
|
|
|
cleanup = g_slist_delete_link (cleanup, cleanup);
|
|
|
|
}
|
2003-08-03 17:18:40 +00:00
|
|
|
return removals;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-01-04 22:16:06 +00:00
|
|
|
/**
|
2003-06-29 14:05:49 +00:00
|
|
|
* gst_debug_remove_log_function:
|
2016-08-26 11:04:33 +00:00
|
|
|
* @func: (scope call) (allow-none): the log function to remove, or %NULL to
|
|
|
|
* remove the default log function
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2007-10-15 06:52:01 +00:00
|
|
|
* Removes all registered instances of the given logging functions.
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2003-06-29 14:05:49 +00:00
|
|
|
* Returns: How many instances of the function were removed
|
2001-01-04 22:16:06 +00:00
|
|
|
*/
|
2003-06-29 14:05:49 +00:00
|
|
|
guint
|
|
|
|
gst_debug_remove_log_function (GstLogFunction func)
|
|
|
|
{
|
2003-08-03 17:18:40 +00:00
|
|
|
guint removals;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2011-02-03 10:53:27 +00:00
|
|
|
if (func == NULL)
|
|
|
|
func = gst_debug_log_default;
|
2001-01-01 00:17:21 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
removals =
|
|
|
|
gst_debug_remove_with_compare_func
|
2006-10-06 14:46:04 +00:00
|
|
|
(gst_debug_compare_log_function_by_func, (gpointer) func);
|
2016-02-29 19:04:16 +00:00
|
|
|
|
|
|
|
if (gst_is_initialized ()) {
|
2012-10-22 08:25:40 +00:00
|
|
|
GST_DEBUG ("removed log function %p %d times from log function list", func,
|
|
|
|
removals);
|
2016-02-29 19:04:16 +00:00
|
|
|
} else {
|
|
|
|
/* If the default log function is removed before gst_init() was called,
|
|
|
|
* set a flag so we don't add it in gst_init() later */
|
|
|
|
if (func == gst_debug_log_default) {
|
|
|
|
add_default_log_func = FALSE;
|
|
|
|
++removals;
|
|
|
|
}
|
|
|
|
}
|
2000-12-29 10:02:17 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
return removals;
|
2000-12-29 10:02:17 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
/**
|
|
|
|
* gst_debug_remove_log_function_by_data:
|
|
|
|
* @data: user data of the log function to remove
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2007-10-15 06:52:01 +00:00
|
|
|
* Removes all registered instances of log functions with the given user data.
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2003-06-29 14:05:49 +00:00
|
|
|
* Returns: How many instances of the function were removed
|
|
|
|
*/
|
|
|
|
guint
|
|
|
|
gst_debug_remove_log_function_by_data (gpointer data)
|
|
|
|
{
|
2003-08-03 17:18:40 +00:00
|
|
|
guint removals;
|
2003-06-29 14:05:49 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
removals =
|
|
|
|
gst_debug_remove_with_compare_func
|
|
|
|
(gst_debug_compare_log_function_by_data, data);
|
2012-10-22 08:25:40 +00:00
|
|
|
|
|
|
|
if (gst_is_initialized ())
|
|
|
|
GST_DEBUG
|
|
|
|
("removed %d log functions with user data %p from log function list",
|
|
|
|
removals, data);
|
2000-12-29 10:02:17 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
return removals;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-01-04 22:16:06 +00:00
|
|
|
/**
|
2003-06-29 14:05:49 +00:00
|
|
|
* gst_debug_set_colored:
|
|
|
|
* @colored: Whether to use colored output or not
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2003-06-29 14:05:49 +00:00
|
|
|
* Sets or unsets the use of coloured debugging output.
|
2013-07-18 11:10:10 +00:00
|
|
|
* Same as gst_debug_set_color_mode () with the argument being
|
|
|
|
* being GST_DEBUG_COLOR_MODE_ON or GST_DEBUG_COLOR_MODE_OFF.
|
2010-07-28 01:24:44 +00:00
|
|
|
*
|
|
|
|
* This function may be called before gst_init().
|
2001-01-04 22:16:06 +00:00
|
|
|
*/
|
2001-01-01 00:17:21 +00:00
|
|
|
void
|
2003-06-29 14:05:49 +00:00
|
|
|
gst_debug_set_colored (gboolean colored)
|
|
|
|
{
|
2013-07-18 11:10:10 +00:00
|
|
|
GstDebugColorMode new_mode;
|
|
|
|
new_mode = colored ? GST_DEBUG_COLOR_MODE_ON : GST_DEBUG_COLOR_MODE_OFF;
|
|
|
|
g_atomic_int_set (&__use_color, (gint) new_mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_debug_set_color_mode:
|
|
|
|
* @mode: The coloring mode for debug output. See @GstDebugColorMode.
|
|
|
|
*
|
|
|
|
* Changes the coloring mode for debug output.
|
|
|
|
*
|
|
|
|
* This function may be called before gst_init().
|
2013-07-18 12:34:31 +00:00
|
|
|
*
|
|
|
|
* Since: 1.2
|
2013-07-18 11:10:10 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_debug_set_color_mode (GstDebugColorMode mode)
|
|
|
|
{
|
|
|
|
g_atomic_int_set (&__use_color, mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_debug_set_color_mode_from_string:
|
|
|
|
* @mode: The coloring mode for debug output. One of the following:
|
|
|
|
* "on", "auto", "off", "disable", "unix".
|
|
|
|
*
|
|
|
|
* Changes the coloring mode for debug output.
|
|
|
|
*
|
|
|
|
* This function may be called before gst_init().
|
2013-07-18 12:34:31 +00:00
|
|
|
*
|
|
|
|
* Since: 1.2
|
2013-07-18 11:10:10 +00:00
|
|
|
*/
|
|
|
|
void
|
2013-08-07 16:20:03 +00:00
|
|
|
gst_debug_set_color_mode_from_string (const gchar * mode)
|
2013-07-18 11:10:10 +00:00
|
|
|
{
|
2013-08-07 16:20:03 +00:00
|
|
|
if ((strcmp (mode, "on") == 0) || (strcmp (mode, "auto") == 0))
|
2013-07-18 11:10:10 +00:00
|
|
|
gst_debug_set_color_mode (GST_DEBUG_COLOR_MODE_ON);
|
2013-08-07 16:20:03 +00:00
|
|
|
else if ((strcmp (mode, "off") == 0) || (strcmp (mode, "disable") == 0))
|
2013-07-18 11:10:10 +00:00
|
|
|
gst_debug_set_color_mode (GST_DEBUG_COLOR_MODE_OFF);
|
2013-08-07 16:20:03 +00:00
|
|
|
else if (strcmp (mode, "unix") == 0)
|
2013-07-18 11:10:10 +00:00
|
|
|
gst_debug_set_color_mode (GST_DEBUG_COLOR_MODE_UNIX);
|
2001-01-01 00:17:21 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-01-04 22:16:06 +00:00
|
|
|
/**
|
2003-06-29 14:05:49 +00:00
|
|
|
* gst_debug_is_colored:
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2003-06-29 14:05:49 +00:00
|
|
|
* Checks if the debugging output should be colored.
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2014-05-29 21:54:34 +00:00
|
|
|
* Returns: %TRUE, if the debug output should be colored.
|
2001-01-04 22:16:06 +00:00
|
|
|
*/
|
2003-06-29 14:05:49 +00:00
|
|
|
gboolean
|
|
|
|
gst_debug_is_colored (void)
|
|
|
|
{
|
2013-07-18 11:10:10 +00:00
|
|
|
GstDebugColorMode mode = g_atomic_int_get (&__use_color);
|
|
|
|
return (mode == GST_DEBUG_COLOR_MODE_UNIX || mode == GST_DEBUG_COLOR_MODE_ON);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_debug_get_color_mode:
|
|
|
|
*
|
|
|
|
* Changes the coloring mode for debug output.
|
|
|
|
*
|
|
|
|
* Returns: see @GstDebugColorMode for possible values.
|
2013-07-18 12:34:31 +00:00
|
|
|
*
|
|
|
|
* Since: 1.2
|
2013-07-18 11:10:10 +00:00
|
|
|
*/
|
|
|
|
GstDebugColorMode
|
|
|
|
gst_debug_get_color_mode (void)
|
|
|
|
{
|
|
|
|
return g_atomic_int_get (&__use_color);
|
2001-01-01 00:17:21 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-01-04 22:16:06 +00:00
|
|
|
/**
|
2003-06-29 14:05:49 +00:00
|
|
|
* gst_debug_set_active:
|
|
|
|
* @active: Whether to use debugging output or not
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2003-06-29 14:05:49 +00:00
|
|
|
* If activated, debugging messages are sent to the debugging
|
|
|
|
* handlers.
|
|
|
|
* It makes sense to deactivate it for speed issues.
|
2017-01-16 14:26:16 +00:00
|
|
|
* > This function is not threadsafe. It makes sense to only call it
|
|
|
|
* during initialization.
|
2001-01-04 22:16:06 +00:00
|
|
|
*/
|
2001-01-01 00:17:21 +00:00
|
|
|
void
|
2003-06-29 14:05:49 +00:00
|
|
|
gst_debug_set_active (gboolean active)
|
|
|
|
{
|
2011-10-08 12:37:09 +00:00
|
|
|
_gst_debug_enabled = active;
|
2006-03-22 18:25:04 +00:00
|
|
|
if (active)
|
2011-10-08 12:37:09 +00:00
|
|
|
_gst_debug_min = GST_LEVEL_COUNT;
|
2006-06-12 08:47:16 +00:00
|
|
|
else
|
2011-10-08 12:37:09 +00:00
|
|
|
_gst_debug_min = GST_LEVEL_NONE;
|
2001-01-01 00:17:21 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-01-04 22:16:06 +00:00
|
|
|
/**
|
2003-06-29 14:05:49 +00:00
|
|
|
* gst_debug_is_active:
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2003-06-29 14:05:49 +00:00
|
|
|
* Checks if debugging output is activated.
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2014-05-29 21:54:34 +00:00
|
|
|
* Returns: %TRUE, if debugging is activated
|
2003-06-29 14:05:49 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_debug_is_active (void)
|
|
|
|
{
|
2011-10-08 12:37:09 +00:00
|
|
|
return _gst_debug_enabled;
|
2003-06-29 14:05:49 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
/**
|
|
|
|
* gst_debug_set_default_threshold:
|
|
|
|
* @level: level to set
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2003-06-29 14:05:49 +00:00
|
|
|
* Sets the default threshold to the given level and updates all categories to
|
|
|
|
* use this threshold.
|
2010-07-28 01:24:44 +00:00
|
|
|
*
|
|
|
|
* This function may be called before gst_init().
|
2001-01-04 22:16:06 +00:00
|
|
|
*/
|
2001-01-01 00:17:21 +00:00
|
|
|
void
|
2003-06-29 14:05:49 +00:00
|
|
|
gst_debug_set_default_threshold (GstDebugLevel level)
|
|
|
|
{
|
2008-04-17 07:14:46 +00:00
|
|
|
g_atomic_int_set (&__default_level, level);
|
2003-06-29 14:05:49 +00:00
|
|
|
gst_debug_reset_all_thresholds ();
|
2001-01-01 00:17:21 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
/**
|
|
|
|
* gst_debug_get_default_threshold:
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2003-06-29 14:05:49 +00:00
|
|
|
* Returns the default threshold that is used for new categories.
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2003-06-29 14:05:49 +00:00
|
|
|
* Returns: the default threshold level
|
|
|
|
*/
|
|
|
|
GstDebugLevel
|
|
|
|
gst_debug_get_default_threshold (void)
|
2004-03-13 15:27:01 +00:00
|
|
|
{
|
2005-04-24 22:49:45 +00:00
|
|
|
return (GstDebugLevel) g_atomic_int_get (&__default_level);
|
2003-06-29 14:05:49 +00:00
|
|
|
}
|
2009-03-18 16:30:12 +00:00
|
|
|
|
2018-03-27 08:14:27 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
static void
|
|
|
|
gst_debug_reset_threshold (gpointer category, gpointer unused)
|
|
|
|
{
|
|
|
|
GstDebugCategory *cat = (GstDebugCategory *) category;
|
|
|
|
GSList *walk;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_lock (&__level_name_mutex);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2018-03-27 08:15:46 +00:00
|
|
|
for (walk = __level_name; walk != NULL; walk = walk->next) {
|
|
|
|
if (gst_debug_apply_entry (cat, walk->data))
|
|
|
|
break;
|
2003-06-29 14:05:49 +00:00
|
|
|
}
|
2001-01-01 00:17:21 +00:00
|
|
|
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_unlock (&__level_name_mutex);
|
2018-03-27 08:15:46 +00:00
|
|
|
|
|
|
|
if (walk == NULL)
|
|
|
|
gst_debug_category_set_threshold (cat, gst_debug_get_default_threshold ());
|
2003-06-29 14:05:49 +00:00
|
|
|
}
|
2009-03-18 16:30:12 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
static void
|
|
|
|
gst_debug_reset_all_thresholds (void)
|
|
|
|
{
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_lock (&__cat_mutex);
|
2003-06-29 14:05:49 +00:00
|
|
|
g_slist_foreach (__categories, gst_debug_reset_threshold, NULL);
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_unlock (&__cat_mutex);
|
2003-06-29 14:05:49 +00:00
|
|
|
}
|
2009-03-18 16:30:12 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
static void
|
|
|
|
for_each_threshold_by_entry (gpointer data, gpointer user_data)
|
|
|
|
{
|
|
|
|
GstDebugCategory *cat = (GstDebugCategory *) data;
|
|
|
|
LevelNameEntry *entry = (LevelNameEntry *) user_data;
|
2001-01-01 05:18:07 +00:00
|
|
|
|
2018-03-27 08:14:27 +00:00
|
|
|
gst_debug_apply_entry (cat, entry);
|
2003-06-29 14:05:49 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-01-04 22:16:06 +00:00
|
|
|
/**
|
2003-06-29 14:05:49 +00:00
|
|
|
* gst_debug_set_threshold_for_name:
|
|
|
|
* @name: name of the categories to set
|
|
|
|
* @level: level to set them to
|
2004-11-11 15:40:00 +00:00
|
|
|
*
|
|
|
|
* Sets all categories which match the given glob style pattern to the given
|
2003-06-29 14:05:49 +00:00
|
|
|
* level.
|
2001-01-04 22:16:06 +00:00
|
|
|
*/
|
2000-12-29 10:02:17 +00:00
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_debug_set_threshold_for_name (const gchar * name, GstDebugLevel level)
|
2003-06-29 14:05:49 +00:00
|
|
|
{
|
|
|
|
GPatternSpec *pat;
|
|
|
|
LevelNameEntry *entry;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
g_return_if_fail (name != NULL);
|
|
|
|
|
|
|
|
pat = g_pattern_spec_new (name);
|
2010-03-28 16:05:36 +00:00
|
|
|
entry = g_slice_new (LevelNameEntry);
|
2003-06-29 14:05:49 +00:00
|
|
|
entry->pat = pat;
|
|
|
|
entry->level = level;
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_lock (&__level_name_mutex);
|
2003-06-29 14:05:49 +00:00
|
|
|
__level_name = g_slist_prepend (__level_name, entry);
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_unlock (&__level_name_mutex);
|
|
|
|
g_mutex_lock (&__cat_mutex);
|
2003-06-29 14:05:49 +00:00
|
|
|
g_slist_foreach (__categories, for_each_threshold_by_entry, entry);
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_unlock (&__cat_mutex);
|
2003-06-29 14:05:49 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
/**
|
|
|
|
* gst_debug_unset_threshold_for_name:
|
|
|
|
* @name: name of the categories to set
|
2004-11-11 15:40:00 +00:00
|
|
|
*
|
2003-06-29 14:05:49 +00:00
|
|
|
* Resets all categories with the given name back to the default level.
|
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_debug_unset_threshold_for_name (const gchar * name)
|
2003-06-29 14:05:49 +00:00
|
|
|
{
|
|
|
|
GSList *walk;
|
|
|
|
GPatternSpec *pat;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
g_return_if_fail (name != NULL);
|
2000-12-29 10:02:17 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
pat = g_pattern_spec_new (name);
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_lock (&__level_name_mutex);
|
2003-06-29 14:05:49 +00:00
|
|
|
walk = __level_name;
|
|
|
|
/* improve this if you want, it's mighty slow */
|
|
|
|
while (walk) {
|
|
|
|
LevelNameEntry *entry = walk->data;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
if (g_pattern_spec_equal (entry->pat, pat)) {
|
|
|
|
__level_name = g_slist_remove_link (__level_name, walk);
|
|
|
|
g_pattern_spec_free (entry->pat);
|
2010-03-28 16:05:36 +00:00
|
|
|
g_slice_free (LevelNameEntry, entry);
|
2003-06-29 14:05:49 +00:00
|
|
|
g_slist_free_1 (walk);
|
|
|
|
walk = __level_name;
|
2015-04-22 18:03:33 +00:00
|
|
|
} else {
|
|
|
|
walk = g_slist_next (walk);
|
2000-12-29 10:02:17 +00:00
|
|
|
}
|
|
|
|
}
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_unlock (&__level_name_mutex);
|
2003-06-29 14:05:49 +00:00
|
|
|
g_pattern_spec_free (pat);
|
|
|
|
gst_debug_reset_all_thresholds ();
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
GstDebugCategory *
|
2007-09-18 22:13:57 +00:00
|
|
|
_gst_debug_category_new (const gchar * name, guint color,
|
|
|
|
const gchar * description)
|
2003-06-29 14:05:49 +00:00
|
|
|
{
|
2013-12-07 18:32:58 +00:00
|
|
|
GstDebugCategory *cat, *catfound;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
|
2010-03-28 16:05:36 +00:00
|
|
|
cat = g_slice_new (GstDebugCategory);
|
2003-06-29 14:05:49 +00:00
|
|
|
cat->name = g_strdup (name);
|
|
|
|
cat->color = color;
|
|
|
|
if (description != NULL) {
|
|
|
|
cat->description = g_strdup (description);
|
|
|
|
} else {
|
|
|
|
cat->description = g_strdup ("no description");
|
|
|
|
}
|
2008-04-17 07:14:46 +00:00
|
|
|
g_atomic_int_set (&cat->threshold, 0);
|
2003-06-29 14:05:49 +00:00
|
|
|
gst_debug_reset_threshold (cat, NULL);
|
2000-12-29 10:02:17 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
/* add to category list */
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_lock (&__cat_mutex);
|
2013-12-07 18:32:58 +00:00
|
|
|
catfound = _gst_debug_get_category_locked (name);
|
|
|
|
if (catfound) {
|
2013-12-04 22:35:18 +00:00
|
|
|
g_free ((gpointer) cat->name);
|
|
|
|
g_free ((gpointer) cat->description);
|
|
|
|
g_slice_free (GstDebugCategory, cat);
|
2013-12-07 18:32:58 +00:00
|
|
|
cat = catfound;
|
2013-12-04 22:35:18 +00:00
|
|
|
} else {
|
|
|
|
__categories = g_slist_prepend (__categories, cat);
|
|
|
|
}
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_unlock (&__cat_mutex);
|
2000-12-29 10:02:17 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
return cat;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
/**
|
|
|
|
* gst_debug_category_free:
|
2003-12-22 10:51:03 +00:00
|
|
|
* @category: #GstDebugCategory to free.
|
|
|
|
*
|
|
|
|
* Removes and frees the category and all associated resources.
|
2003-06-29 14:05:49 +00:00
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_debug_category_free (GstDebugCategory * category)
|
2003-06-29 14:05:49 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
if (category == NULL)
|
|
|
|
return;
|
2003-06-29 14:05:49 +00:00
|
|
|
|
|
|
|
/* remove from category list */
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_lock (&__cat_mutex);
|
2003-06-29 14:05:49 +00:00
|
|
|
__categories = g_slist_remove (__categories, category);
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_unlock (&__cat_mutex);
|
2003-06-29 14:05:49 +00:00
|
|
|
|
2003-12-22 10:51:03 +00:00
|
|
|
g_free ((gpointer) category->name);
|
|
|
|
g_free ((gpointer) category->description);
|
2010-03-28 16:05:36 +00:00
|
|
|
g_slice_free (GstDebugCategory, category);
|
2003-06-29 14:05:49 +00:00
|
|
|
}
|
2003-12-22 10:51:03 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
/**
|
|
|
|
* gst_debug_category_set_threshold:
|
2003-12-22 10:51:03 +00:00
|
|
|
* @category: a #GstDebugCategory to set threshold of.
|
|
|
|
* @level: the #GstDebugLevel threshold to set.
|
|
|
|
*
|
2003-06-29 14:05:49 +00:00
|
|
|
* Sets the threshold of the category to the given level. Debug information will
|
2003-12-22 10:51:03 +00:00
|
|
|
* only be output if the threshold is lower or equal to the level of the
|
2003-06-29 14:05:49 +00:00
|
|
|
* debugging message.
|
2017-01-16 14:26:16 +00:00
|
|
|
* > Do not use this function in production code, because other functions may
|
|
|
|
* > change the threshold of categories as side effect. It is however a nice
|
|
|
|
* > function to use when debugging (even from gdb).
|
2003-06-29 14:05:49 +00:00
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_debug_category_set_threshold (GstDebugCategory * category,
|
|
|
|
GstDebugLevel level)
|
2003-06-29 14:05:49 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (category != NULL);
|
2000-12-29 10:02:17 +00:00
|
|
|
|
2011-10-08 12:37:09 +00:00
|
|
|
if (level > _gst_debug_min) {
|
|
|
|
_gst_debug_enabled = TRUE;
|
|
|
|
_gst_debug_min = level;
|
2006-06-12 08:47:16 +00:00
|
|
|
}
|
2006-03-22 18:25:04 +00:00
|
|
|
|
2008-04-17 07:14:46 +00:00
|
|
|
g_atomic_int_set (&category->threshold, level);
|
2003-06-29 14:05:49 +00:00
|
|
|
}
|
2003-12-22 10:51:03 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
/**
|
|
|
|
* gst_debug_category_reset_threshold:
|
2003-12-22 10:51:03 +00:00
|
|
|
* @category: a #GstDebugCategory to reset threshold of.
|
|
|
|
*
|
|
|
|
* Resets the threshold of the category to the default level. Debug information
|
|
|
|
* will only be output if the threshold is lower or equal to the level of the
|
2003-06-29 14:05:49 +00:00
|
|
|
* debugging message.
|
2003-12-22 10:51:03 +00:00
|
|
|
* Use this function to set the threshold back to where it was after using
|
2003-06-29 14:05:49 +00:00
|
|
|
* gst_debug_category_set_threshold().
|
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_debug_category_reset_threshold (GstDebugCategory * category)
|
2003-06-29 14:05:49 +00:00
|
|
|
{
|
|
|
|
gst_debug_reset_threshold (category, NULL);
|
|
|
|
}
|
2003-12-22 10:51:03 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
/**
|
|
|
|
* gst_debug_category_get_threshold:
|
2003-12-22 10:51:03 +00:00
|
|
|
* @category: a #GstDebugCategory to get threshold of.
|
|
|
|
*
|
2007-10-15 06:52:01 +00:00
|
|
|
* Returns the threshold of a #GstDebugCategory.
|
2003-12-22 10:51:03 +00:00
|
|
|
*
|
|
|
|
* Returns: the #GstDebugLevel that is used as threshold.
|
2003-06-29 14:05:49 +00:00
|
|
|
*/
|
|
|
|
GstDebugLevel
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_debug_category_get_threshold (GstDebugCategory * category)
|
2003-06-29 14:05:49 +00:00
|
|
|
{
|
2011-08-16 20:41:32 +00:00
|
|
|
return (GstDebugLevel) g_atomic_int_get (&category->threshold);
|
2003-06-29 14:05:49 +00:00
|
|
|
}
|
2003-12-22 10:51:03 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
/**
|
|
|
|
* gst_debug_category_get_name:
|
2003-12-22 10:51:03 +00:00
|
|
|
* @category: a #GstDebugCategory to get name of.
|
|
|
|
*
|
|
|
|
* Returns the name of a debug category.
|
|
|
|
*
|
|
|
|
* Returns: the name of the category.
|
2003-06-29 14:05:49 +00:00
|
|
|
*/
|
|
|
|
const gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_debug_category_get_name (GstDebugCategory * category)
|
2003-06-29 14:05:49 +00:00
|
|
|
{
|
|
|
|
return category->name;
|
|
|
|
}
|
2003-12-22 10:51:03 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
/**
|
|
|
|
* gst_debug_category_get_color:
|
2003-12-22 10:51:03 +00:00
|
|
|
* @category: a #GstDebugCategory to get the color of.
|
|
|
|
*
|
|
|
|
* Returns the color of a debug category used when printing output in this
|
|
|
|
* category.
|
|
|
|
*
|
|
|
|
* Returns: the color of the category.
|
2003-06-29 14:05:49 +00:00
|
|
|
*/
|
|
|
|
guint
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_debug_category_get_color (GstDebugCategory * category)
|
2003-06-29 14:05:49 +00:00
|
|
|
{
|
|
|
|
return category->color;
|
|
|
|
}
|
2003-12-22 10:51:03 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
/**
|
|
|
|
* gst_debug_category_get_description:
|
2003-12-22 10:51:03 +00:00
|
|
|
* @category: a #GstDebugCategory to get the description of.
|
|
|
|
*
|
|
|
|
* Returns the description of a debug category.
|
|
|
|
*
|
|
|
|
* Returns: the description of the category.
|
2003-06-29 14:05:49 +00:00
|
|
|
*/
|
|
|
|
const gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_debug_category_get_description (GstDebugCategory * category)
|
2003-06-29 14:05:49 +00:00
|
|
|
{
|
|
|
|
return category->description;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
/**
|
|
|
|
* gst_debug_get_all_categories:
|
|
|
|
*
|
|
|
|
* Returns a snapshot of a all categories that are currently in use . This list
|
|
|
|
* may change anytime.
|
|
|
|
* The caller has to free the list after use.
|
2003-12-22 10:51:03 +00:00
|
|
|
*
|
2010-12-07 18:35:04 +00:00
|
|
|
* Returns: (transfer container) (element-type Gst.DebugCategory): the list of
|
|
|
|
* debug categories
|
2003-06-29 14:05:49 +00:00
|
|
|
*/
|
|
|
|
GSList *
|
|
|
|
gst_debug_get_all_categories (void)
|
|
|
|
{
|
|
|
|
GSList *ret;
|
2000-12-29 10:02:17 +00:00
|
|
|
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_lock (&__cat_mutex);
|
2003-06-29 14:05:49 +00:00
|
|
|
ret = g_slist_copy (__categories);
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_unlock (&__cat_mutex);
|
2000-12-29 10:02:17 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return ret;
|
2000-12-29 10:02:17 +00:00
|
|
|
}
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2013-12-04 22:35:02 +00:00
|
|
|
static GstDebugCategory *
|
|
|
|
_gst_debug_get_category_locked (const gchar * name)
|
2009-06-30 08:26:34 +00:00
|
|
|
{
|
|
|
|
GstDebugCategory *ret = NULL;
|
|
|
|
GSList *node;
|
|
|
|
|
|
|
|
for (node = __categories; node; node = g_slist_next (node)) {
|
|
|
|
ret = (GstDebugCategory *) node->data;
|
|
|
|
if (!strcmp (name, ret->name)) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-12-04 22:35:02 +00:00
|
|
|
GstDebugCategory *
|
|
|
|
_gst_debug_get_category (const gchar * name)
|
|
|
|
{
|
|
|
|
GstDebugCategory *ret;
|
|
|
|
|
|
|
|
g_mutex_lock (&__cat_mutex);
|
|
|
|
ret = _gst_debug_get_category_locked (name);
|
|
|
|
g_mutex_unlock (&__cat_mutex);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-06-29 16:05:36 +00:00
|
|
|
static gboolean
|
|
|
|
parse_debug_category (gchar * str, const gchar ** category)
|
|
|
|
{
|
|
|
|
if (!str)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* works in place */
|
|
|
|
g_strstrip (str);
|
|
|
|
|
|
|
|
if (str[0] != '\0') {
|
|
|
|
*category = str;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
parse_debug_level (gchar * str, GstDebugLevel * level)
|
|
|
|
{
|
|
|
|
if (!str)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* works in place */
|
|
|
|
g_strstrip (str);
|
|
|
|
|
2013-07-24 17:29:30 +00:00
|
|
|
if (g_ascii_isdigit (str[0])) {
|
|
|
|
unsigned long l;
|
|
|
|
char *endptr;
|
|
|
|
l = strtoul (str, &endptr, 10);
|
|
|
|
if (endptr > str && endptr[0] == 0) {
|
|
|
|
*level = (GstDebugLevel) l;
|
|
|
|
} else {
|
|
|
|
return FALSE;
|
|
|
|
}
|
2012-10-27 13:40:14 +00:00
|
|
|
} else if (strcmp (str, "ERROR") == 0) {
|
|
|
|
*level = GST_LEVEL_ERROR;
|
|
|
|
} else if (strncmp (str, "WARN", 4) == 0) {
|
|
|
|
*level = GST_LEVEL_WARNING;
|
|
|
|
} else if (strcmp (str, "FIXME") == 0) {
|
|
|
|
*level = GST_LEVEL_FIXME;
|
|
|
|
} else if (strcmp (str, "INFO") == 0) {
|
|
|
|
*level = GST_LEVEL_INFO;
|
|
|
|
} else if (strcmp (str, "DEBUG") == 0) {
|
|
|
|
*level = GST_LEVEL_DEBUG;
|
|
|
|
} else if (strcmp (str, "LOG") == 0) {
|
|
|
|
*level = GST_LEVEL_LOG;
|
|
|
|
} else if (strcmp (str, "TRACE") == 0) {
|
|
|
|
*level = GST_LEVEL_TRACE;
|
|
|
|
} else if (strcmp (str, "MEMDUMP") == 0) {
|
|
|
|
*level = GST_LEVEL_MEMDUMP;
|
|
|
|
} else
|
|
|
|
return FALSE;
|
2012-06-29 16:05:36 +00:00
|
|
|
|
2012-10-27 13:40:14 +00:00
|
|
|
return TRUE;
|
2012-06-29 16:05:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_debug_set_threshold_from_string:
|
|
|
|
* @list: comma-separated list of "category:level" pairs to be used
|
|
|
|
* as debug logging levels
|
|
|
|
* @reset: %TRUE to clear all previously-set debug levels before setting
|
|
|
|
* new thresholds
|
|
|
|
* %FALSE if adding the threshold described by @list to the one already set.
|
|
|
|
*
|
|
|
|
* Sets the debug logging wanted in the same form as with the GST_DEBUG
|
|
|
|
* environment variable. You can use wildcards such as '*', but note that
|
|
|
|
* the order matters when you use wild cards, e.g. "foosrc:6,*src:3,*:2" sets
|
|
|
|
* everything to log level 2.
|
|
|
|
*
|
2013-11-16 12:24:56 +00:00
|
|
|
* Since: 1.2
|
2012-06-29 16:05:36 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_debug_set_threshold_from_string (const gchar * list, gboolean reset)
|
|
|
|
{
|
|
|
|
gchar **split;
|
|
|
|
gchar **walk;
|
|
|
|
|
|
|
|
g_assert (list);
|
|
|
|
|
2014-11-28 13:17:54 +00:00
|
|
|
if (reset)
|
2018-01-11 11:36:53 +00:00
|
|
|
gst_debug_set_default_threshold (GST_LEVEL_DEFAULT);
|
2012-06-29 16:05:36 +00:00
|
|
|
|
|
|
|
split = g_strsplit (list, ",", 0);
|
|
|
|
|
|
|
|
for (walk = split; *walk; walk++) {
|
|
|
|
if (strchr (*walk, ':')) {
|
|
|
|
gchar **values = g_strsplit (*walk, ":", 2);
|
|
|
|
|
|
|
|
if (values[0] && values[1]) {
|
|
|
|
GstDebugLevel level;
|
|
|
|
const gchar *category;
|
|
|
|
|
|
|
|
if (parse_debug_category (values[0], &category)
|
2016-12-28 20:47:03 +00:00
|
|
|
&& parse_debug_level (values[1], &level)) {
|
2012-06-29 16:05:36 +00:00
|
|
|
gst_debug_set_threshold_for_name (category, level);
|
2016-12-28 20:47:03 +00:00
|
|
|
|
|
|
|
/* bump min-level anyway to allow the category to be registered in the
|
|
|
|
* future still */
|
|
|
|
if (level > _gst_debug_min) {
|
|
|
|
_gst_debug_min = level;
|
|
|
|
}
|
|
|
|
}
|
2012-06-29 16:05:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_strfreev (values);
|
|
|
|
} else {
|
|
|
|
GstDebugLevel level;
|
|
|
|
|
|
|
|
if (parse_debug_level (*walk, &level))
|
|
|
|
gst_debug_set_default_threshold (level);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_strfreev (split);
|
|
|
|
}
|
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
/*** FUNCTION POINTERS ********************************************************/
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2005-09-21 21:39:06 +00:00
|
|
|
static GHashTable *__gst_function_pointers; /* NULL */
|
2012-01-22 22:44:59 +00:00
|
|
|
static GMutex __dbg_functions_mutex;
|
2005-09-21 21:39:06 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
/* This function MUST NOT return NULL */
|
2010-03-02 22:51:18 +00:00
|
|
|
const gchar *
|
2010-03-29 13:05:44 +00:00
|
|
|
_gst_debug_nameof_funcptr (GstDebugFuncPtr func)
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
|
|
|
gchar *ptrname;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-08-06 03:00:21 +00:00
|
|
|
#ifdef HAVE_DLADDR
|
2007-10-13 17:43:27 +00:00
|
|
|
Dl_info dl_info;
|
2003-08-06 03:00:21 +00:00
|
|
|
#endif
|
|
|
|
|
2006-09-01 15:55:20 +00:00
|
|
|
if (G_UNLIKELY (func == NULL))
|
|
|
|
return "(NULL)";
|
|
|
|
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_lock (&__dbg_functions_mutex);
|
2006-06-12 08:47:16 +00:00
|
|
|
if (G_LIKELY (__gst_function_pointers)) {
|
2006-10-06 14:46:04 +00:00
|
|
|
ptrname = g_hash_table_lookup (__gst_function_pointers, (gpointer) func);
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_unlock (&__dbg_functions_mutex);
|
2006-06-12 08:47:16 +00:00
|
|
|
if (G_LIKELY (ptrname))
|
2005-09-21 21:39:06 +00:00
|
|
|
return ptrname;
|
2006-09-01 15:55:20 +00:00
|
|
|
} else {
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_unlock (&__dbg_functions_mutex);
|
2003-08-07 12:45:31 +00:00
|
|
|
}
|
|
|
|
/* we need to create an entry in the hash table for this one so we don't leak
|
|
|
|
* the name */
|
2003-08-06 03:00:21 +00:00
|
|
|
#ifdef HAVE_DLADDR
|
2007-10-13 17:43:27 +00:00
|
|
|
if (dladdr ((gpointer) func, &dl_info) && dl_info.dli_sname) {
|
2019-04-16 11:29:00 +00:00
|
|
|
const gchar *name = g_intern_string (dl_info.dli_sname);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2006-10-06 14:46:04 +00:00
|
|
|
_gst_debug_register_funcptr (func, name);
|
2003-08-07 12:45:31 +00:00
|
|
|
return name;
|
2003-08-06 03:00:21 +00:00
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
{
|
2006-10-06 14:46:04 +00:00
|
|
|
gchar *name = g_strdup_printf ("%p", (gpointer) func);
|
2019-04-16 11:29:00 +00:00
|
|
|
const gchar *iname = g_intern_string (name);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2019-04-16 11:29:00 +00:00
|
|
|
g_free (name);
|
|
|
|
|
|
|
|
_gst_debug_register_funcptr (func, iname);
|
|
|
|
return iname;
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
}
|
2003-08-06 03:00:21 +00:00
|
|
|
|
2005-07-20 16:20:39 +00:00
|
|
|
void
|
2010-03-29 13:05:44 +00:00
|
|
|
_gst_debug_register_funcptr (GstDebugFuncPtr func, const gchar * ptrname)
|
2003-03-14 18:31:47 +00:00
|
|
|
{
|
2010-03-29 13:05:44 +00:00
|
|
|
gpointer ptr = (gpointer) func;
|
|
|
|
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_lock (&__dbg_functions_mutex);
|
2005-09-21 21:39:06 +00:00
|
|
|
|
2003-03-14 18:31:47 +00:00
|
|
|
if (!__gst_function_pointers)
|
|
|
|
__gst_function_pointers = g_hash_table_new (g_direct_hash, g_direct_equal);
|
2019-04-16 11:29:00 +00:00
|
|
|
if (!g_hash_table_lookup (__gst_function_pointers, ptr)) {
|
2006-10-26 00:00:34 +00:00
|
|
|
g_hash_table_insert (__gst_function_pointers, ptr, (gpointer) ptrname);
|
2019-04-16 11:29:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_mutex_unlock (&__dbg_functions_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_priv_gst_debug_cleanup (void)
|
|
|
|
{
|
|
|
|
g_mutex_lock (&__dbg_functions_mutex);
|
|
|
|
|
|
|
|
if (__gst_function_pointers) {
|
|
|
|
g_hash_table_unref (__gst_function_pointers);
|
|
|
|
__gst_function_pointers = NULL;
|
|
|
|
}
|
2005-09-21 21:39:06 +00:00
|
|
|
|
2012-01-22 22:44:59 +00:00
|
|
|
g_mutex_unlock (&__dbg_functions_mutex);
|
2003-03-14 18:31:47 +00:00
|
|
|
}
|
2001-09-10 19:46:01 +00:00
|
|
|
|
2009-04-06 00:27:26 +00:00
|
|
|
static void
|
|
|
|
gst_info_dump_mem_line (gchar * linebuf, gsize linebuf_size,
|
|
|
|
const guint8 * mem, gsize mem_offset, gsize mem_size)
|
|
|
|
{
|
|
|
|
gchar hexstr[50], ascstr[18], digitstr[4];
|
|
|
|
|
|
|
|
if (mem_size > 16)
|
|
|
|
mem_size = 16;
|
|
|
|
|
|
|
|
hexstr[0] = '\0';
|
|
|
|
ascstr[0] = '\0';
|
|
|
|
|
|
|
|
if (mem != NULL) {
|
|
|
|
guint i = 0;
|
|
|
|
|
|
|
|
mem += mem_offset;
|
|
|
|
while (i < mem_size) {
|
|
|
|
ascstr[i] = (g_ascii_isprint (mem[i])) ? mem[i] : '.';
|
|
|
|
g_snprintf (digitstr, sizeof (digitstr), "%02x ", mem[i]);
|
|
|
|
g_strlcat (hexstr, digitstr, sizeof (hexstr));
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
ascstr[i] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
g_snprintf (linebuf, linebuf_size, "%08x: %-48.48s %-16.16s",
|
2009-04-09 09:42:48 +00:00
|
|
|
(guint) mem_offset, hexstr, ascstr);
|
2009-04-06 00:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gst_debug_dump_mem (GstDebugCategory * cat, const gchar * file,
|
|
|
|
const gchar * func, gint line, GObject * obj, const gchar * msg,
|
|
|
|
const guint8 * data, guint length)
|
|
|
|
{
|
|
|
|
guint off = 0;
|
|
|
|
|
2009-10-07 21:08:47 +00:00
|
|
|
gst_debug_log ((cat), GST_LEVEL_MEMDUMP, file, func, line, obj, "--------"
|
|
|
|
"-------------------------------------------------------------------");
|
2009-04-06 00:27:26 +00:00
|
|
|
|
|
|
|
if (msg != NULL && *msg != '\0') {
|
2009-10-08 08:34:47 +00:00
|
|
|
gst_debug_log ((cat), GST_LEVEL_MEMDUMP, file, func, line, obj, "%s", msg);
|
2009-04-06 00:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
while (off < length) {
|
|
|
|
gchar buf[128];
|
|
|
|
|
|
|
|
/* gst_info_dump_mem_line will process 16 bytes at most */
|
|
|
|
gst_info_dump_mem_line (buf, sizeof (buf), data, off, length - off);
|
|
|
|
gst_debug_log (cat, GST_LEVEL_MEMDUMP, file, func, line, obj, "%s", buf);
|
|
|
|
off += 16;
|
|
|
|
}
|
|
|
|
|
2009-10-07 21:08:47 +00:00
|
|
|
gst_debug_log ((cat), GST_LEVEL_MEMDUMP, file, func, line, obj, "--------"
|
|
|
|
"-------------------------------------------------------------------");
|
2009-04-06 00:27:26 +00:00
|
|
|
}
|
|
|
|
|
2004-08-03 12:40:47 +00:00
|
|
|
#else /* !GST_DISABLE_GST_DEBUG */
|
2009-03-23 13:18:21 +00:00
|
|
|
#ifndef GST_REMOVE_DISABLED
|
2009-04-17 14:59:38 +00:00
|
|
|
|
|
|
|
GstDebugCategory *
|
|
|
|
_gst_debug_category_new (const gchar * name, guint color,
|
|
|
|
const gchar * description)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-03-29 13:05:44 +00:00
|
|
|
_gst_debug_register_funcptr (GstDebugFuncPtr func, const gchar * ptrname)
|
2009-04-17 14:59:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This function MUST NOT return NULL */
|
|
|
|
const gchar *
|
2010-03-29 13:05:44 +00:00
|
|
|
_gst_debug_nameof_funcptr (GstDebugFuncPtr func)
|
2009-04-17 14:59:38 +00:00
|
|
|
{
|
|
|
|
return "(NULL)";
|
|
|
|
}
|
|
|
|
|
2019-04-16 11:29:00 +00:00
|
|
|
void
|
|
|
|
_priv_gst_debug_cleanup (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-03-23 13:18:21 +00:00
|
|
|
void
|
|
|
|
gst_debug_log (GstDebugCategory * category, GstDebugLevel level,
|
|
|
|
const gchar * file, const gchar * function, gint line,
|
|
|
|
GObject * object, const gchar * format, ...)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gst_debug_log_valist (GstDebugCategory * category, GstDebugLevel level,
|
|
|
|
const gchar * file, const gchar * function, gint line,
|
|
|
|
GObject * object, const gchar * format, va_list args)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-04-16 19:26:00 +00:00
|
|
|
const gchar *
|
|
|
|
gst_debug_message_get (GstDebugMessage * message)
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2009-03-23 13:18:21 +00:00
|
|
|
void
|
|
|
|
gst_debug_log_default (GstDebugCategory * category, GstDebugLevel level,
|
|
|
|
const gchar * file, const gchar * function, gint line,
|
|
|
|
GObject * object, GstDebugMessage * message, gpointer unused)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-06-09 16:13:35 +00:00
|
|
|
const gchar *
|
2009-04-16 19:26:00 +00:00
|
|
|
gst_debug_level_get_name (GstDebugLevel level)
|
|
|
|
{
|
|
|
|
return "NONE";
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-07-06 23:37:50 +00:00
|
|
|
gst_debug_add_log_function (GstLogFunction func, gpointer user_data,
|
|
|
|
GDestroyNotify notify)
|
2009-04-16 19:26:00 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-02-25 00:10:05 +00:00
|
|
|
guint
|
|
|
|
gst_debug_remove_log_function (GstLogFunction func)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
guint
|
|
|
|
gst_debug_remove_log_function_by_data (gpointer data)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2004-08-03 12:40:47 +00:00
|
|
|
|
2009-04-16 19:26:00 +00:00
|
|
|
void
|
|
|
|
gst_debug_set_active (gboolean active)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gst_debug_is_active (void)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gst_debug_set_colored (gboolean colored)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-07-18 11:10:10 +00:00
|
|
|
void
|
|
|
|
gst_debug_set_color_mode (GstDebugColorMode mode)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gst_debug_set_color_mode_from_string (const gchar * str)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-04-16 19:26:00 +00:00
|
|
|
gboolean
|
|
|
|
gst_debug_is_colored (void)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-07-18 11:10:10 +00:00
|
|
|
GstDebugColorMode
|
|
|
|
gst_debug_get_color_mode (void)
|
|
|
|
{
|
|
|
|
return GST_DEBUG_COLOR_MODE_OFF;
|
|
|
|
}
|
|
|
|
|
2012-06-29 16:05:36 +00:00
|
|
|
void
|
2012-11-12 00:40:42 +00:00
|
|
|
gst_debug_set_threshold_from_string (const gchar * list, gboolean reset)
|
2012-06-29 16:05:36 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-04-16 19:26:00 +00:00
|
|
|
void
|
|
|
|
gst_debug_set_default_threshold (GstDebugLevel level)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
GstDebugLevel
|
|
|
|
gst_debug_get_default_threshold (void)
|
|
|
|
{
|
|
|
|
return GST_LEVEL_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gst_debug_set_threshold_for_name (const gchar * name, GstDebugLevel level)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gst_debug_unset_threshold_for_name (const gchar * name)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gst_debug_category_free (GstDebugCategory * category)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gst_debug_category_set_threshold (GstDebugCategory * category,
|
|
|
|
GstDebugLevel level)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gst_debug_category_reset_threshold (GstDebugCategory * category)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
GstDebugLevel
|
|
|
|
gst_debug_category_get_threshold (GstDebugCategory * category)
|
|
|
|
{
|
|
|
|
return GST_LEVEL_NONE;
|
|
|
|
}
|
|
|
|
|
2011-06-09 16:13:35 +00:00
|
|
|
const gchar *
|
2009-04-16 19:26:00 +00:00
|
|
|
gst_debug_category_get_name (GstDebugCategory * category)
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
guint
|
|
|
|
gst_debug_category_get_color (GstDebugCategory * category)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-06-09 16:13:35 +00:00
|
|
|
const gchar *
|
2009-04-16 19:26:00 +00:00
|
|
|
gst_debug_category_get_description (GstDebugCategory * category)
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
GSList *
|
|
|
|
gst_debug_get_all_categories (void)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-07-13 23:04:22 +00:00
|
|
|
GstDebugCategory *
|
|
|
|
_gst_debug_get_category (const gchar * name)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-04-16 19:26:00 +00:00
|
|
|
gchar *
|
|
|
|
gst_debug_construct_term_color (guint colorinfo)
|
|
|
|
{
|
|
|
|
return g_strdup ("00");
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gst_debug_construct_win_color (guint colorinfo)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-08-03 12:40:47 +00:00
|
|
|
gboolean
|
Makefile.am: Add check-exports target and run it as part of 'make check' (see #499140 and #493983).
Original commit message from CVS:
* Makefile.am:
Add check-exports target and run it as part of 'make check'
(see #499140 and #493983).
* gst/gst_private.h:
* gst/gstelementfactory.h:
* gst/gstghostpad.c: (gst_proxy_pad_class_init):
* gst/gstinfo.c: (_priv_gst_in_valgrind), (_gst_debug_init),
(_priv_gst_in_valgrind):
* gst/gstinfo.h: (GstLogFunction):
* gst/gsttypefind.c: (type_find_debug), (GST_CAT_DEFAULT),
(gst_type_find_register):
* gst/gsttypefindfactory.c: (type_find_debug), (GST_CAT_DEFAULT),
(gst_type_find_factory_get_type):
* libs/gst/controller/gstcontroller.c: (GST_CAT_DEFAULT),
(GST_CAT_DEFAULT), (parent_class), (priv_gst_controller_key),
(gst_controller_new_valist), (gst_controller_new_list),
(_gst_controller_dispose), (_gst_controller_class_init):
* libs/gst/controller/gstcontrolsource.c: (GST_CAT_DEFAULT):
* libs/gst/controller/gsthelper.c: (GST_CAT_DEFAULT),
(GST_CAT_DEFAULT), (gst_object_uncontrol_properties),
(gst_object_get_controller), (gst_object_set_controller),
(gst_object_suggest_next_sync), (gst_object_sync_values),
(gst_object_set_control_source), (gst_object_get_control_source),
(gst_object_get_value_arrays), (gst_object_get_value_array),
(gst_object_get_control_rate), (gst_object_set_control_rate):
* libs/gst/controller/gstinterpolation.c: (GST_CAT_DEFAULT):
* libs/gst/controller/lib.c: (GST_CAT_DEFAULT):
Make some functions that should be static static; rename some
private symbols so that they don't get exported; add some FIXME
comments so we can move accidentally exported functions into
our private section in 0.11.
* win32/common/libgstreamer.def:
Add gst_utils_get_timestamp().
2007-12-12 23:20:00 +00:00
|
|
|
_priv_gst_in_valgrind (void)
|
2004-08-03 12:40:47 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-04-06 00:27:26 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
_gst_debug_dump_mem (GstDebugCategory * cat, const gchar * file,
|
|
|
|
const gchar * func, gint line, GObject * obj, const gchar * msg,
|
|
|
|
const guint8 * data, guint length)
|
|
|
|
{
|
|
|
|
}
|
2009-03-23 13:18:21 +00:00
|
|
|
#endif /* GST_REMOVE_DISABLED */
|
2003-06-29 14:05:49 +00:00
|
|
|
#endif /* GST_DISABLE_GST_DEBUG */
|
2001-09-10 19:46:01 +00:00
|
|
|
|
2013-04-12 22:58:52 +00:00
|
|
|
/* Need this for _gst_element_error_printf even if GST_REMOVE_DISABLED is set:
|
|
|
|
* fallback function that cleans up the format string and replaces all pointer
|
|
|
|
* extension formats with plain %p. */
|
|
|
|
#ifdef GST_DISABLE_GST_DEBUG
|
|
|
|
int
|
|
|
|
__gst_info_fallback_vasprintf (char **result, char const *format, va_list args)
|
|
|
|
{
|
|
|
|
gchar *clean_format, *c;
|
|
|
|
gsize len;
|
|
|
|
|
|
|
|
if (format == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
clean_format = g_strdup (format);
|
|
|
|
c = clean_format;
|
|
|
|
while ((c = strstr (c, "%p\a"))) {
|
|
|
|
if (c[3] < 'A' || c[3] > 'Z') {
|
|
|
|
c += 3;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
len = strlen (c + 4);
|
2013-11-21 15:04:04 +00:00
|
|
|
memmove (c + 2, c + 4, len + 1);
|
2013-04-12 22:58:52 +00:00
|
|
|
c += 2;
|
|
|
|
}
|
|
|
|
while ((c = strstr (clean_format, "%P"))) /* old GST_PTR_FORMAT */
|
|
|
|
c[1] = 'p';
|
|
|
|
while ((c = strstr (clean_format, "%Q"))) /* old GST_SEGMENT_FORMAT */
|
|
|
|
c[1] = 'p';
|
|
|
|
|
|
|
|
len = g_vasprintf (result, clean_format, args);
|
|
|
|
|
|
|
|
g_free (clean_format);
|
|
|
|
|
|
|
|
if (*result == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
#endif
|
2004-08-03 12:40:47 +00:00
|
|
|
|
2016-01-11 05:31:39 +00:00
|
|
|
/**
|
|
|
|
* gst_info_vasprintf:
|
|
|
|
* @result: (out): the resulting string
|
|
|
|
* @format: a printf style format string
|
|
|
|
* @args: the va_list of printf arguments for @format
|
|
|
|
*
|
|
|
|
* Allocates and fills a string large enough (including the terminating null
|
|
|
|
* byte) to hold the specified printf style @format and @args.
|
|
|
|
*
|
|
|
|
* This function deals with the GStreamer specific printf specifiers
|
|
|
|
* #GST_PTR_FORMAT and #GST_SEGMENT_FORMAT. If you do not have these specifiers
|
|
|
|
* in your @format string, you do not need to use this function and can use
|
|
|
|
* alternatives such as g_vasprintf().
|
|
|
|
*
|
|
|
|
* Free @result with g_free().
|
|
|
|
*
|
|
|
|
* Returns: the length of the string allocated into @result or -1 on any error
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
*/
|
|
|
|
gint
|
|
|
|
gst_info_vasprintf (gchar ** result, const gchar * format, va_list args)
|
|
|
|
{
|
|
|
|
/* This will fallback to __gst_info_fallback_vasprintf() via a #define in
|
|
|
|
* gst_private.h if the debug system is disabled which will remove the gst
|
|
|
|
* specific printf format specifiers */
|
|
|
|
return __gst_vasprintf (result, format, args);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_info_strdup_vprintf:
|
|
|
|
* @format: a printf style format string
|
|
|
|
* @args: the va_list of printf arguments for @format
|
|
|
|
*
|
|
|
|
* Allocates, fills and returns a null terminated string from the printf style
|
|
|
|
* @format string and @args.
|
|
|
|
*
|
|
|
|
* See gst_info_vasprintf() for when this function is required.
|
|
|
|
*
|
|
|
|
* Free with g_free().
|
|
|
|
*
|
2017-10-22 12:35:30 +00:00
|
|
|
* Returns: (nullable): a newly allocated null terminated string or %NULL on any error
|
2016-01-11 05:31:39 +00:00
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
*/
|
|
|
|
gchar *
|
|
|
|
gst_info_strdup_vprintf (const gchar * format, va_list args)
|
|
|
|
{
|
|
|
|
gchar *ret;
|
|
|
|
|
|
|
|
if (gst_info_vasprintf (&ret, format, args) < 0)
|
|
|
|
ret = NULL;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_info_strdup_printf:
|
|
|
|
* @format: a printf style format string
|
|
|
|
* @...: the printf arguments for @format
|
|
|
|
*
|
2016-11-11 16:11:15 +00:00
|
|
|
* Allocates, fills and returns a 0-terminated string from the printf style
|
2016-01-11 05:31:39 +00:00
|
|
|
* @format string and corresponding arguments.
|
|
|
|
*
|
|
|
|
* See gst_info_vasprintf() for when this function is required.
|
|
|
|
*
|
|
|
|
* Free with g_free().
|
|
|
|
*
|
2017-10-22 12:35:30 +00:00
|
|
|
* Returns: (nullable): a newly allocated null terminated string or %NULL on any error
|
2016-01-11 05:31:39 +00:00
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
*/
|
|
|
|
gchar *
|
|
|
|
gst_info_strdup_printf (const gchar * format, ...)
|
|
|
|
{
|
|
|
|
gchar *ret;
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
va_start (args, format);
|
|
|
|
ret = gst_info_strdup_vprintf (format, args);
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-11-11 16:11:15 +00:00
|
|
|
/**
|
|
|
|
* gst_print:
|
|
|
|
* @format: a printf style format string
|
|
|
|
* @...: the printf arguments for @format
|
|
|
|
*
|
|
|
|
* Outputs a formatted message via the GLib print handler. The default print
|
|
|
|
* handler simply outputs the message to stdout.
|
|
|
|
*
|
|
|
|
* This function will not append a new-line character at the end, unlike
|
|
|
|
* gst_println() which will.
|
|
|
|
*
|
|
|
|
* All strings must be in ASCII or UTF-8 encoding.
|
|
|
|
*
|
|
|
|
* This function differs from g_print() in that it supports all the additional
|
|
|
|
* printf specifiers that are supported by GStreamer's debug logging system,
|
|
|
|
* such as #GST_PTR_FORMAT and #GST_SEGMENT_FORMAT.
|
|
|
|
*
|
|
|
|
* This function is primarily for printing debug output.
|
|
|
|
*
|
|
|
|
* Since: 1.12
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_print (const gchar * format, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
gchar *str;
|
|
|
|
|
|
|
|
va_start (args, format);
|
|
|
|
str = gst_info_strdup_vprintf (format, args);
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
g_print ("%s", str);
|
|
|
|
g_free (str);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_println:
|
|
|
|
* @format: a printf style format string
|
|
|
|
* @...: the printf arguments for @format
|
|
|
|
*
|
|
|
|
* Outputs a formatted message via the GLib print handler. The default print
|
|
|
|
* handler simply outputs the message to stdout.
|
|
|
|
*
|
|
|
|
* This function will append a new-line character at the end, unlike
|
|
|
|
* gst_print() which will not.
|
|
|
|
*
|
|
|
|
* All strings must be in ASCII or UTF-8 encoding.
|
|
|
|
*
|
|
|
|
* This function differs from g_print() in that it supports all the additional
|
|
|
|
* printf specifiers that are supported by GStreamer's debug logging system,
|
|
|
|
* such as #GST_PTR_FORMAT and #GST_SEGMENT_FORMAT.
|
|
|
|
*
|
|
|
|
* This function is primarily for printing debug output.
|
|
|
|
*
|
|
|
|
* Since: 1.12
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_println (const gchar * format, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
gchar *str;
|
|
|
|
|
|
|
|
va_start (args, format);
|
|
|
|
str = gst_info_strdup_vprintf (format, args);
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
g_print ("%s\n", str);
|
|
|
|
g_free (str);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_printerr:
|
|
|
|
* @format: a printf style format string
|
|
|
|
* @...: the printf arguments for @format
|
|
|
|
*
|
|
|
|
* Outputs a formatted message via the GLib error message handler. The default
|
|
|
|
* handler simply outputs the message to stderr.
|
|
|
|
*
|
|
|
|
* This function will not append a new-line character at the end, unlike
|
|
|
|
* gst_printerrln() which will.
|
|
|
|
*
|
|
|
|
* All strings must be in ASCII or UTF-8 encoding.
|
|
|
|
*
|
|
|
|
* This function differs from g_printerr() in that it supports the additional
|
|
|
|
* printf specifiers that are supported by GStreamer's debug logging system,
|
|
|
|
* such as #GST_PTR_FORMAT and #GST_SEGMENT_FORMAT.
|
|
|
|
*
|
|
|
|
* This function is primarily for printing debug output.
|
|
|
|
*
|
|
|
|
* Since: 1.12
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_printerr (const gchar * format, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
gchar *str;
|
|
|
|
|
|
|
|
va_start (args, format);
|
|
|
|
str = gst_info_strdup_vprintf (format, args);
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
g_printerr ("%s", str);
|
|
|
|
g_free (str);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_printerrln:
|
|
|
|
* @format: a printf style format string
|
|
|
|
* @...: the printf arguments for @format
|
|
|
|
*
|
|
|
|
* Outputs a formatted message via the GLib error message handler. The default
|
|
|
|
* handler simply outputs the message to stderr.
|
|
|
|
*
|
|
|
|
* This function will append a new-line character at the end, unlike
|
|
|
|
* gst_printerr() which will not.
|
|
|
|
*
|
|
|
|
* All strings must be in ASCII or UTF-8 encoding.
|
|
|
|
*
|
|
|
|
* This function differs from g_printerr() in that it supports the additional
|
|
|
|
* printf specifiers that are supported by GStreamer's debug logging system,
|
|
|
|
* such as #GST_PTR_FORMAT and #GST_SEGMENT_FORMAT.
|
|
|
|
*
|
|
|
|
* This function is primarily for printing debug output.
|
|
|
|
*
|
|
|
|
* Since: 1.12
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_printerrln (const gchar * format, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
gchar *str;
|
|
|
|
|
|
|
|
va_start (args, format);
|
|
|
|
str = gst_info_strdup_vprintf (format, args);
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
g_printerr ("%s\n", str);
|
|
|
|
g_free (str);
|
|
|
|
}
|
|
|
|
|
2016-10-07 09:38:27 +00:00
|
|
|
#ifdef HAVE_UNWIND
|
|
|
|
#ifdef HAVE_DW
|
|
|
|
static gboolean
|
2016-11-29 20:34:40 +00:00
|
|
|
append_debug_info (GString * trace, Dwfl * dwfl, const void *ip)
|
2016-10-07 09:38:27 +00:00
|
|
|
{
|
|
|
|
Dwfl_Line *line;
|
|
|
|
Dwarf_Addr addr;
|
|
|
|
Dwfl_Module *module;
|
|
|
|
const gchar *function_name;
|
|
|
|
|
|
|
|
if (dwfl_linux_proc_report (dwfl, getpid ()) != 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (dwfl_report_end (dwfl, NULL, NULL))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
addr = (uintptr_t) ip;
|
|
|
|
module = dwfl_addrmodule (dwfl, addr);
|
|
|
|
function_name = dwfl_module_addrname (module, addr);
|
|
|
|
|
2016-10-10 14:40:21 +00:00
|
|
|
g_string_append_printf (trace, "%s (", function_name ? function_name : "??");
|
2016-10-07 09:38:27 +00:00
|
|
|
|
|
|
|
line = dwfl_getsrc (dwfl, addr);
|
|
|
|
if (line != NULL) {
|
|
|
|
gint nline;
|
|
|
|
Dwarf_Addr addr;
|
|
|
|
const gchar *filename = dwfl_lineinfo (line, &addr,
|
|
|
|
&nline, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
g_string_append_printf (trace, "%s:%d", strrchr (filename,
|
|
|
|
G_DIR_SEPARATOR) + 1, nline);
|
|
|
|
} else {
|
|
|
|
const gchar *eflfile = NULL;
|
|
|
|
|
|
|
|
dwfl_module_info (module, NULL, NULL, NULL, NULL, NULL, &eflfile, NULL);
|
|
|
|
g_string_append_printf (trace, "%s:%p", eflfile ? eflfile : "??", ip);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
#endif /* HAVE_DW */
|
|
|
|
|
|
|
|
static gchar *
|
2016-11-30 18:10:48 +00:00
|
|
|
generate_unwind_trace (GstStackTraceFlags flags)
|
2001-10-17 10:21:27 +00:00
|
|
|
{
|
2017-01-26 16:35:27 +00:00
|
|
|
gint unret;
|
2016-10-07 09:38:27 +00:00
|
|
|
unw_context_t uc;
|
|
|
|
unw_cursor_t cursor;
|
|
|
|
gboolean use_libunwind = TRUE;
|
|
|
|
GString *trace = g_string_new (NULL);
|
|
|
|
|
2016-11-29 20:34:40 +00:00
|
|
|
#ifdef HAVE_DW
|
2016-11-30 18:10:48 +00:00
|
|
|
Dwfl *dwfl = NULL;
|
2016-11-29 20:34:40 +00:00
|
|
|
Dwfl_Callbacks callbacks = {
|
|
|
|
.find_elf = dwfl_linux_proc_find_elf,
|
|
|
|
.find_debuginfo = dwfl_standard_find_debuginfo,
|
|
|
|
};
|
|
|
|
|
2016-11-30 18:10:48 +00:00
|
|
|
if ((flags & GST_STACK_TRACE_SHOW_FULL))
|
|
|
|
dwfl = dwfl_begin (&callbacks);
|
2016-11-29 20:34:40 +00:00
|
|
|
#endif /* HAVE_DW */
|
|
|
|
|
2017-01-26 16:35:27 +00:00
|
|
|
unret = unw_getcontext (&uc);
|
|
|
|
if (unret) {
|
|
|
|
GST_DEBUG ("Could not get libunwind context (%d)", unret);
|
|
|
|
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
unret = unw_init_local (&cursor, &uc);
|
|
|
|
if (unret) {
|
|
|
|
GST_DEBUG ("Could not init libunwind context (%d)", unret);
|
|
|
|
|
|
|
|
goto done;
|
|
|
|
}
|
2016-10-07 09:38:27 +00:00
|
|
|
|
|
|
|
while (unw_step (&cursor) > 0) {
|
|
|
|
#ifdef HAVE_DW
|
2016-11-29 20:34:40 +00:00
|
|
|
if (dwfl) {
|
|
|
|
unw_word_t ip;
|
2016-10-07 09:38:27 +00:00
|
|
|
|
2017-01-26 16:35:27 +00:00
|
|
|
unret = unw_get_reg (&cursor, UNW_REG_IP, &ip);
|
|
|
|
if (unret) {
|
|
|
|
GST_DEBUG ("libunwind could read frame info (%d)", unret);
|
|
|
|
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2016-11-29 20:34:40 +00:00
|
|
|
if (append_debug_info (trace, dwfl, (void *) (ip - 4))) {
|
|
|
|
use_libunwind = FALSE;
|
|
|
|
g_string_append (trace, ")\n");
|
|
|
|
}
|
2016-10-07 09:38:27 +00:00
|
|
|
}
|
|
|
|
#endif /* HAVE_DW */
|
|
|
|
|
|
|
|
if (use_libunwind) {
|
|
|
|
char name[32];
|
|
|
|
|
|
|
|
unw_word_t offset = 0;
|
|
|
|
unw_get_proc_name (&cursor, name, sizeof (name), &offset);
|
|
|
|
g_string_append_printf (trace, "%s (0x%" G_GSIZE_FORMAT ")\n", name,
|
|
|
|
(gsize) offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-26 16:35:27 +00:00
|
|
|
done:
|
2016-11-29 20:34:40 +00:00
|
|
|
#ifdef HAVE_DW
|
2016-11-30 18:10:48 +00:00
|
|
|
if (dwfl)
|
|
|
|
dwfl_end (dwfl);
|
2016-11-29 20:34:40 +00:00
|
|
|
#endif
|
|
|
|
|
2016-10-07 09:38:27 +00:00
|
|
|
return g_string_free (trace, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* HAVE_UNWIND */
|
|
|
|
|
|
|
|
#ifdef HAVE_BACKTRACE
|
|
|
|
static gchar *
|
|
|
|
generate_backtrace_trace (void)
|
|
|
|
{
|
|
|
|
int j, nptrs;
|
|
|
|
void *buffer[BT_BUF_SIZE];
|
|
|
|
char **strings;
|
|
|
|
GString *trace;
|
|
|
|
|
|
|
|
trace = g_string_new (NULL);
|
|
|
|
nptrs = backtrace (buffer, BT_BUF_SIZE);
|
|
|
|
|
|
|
|
strings = backtrace_symbols (buffer, nptrs);
|
|
|
|
|
|
|
|
if (!strings)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
for (j = 0; j < nptrs; j++)
|
|
|
|
g_string_append_printf (trace, "%s\n", strings[j]);
|
|
|
|
|
2017-11-25 12:07:12 +00:00
|
|
|
free (strings);
|
2017-11-25 11:44:11 +00:00
|
|
|
|
2016-10-07 09:38:27 +00:00
|
|
|
return g_string_free (trace, FALSE);
|
2001-09-10 19:46:01 +00:00
|
|
|
}
|
2016-12-13 12:20:09 +00:00
|
|
|
#else
|
|
|
|
#define generate_backtrace_trace() NULL
|
2016-10-07 09:38:27 +00:00
|
|
|
#endif /* HAVE_BACKTRACE */
|
|
|
|
|
2019-01-25 01:36:18 +00:00
|
|
|
#ifdef HAVE_DBGHELP
|
|
|
|
static void
|
|
|
|
dbghelp_initialize_symbols (HANDLE process)
|
|
|
|
{
|
|
|
|
static gsize initialization_value = 0;
|
|
|
|
|
|
|
|
if (g_once_init_enter (&initialization_value)) {
|
|
|
|
GST_INFO ("Initializing Windows symbol handler");
|
|
|
|
SymSetOptions (SYMOPT_LOAD_LINES);
|
|
|
|
SymInitialize (process, NULL, TRUE);
|
|
|
|
GST_INFO ("Initialized Windows symbol handler");
|
|
|
|
|
|
|
|
g_once_init_leave (&initialization_value, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
generate_dbghelp_trace (void)
|
|
|
|
{
|
|
|
|
HANDLE process = GetCurrentProcess ();
|
|
|
|
HANDLE thread = GetCurrentThread ();
|
|
|
|
IMAGEHLP_MODULE64 module_info;
|
|
|
|
DWORD machine;
|
|
|
|
CONTEXT context;
|
|
|
|
STACKFRAME64 frame = { 0 };
|
|
|
|
PVOID save_context;
|
|
|
|
GString *trace = g_string_new (NULL);
|
|
|
|
|
|
|
|
dbghelp_initialize_symbols (process);
|
|
|
|
|
|
|
|
memset (&context, 0, sizeof (CONTEXT));
|
|
|
|
context.ContextFlags = CONTEXT_FULL;
|
|
|
|
|
|
|
|
RtlCaptureContext (&context);
|
|
|
|
|
|
|
|
frame.AddrPC.Mode = AddrModeFlat;
|
|
|
|
frame.AddrStack.Mode = AddrModeFlat;
|
|
|
|
frame.AddrFrame.Mode = AddrModeFlat;
|
|
|
|
|
|
|
|
#if (defined _M_IX86)
|
|
|
|
machine = IMAGE_FILE_MACHINE_I386;
|
|
|
|
frame.AddrFrame.Offset = context.Ebp;
|
|
|
|
frame.AddrPC.Offset = context.Eip;
|
|
|
|
frame.AddrStack.Offset = context.Esp;
|
|
|
|
#elif (defined _M_X64)
|
|
|
|
machine = IMAGE_FILE_MACHINE_AMD64;
|
|
|
|
frame.AddrFrame.Offset = context.Rbp;
|
|
|
|
frame.AddrPC.Offset = context.Rip;
|
|
|
|
frame.AddrStack.Offset = context.Rsp;
|
|
|
|
#else
|
|
|
|
goto done;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
module_info.SizeOfStruct = sizeof (module_info);
|
|
|
|
save_context = (machine == IMAGE_FILE_MACHINE_I386) ? NULL : &context;
|
|
|
|
|
|
|
|
while (TRUE) {
|
|
|
|
char buffer[sizeof (SYMBOL_INFO) + MAX_SYM_NAME * sizeof (TCHAR)];
|
|
|
|
PSYMBOL_INFO symbol = (PSYMBOL_INFO) buffer;
|
|
|
|
IMAGEHLP_LINE64 line;
|
|
|
|
DWORD displacement = 0;
|
|
|
|
|
|
|
|
symbol->SizeOfStruct = sizeof (SYMBOL_INFO);
|
|
|
|
symbol->MaxNameLen = MAX_SYM_NAME;
|
|
|
|
|
|
|
|
line.SizeOfStruct = sizeof (line);
|
|
|
|
|
|
|
|
if (!StackWalk64 (machine, process, thread, &frame, save_context, 0,
|
|
|
|
SymFunctionTableAccess64, SymGetModuleBase64, 0))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (SymFromAddr (process, frame.AddrPC.Offset, 0, symbol))
|
|
|
|
g_string_append_printf (trace, "%s ", symbol->Name);
|
|
|
|
else
|
|
|
|
g_string_append (trace, "?? ");
|
|
|
|
|
|
|
|
if (SymGetLineFromAddr64 (process, frame.AddrPC.Offset, &displacement,
|
|
|
|
&line))
|
|
|
|
g_string_append_printf (trace, "(%s:%u)", line.FileName, line.LineNumber);
|
|
|
|
else if (SymGetModuleInfo64 (process, frame.AddrPC.Offset, &module_info))
|
|
|
|
g_string_append_printf (trace, "(%s)", module_info.ImageName);
|
|
|
|
else
|
|
|
|
g_string_append_printf (trace, "(%s)", "??");
|
|
|
|
|
|
|
|
g_string_append (trace, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
return g_string_free (trace, FALSE);
|
|
|
|
}
|
|
|
|
#endif /* HAVE_DBGHELP */
|
|
|
|
|
2016-10-10 14:40:21 +00:00
|
|
|
/**
|
|
|
|
* gst_debug_get_stack_trace:
|
2016-11-30 18:10:48 +00:00
|
|
|
* @flags: A set of #GstStackTraceFlags to determine how the stack
|
|
|
|
* trace should look like. Pass 0 to retrieve a minimal backtrace.
|
2016-10-10 14:40:21 +00:00
|
|
|
*
|
2017-10-22 12:35:30 +00:00
|
|
|
* Returns: (nullable): a stack trace, if libunwind or glibc backtrace are
|
|
|
|
* present, else %NULL.
|
2016-11-30 18:10:48 +00:00
|
|
|
*
|
|
|
|
* Since: 1.12
|
2016-10-10 14:40:21 +00:00
|
|
|
*/
|
2016-10-07 09:38:27 +00:00
|
|
|
gchar *
|
2016-11-30 18:10:48 +00:00
|
|
|
gst_debug_get_stack_trace (GstStackTraceFlags flags)
|
2016-10-07 09:38:27 +00:00
|
|
|
{
|
|
|
|
gchar *trace = NULL;
|
2016-11-30 18:10:48 +00:00
|
|
|
#ifdef HAVE_BACKTRACE
|
|
|
|
gboolean have_backtrace = TRUE;
|
|
|
|
#else
|
|
|
|
gboolean have_backtrace = FALSE;
|
|
|
|
#endif
|
2016-10-07 09:38:27 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_UNWIND
|
2016-11-30 18:10:48 +00:00
|
|
|
if ((flags & GST_STACK_TRACE_SHOW_FULL) || !have_backtrace)
|
|
|
|
trace = generate_unwind_trace (flags);
|
2016-10-07 09:38:27 +00:00
|
|
|
#endif /* HAVE_UNWIND */
|
2001-09-10 19:46:01 +00:00
|
|
|
|
2019-01-25 01:36:18 +00:00
|
|
|
#ifdef HAVE_DBGHELP
|
|
|
|
trace = generate_dbghelp_trace ();
|
|
|
|
#endif
|
|
|
|
|
2016-11-30 18:10:48 +00:00
|
|
|
if (trace)
|
|
|
|
return trace;
|
|
|
|
else if (have_backtrace)
|
|
|
|
return generate_backtrace_trace ();
|
2016-10-07 09:38:27 +00:00
|
|
|
|
2016-11-30 18:10:48 +00:00
|
|
|
return NULL;
|
2016-10-07 09:38:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_debug_print_stack_trace:
|
|
|
|
*
|
2019-01-25 01:36:18 +00:00
|
|
|
* If libunwind, glibc backtrace or DbgHelp are present
|
2016-10-10 14:40:21 +00:00
|
|
|
* a stack trace is printed.
|
2016-10-07 09:38:27 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_debug_print_stack_trace (void)
|
|
|
|
{
|
2016-11-30 18:10:48 +00:00
|
|
|
gchar *trace = gst_debug_get_stack_trace (GST_STACK_TRACE_SHOW_FULL);
|
2016-10-07 09:38:27 +00:00
|
|
|
|
|
|
|
if (trace)
|
|
|
|
g_print ("%s\n", trace);
|
|
|
|
|
|
|
|
g_free (trace);
|
|
|
|
}
|
2017-07-17 18:03:11 +00:00
|
|
|
|
2017-07-29 09:28:03 +00:00
|
|
|
#ifndef GST_DISABLE_GST_DEBUG
|
2017-07-17 18:03:11 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
guint max_size_per_thread;
|
|
|
|
guint thread_timeout;
|
|
|
|
GQueue threads;
|
|
|
|
GHashTable *thread_index;
|
|
|
|
} GstRingBufferLogger;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GList *link;
|
|
|
|
gint64 last_use;
|
|
|
|
GThread *thread;
|
|
|
|
|
|
|
|
GQueue log;
|
|
|
|
gsize log_size;
|
|
|
|
} GstRingBufferLog;
|
|
|
|
|
|
|
|
G_LOCK_DEFINE_STATIC (ring_buffer_logger);
|
|
|
|
static GstRingBufferLogger *ring_buffer_logger = NULL;
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_ring_buffer_logger_log (GstDebugCategory * category,
|
|
|
|
GstDebugLevel level,
|
|
|
|
const gchar * file,
|
|
|
|
const gchar * function,
|
|
|
|
gint line, GObject * object, GstDebugMessage * message, gpointer user_data)
|
|
|
|
{
|
|
|
|
GstRingBufferLogger *logger = user_data;
|
|
|
|
gint pid;
|
|
|
|
GThread *thread;
|
|
|
|
GstClockTime elapsed;
|
|
|
|
gchar *obj = NULL;
|
|
|
|
gchar c;
|
|
|
|
gchar *output;
|
|
|
|
gsize output_len;
|
|
|
|
GstRingBufferLog *log;
|
|
|
|
gint64 now = g_get_monotonic_time ();
|
|
|
|
const gchar *message_str = gst_debug_message_get (message);
|
|
|
|
|
|
|
|
G_LOCK (ring_buffer_logger);
|
|
|
|
|
|
|
|
if (logger->thread_timeout > 0) {
|
|
|
|
/* Remove all threads that saw no output since thread_timeout seconds.
|
|
|
|
* By construction these are all at the tail of the queue, and the queue
|
|
|
|
* is ordered by last use, so we just need to look at the tail.
|
|
|
|
*/
|
|
|
|
while (logger->threads.tail) {
|
|
|
|
log = logger->threads.tail->data;
|
|
|
|
if (log->last_use + logger->thread_timeout * G_USEC_PER_SEC >= now)
|
|
|
|
break;
|
|
|
|
|
|
|
|
g_hash_table_remove (logger->thread_index, log->thread);
|
|
|
|
while ((output = g_queue_pop_head (&log->log)))
|
|
|
|
g_free (output);
|
|
|
|
g_free (log);
|
|
|
|
g_queue_pop_tail (&logger->threads);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get logger for this thread, and put it back at the
|
|
|
|
* head of the threads queue */
|
|
|
|
thread = g_thread_self ();
|
|
|
|
log = g_hash_table_lookup (logger->thread_index, thread);
|
|
|
|
if (!log) {
|
|
|
|
log = g_new0 (GstRingBufferLog, 1);
|
|
|
|
g_queue_init (&log->log);
|
|
|
|
log->log_size = 0;
|
|
|
|
g_queue_push_head (&logger->threads, log);
|
|
|
|
log->link = logger->threads.head;
|
|
|
|
log->thread = thread;
|
|
|
|
g_hash_table_insert (logger->thread_index, thread, log);
|
|
|
|
} else {
|
|
|
|
g_queue_unlink (&logger->threads, log->link);
|
|
|
|
g_queue_push_head_link (&logger->threads, log->link);
|
|
|
|
}
|
|
|
|
log->last_use = now;
|
|
|
|
|
|
|
|
/* __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
|
|
|
|
* readability. */
|
|
|
|
c = file[0];
|
|
|
|
if (c == '.' || c == '/' || c == '\\' || (c != '\0' && file[1] == ':')) {
|
|
|
|
file = gst_path_basename (file);
|
|
|
|
}
|
|
|
|
|
|
|
|
pid = getpid ();
|
|
|
|
|
|
|
|
if (object) {
|
|
|
|
obj = gst_debug_print_object (object);
|
|
|
|
} else {
|
|
|
|
obj = (gchar *) "";
|
|
|
|
}
|
|
|
|
|
|
|
|
elapsed = GST_CLOCK_DIFF (_priv_gst_start_time, gst_util_get_timestamp ());
|
|
|
|
|
|
|
|
/* no color, all platforms */
|
|
|
|
#define PRINT_FMT " "PID_FMT" "PTR_FMT" %s "CAT_FMT" %s\n"
|
|
|
|
output =
|
|
|
|
g_strdup_printf ("%" GST_TIME_FORMAT PRINT_FMT, GST_TIME_ARGS (elapsed),
|
|
|
|
pid, thread, gst_debug_level_get_name (level),
|
|
|
|
gst_debug_category_get_name (category), file, line, function, obj,
|
|
|
|
message_str);
|
|
|
|
#undef PRINT_FMT
|
|
|
|
|
|
|
|
output_len = strlen (output);
|
|
|
|
|
|
|
|
if (output_len < logger->max_size_per_thread) {
|
|
|
|
gchar *buf;
|
|
|
|
|
|
|
|
/* While using a GQueue here is not the most efficient thing to do, we
|
|
|
|
* have to allocate a string for every output anyway and could just store
|
|
|
|
* that instead of copying it to an actual ringbuffer.
|
|
|
|
* Better than GQueue would be GstQueueArray, but that one is in
|
|
|
|
* libgstbase and we can't use it here. That one allocation will not make
|
|
|
|
* much of a difference anymore, considering the number of allocations
|
|
|
|
* needed to get to this point...
|
|
|
|
*/
|
|
|
|
while (log->log_size + output_len > logger->max_size_per_thread) {
|
|
|
|
buf = g_queue_pop_head (&log->log);
|
|
|
|
log->log_size -= strlen (buf);
|
|
|
|
g_free (buf);
|
|
|
|
}
|
|
|
|
g_queue_push_tail (&log->log, output);
|
|
|
|
log->log_size += output_len;
|
|
|
|
} else {
|
|
|
|
gchar *buf;
|
|
|
|
|
|
|
|
/* Can't really write anything as the line is bigger than the maximum
|
|
|
|
* allowed log size already, so just remove everything */
|
|
|
|
|
|
|
|
while ((buf = g_queue_pop_head (&log->log)))
|
|
|
|
g_free (buf);
|
|
|
|
g_free (output);
|
|
|
|
log->log_size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (object != NULL)
|
|
|
|
g_free (obj);
|
|
|
|
|
|
|
|
G_UNLOCK (ring_buffer_logger);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_debug_ring_buffer_logger_get_logs:
|
|
|
|
*
|
|
|
|
* Fetches the current logs per thread from the ring buffer logger. See
|
|
|
|
* gst_debug_add_ring_buffer_logger() for details.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full) (array zero-terminated): NULL-terminated array of
|
|
|
|
* strings with the debug output per thread
|
|
|
|
*
|
|
|
|
* Since: 1.14
|
|
|
|
*/
|
|
|
|
gchar **
|
|
|
|
gst_debug_ring_buffer_logger_get_logs (void)
|
|
|
|
{
|
|
|
|
gchar **logs, **tmp;
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
g_return_val_if_fail (ring_buffer_logger != NULL, NULL);
|
|
|
|
|
|
|
|
G_LOCK (ring_buffer_logger);
|
|
|
|
|
|
|
|
tmp = logs = g_new0 (gchar *, ring_buffer_logger->threads.length + 1);
|
|
|
|
for (l = ring_buffer_logger->threads.head; l; l = l->next) {
|
|
|
|
GstRingBufferLog *log = l->data;
|
|
|
|
GList *l;
|
|
|
|
gchar *p;
|
|
|
|
gsize len;
|
|
|
|
|
|
|
|
*tmp = p = g_new0 (gchar, log->log_size + 1);
|
|
|
|
|
|
|
|
for (l = log->log.head; l; l = l->next) {
|
|
|
|
len = strlen (l->data);
|
|
|
|
memcpy (p, l->data, len);
|
|
|
|
p += len;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp++;
|
|
|
|
}
|
|
|
|
|
|
|
|
G_UNLOCK (ring_buffer_logger);
|
|
|
|
|
|
|
|
return logs;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_ring_buffer_logger_free (GstRingBufferLogger * logger)
|
|
|
|
{
|
|
|
|
G_LOCK (ring_buffer_logger);
|
|
|
|
if (ring_buffer_logger == logger) {
|
|
|
|
GstRingBufferLog *log;
|
|
|
|
|
|
|
|
while ((log = g_queue_pop_head (&logger->threads))) {
|
|
|
|
gchar *buf;
|
|
|
|
while ((buf = g_queue_pop_head (&log->log)))
|
|
|
|
g_free (buf);
|
|
|
|
g_free (log);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_hash_table_unref (logger->thread_index);
|
|
|
|
|
|
|
|
g_free (logger);
|
|
|
|
ring_buffer_logger = NULL;
|
|
|
|
}
|
|
|
|
G_UNLOCK (ring_buffer_logger);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_debug_add_ring_buffer_logger:
|
|
|
|
* @max_size_per_thread: Maximum size of log per thread in bytes
|
|
|
|
* @thread_timeout: Timeout for threads in seconds
|
|
|
|
*
|
|
|
|
* Adds a memory ringbuffer based debug logger that stores up to
|
|
|
|
* @max_size_per_thread bytes of logs per thread and times out threads after
|
|
|
|
* @thread_timeout seconds of inactivity.
|
|
|
|
*
|
|
|
|
* Logs can be fetched with gst_debug_ring_buffer_logger_get_logs() and the
|
|
|
|
* logger can be removed again with gst_debug_remove_ring_buffer_logger().
|
|
|
|
* Only one logger at a time is possible.
|
|
|
|
*
|
|
|
|
* Since: 1.14
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_debug_add_ring_buffer_logger (guint max_size_per_thread,
|
|
|
|
guint thread_timeout)
|
|
|
|
{
|
|
|
|
GstRingBufferLogger *logger;
|
|
|
|
|
|
|
|
G_LOCK (ring_buffer_logger);
|
|
|
|
|
|
|
|
if (ring_buffer_logger) {
|
|
|
|
g_warn_if_reached ();
|
|
|
|
G_UNLOCK (ring_buffer_logger);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
logger = ring_buffer_logger = g_new0 (GstRingBufferLogger, 1);
|
|
|
|
|
|
|
|
logger->max_size_per_thread = max_size_per_thread;
|
|
|
|
logger->thread_timeout = thread_timeout;
|
|
|
|
logger->thread_index = g_hash_table_new (g_direct_hash, g_direct_equal);
|
|
|
|
g_queue_init (&logger->threads);
|
|
|
|
|
|
|
|
gst_debug_add_log_function (gst_ring_buffer_logger_log, logger,
|
|
|
|
(GDestroyNotify) gst_ring_buffer_logger_free);
|
|
|
|
G_UNLOCK (ring_buffer_logger);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_debug_remove_ring_buffer_logger:
|
|
|
|
*
|
|
|
|
* Removes any previously added ring buffer logger with
|
|
|
|
* gst_debug_add_ring_buffer_logger().
|
|
|
|
*
|
|
|
|
* Since: 1.14
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_debug_remove_ring_buffer_logger (void)
|
|
|
|
{
|
|
|
|
gst_debug_remove_log_function (gst_ring_buffer_logger_log);
|
|
|
|
}
|
2017-07-29 09:28:03 +00:00
|
|
|
|
|
|
|
#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 */
|