mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 06:46:38 +00:00
leakstracer: Add API for logging leaks in the debug log
This is the equivalent of sending SIGUSR1 to the application, and is useful on platforms where UNIX signals are not available, such as Windows.
This commit is contained in:
parent
44198ec4d6
commit
6e3565ca86
2 changed files with 27 additions and 11 deletions
|
@ -74,6 +74,7 @@ enum
|
|||
{
|
||||
/* actions */
|
||||
SIGNAL_GET_LIVE_OBJECTS,
|
||||
SIGNAL_LOG_LIVE_OBJECTS,
|
||||
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
@ -87,6 +88,7 @@ G_DEFINE_TYPE_WITH_CODE (GstLeaksTracer, gst_leaks_tracer,
|
|||
GST_TYPE_TRACER, _do_init);
|
||||
|
||||
static GstStructure *gst_leaks_tracer_get_live_objects (GstLeaksTracer * self);
|
||||
static void gst_leaks_tracer_log_live_objects (GstLeaksTracer * self);
|
||||
|
||||
static GstTracerRecord *tr_alive;
|
||||
static GstTracerRecord *tr_refings;
|
||||
|
@ -754,20 +756,10 @@ gst_leaks_tracer_finalize (GObject * object)
|
|||
NULL)
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
static void
|
||||
sig_usr1_handler_foreach (gpointer data, gpointer user_data)
|
||||
{
|
||||
GstLeaksTracer *tracer = data;
|
||||
|
||||
GST_OBJECT_LOCK (tracer);
|
||||
process_leaks (tracer, NULL);
|
||||
GST_OBJECT_UNLOCK (tracer);
|
||||
}
|
||||
|
||||
static void
|
||||
sig_usr1_handler (G_GNUC_UNUSED int signal)
|
||||
{
|
||||
g_queue_foreach (&instances, sig_usr1_handler_foreach, NULL);
|
||||
g_queue_foreach (&instances, (GFunc) gst_leaks_tracer_log_live_objects, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -859,6 +851,14 @@ gst_leaks_tracer_get_live_objects (GstLeaksTracer * self)
|
|||
return info;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_leaks_tracer_log_live_objects (GstLeaksTracer * self)
|
||||
{
|
||||
GST_OBJECT_LOCK (self);
|
||||
process_leaks (self, NULL);
|
||||
GST_OBJECT_UNLOCK (self);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_leaks_tracer_class_init (GstLeaksTracerClass * klass)
|
||||
{
|
||||
|
@ -920,5 +920,20 @@ gst_leaks_tracer_class_init (GstLeaksTracerClass * klass)
|
|||
get_live_objects), NULL, NULL, NULL, GST_TYPE_STRUCTURE, 0,
|
||||
G_TYPE_NONE);
|
||||
|
||||
/**
|
||||
* GstLeaksTracer::log-live-objects:
|
||||
* @leakstracer: the leaks tracer object to emit this signal on
|
||||
*
|
||||
* Logs all objects that are still alive to the debug log in the same format
|
||||
* as the logging during gst_deinit().
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
gst_leaks_tracer_signals[SIGNAL_LOG_LIVE_OBJECTS] =
|
||||
g_signal_new ("log-live-objects", G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (GstLeaksTracerClass,
|
||||
log_live_objects), NULL, NULL, NULL, G_TYPE_NONE, 0, G_TYPE_NONE);
|
||||
|
||||
klass->get_live_objects = gst_leaks_tracer_get_live_objects;
|
||||
klass->log_live_objects = gst_leaks_tracer_log_live_objects;
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ struct _GstLeaksTracerClass {
|
|||
|
||||
/* actions */
|
||||
GstStructure * (*get_live_objects) (GstLeaksTracer *tracer);
|
||||
void (*log_live_objects) (GstLeaksTracer *tracer);
|
||||
};
|
||||
|
||||
G_GNUC_INTERNAL GType gst_leaks_tracer_get_type (void);
|
||||
|
|
Loading…
Reference in a new issue