[glib] Add some mainloop instrumentation



commit a9d93ca1dfbee4d4b6bb0880493be5ed6efac62c
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Nov 23 00:22:09 2013 -0500

    Add some mainloop instrumentation
    
    Add trace points around adding, removing and dispatching of
    sources.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=710741

 glib/glib.stp.in   |   22 ++++++++++++++++++++++
 glib/glib_probes.d |    4 ++++
 glib/gmain.c       |    8 ++++++++
 3 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/glib/glib.stp.in b/glib/glib.stp.in
index 95d3351..41f2bbd 100644
--- a/glib/glib.stp.in
+++ b/glib/glib.stp.in
@@ -82,3 +82,25 @@ probe glib.slice_free = process("@ABS_GLIB_RUNTIME_LIBDIR@/libglib-2 0 so 0  LT_
   n_bytes = $arg2; 
   probestr = sprintf("glib.slice_free(n_bytes=%d) -> %p", n_bytes, mem);
 }
+
+/**
+ *  * probe glib.main_before_dispatch - Called before dispatching a GSource
+ *   * @source: name of the source
+ *    * @callback: address of the callback
+ *     */
+probe glib.main_before_dispatch = process("@ABS_GLIB_RUNTIME_LIBDIR@/libglib-2 0 so 0  LT_CURRENT@  
LT_REVISION@").mark("main__before_dispatch")
+{
+       source = user_string2($arg1, "unnamed");
+       probestr = sprintf("glib.main_before_dispatch(source=%s)", source);
+}
+
+/**
+ *  * probe glib.main_after_dispatch - Called after dispatching a GSource
+ *   * @source: name of the source
+ *    * @callback: address of the callback
+ *     */
+probe glib.main_after_dispatch = process("@ABS_GLIB_RUNTIME_LIBDIR@/libglib-2 0 so 0  LT_CURRENT@  
LT_REVISION@").mark("main__after_dispatch")
+{
+       source = user_string2($arg1, "unnamed");
+       probestr = sprintf("glib.main_after_dispatch(source=%s)", source);
+}
diff --git a/glib/glib_probes.d b/glib/glib_probes.d
index 9232e1b..ac955e8 100644
--- a/glib/glib_probes.d
+++ b/glib/glib_probes.d
@@ -5,4 +5,8 @@ provider glib {
        probe slice__alloc(void*, unsigned int);
        probe slice__free(void*, unsigned int);
        probe quark__new(char *, unsigned int);
+       probe main__before_dispatch (char *);
+        probe main__after_dispatch (char *);
+        probe main__source_attach(char*);
+        probe main__source_destroy(char*);
 };
diff --git a/glib/gmain.c b/glib/gmain.c
index c3b1f16..0900374 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -73,6 +73,8 @@
 #include <windows.h>
 #endif /* G_OS_WIN32 */
 
+#include "glib_trace.h"
+
 #include "gmain.h"
 
 #include "garray.h"
@@ -1165,6 +1167,8 @@ g_source_attach (GSource      *source,
   g_return_val_if_fail (source->context == NULL, 0);
   g_return_val_if_fail (!SOURCE_DESTROYED (source), 0);
   
+  TRACE (GLIB_MAIN_SOURCE_ATTACH (g_source_get_name (source)));
+
   if (!context)
     context = g_main_context_default ();
 
@@ -1182,6 +1186,8 @@ g_source_destroy_internal (GSource      *source,
                           GMainContext *context,
                           gboolean      have_lock)
 {
+  TRACE (GLIB_MAIN_SOURCE_DESTROY (g_source_get_name (source)));
+
   if (!have_lock)
     LOCK_CONTEXT (context);
   
@@ -3058,7 +3064,9 @@ g_main_dispatch (GMainContext *context)
           current->source = source;
           current->depth++;
 
+         TRACE( GLIB_MAIN_BEFORE_DISPATCH (g_source_get_name (source)));
           need_destroy = !(* dispatch) (source, callback, user_data);
+         TRACE( GLIB_MAIN_AFTER_DISPATCH (g_source_get_name (source)));
 
           current->source = prev_source;
           current->depth--;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]