[Xfce4-commits] <xfce4-panel:master> Only inform user about gdb/valgrind in main.

Nick Schermer noreply at xfce.org
Tue Jan 4 22:10:05 CET 2011


Updating branch refs/heads/master
         to b6d6a0d34144906a8f77d7596eba28efb12bea43 (commit)
       from cad0a5c268ca9f6051ec0b33445e7f05b97f7ce8 (commit)

commit b6d6a0d34144906a8f77d7596eba28efb12bea43
Author: Nick Schermer <nick at xfce.org>
Date:   Tue Jan 4 21:47:21 2011 +0100

    Only inform user about gdb/valgrind in main.

 common/panel-debug.c |   88 +++++++++++++++++++++++++-------------------------
 common/panel-debug.h |   16 +++++----
 panel/main.c         |    3 ++
 3 files changed, 56 insertions(+), 51 deletions(-)

diff --git a/common/panel-debug.c b/common/panel-debug.c
index 205c305..e13bbb0 100644
--- a/common/panel-debug.c
+++ b/common/panel-debug.c
@@ -58,8 +58,6 @@ panel_debug_init (void)
 {
   static volatile gsize  inited__volatile = 0;
   const gchar           *value;
-  gchar                 *path;
-  const gchar           *proxy_application;
 
   if (g_once_init_enter (&inited__volatile))
     {
@@ -71,48 +69,6 @@ panel_debug_init (void)
 
           /* always enable (unfiltered) debugging messages */
           PANEL_SET_FLAG (panel_debug_flags, PANEL_DEBUG_YES);
-
-          if (PANEL_HAS_FLAG (panel_debug_flags, PANEL_DEBUG_GDB))
-            {
-              proxy_application = "gdb";
-
-              /* performs sanity checks on the released memory slices */
-              g_setenv ("G_SLICE", "debug-blocks", TRUE);
-
-              /* make sure we don't run gdb and valgrind at the same time */
-              PANEL_UNSET_FLAG (panel_debug_flags, PANEL_DEBUG_VALGRIND);
-            }
-          else if (PANEL_HAS_FLAG (panel_debug_flags, PANEL_DEBUG_VALGRIND))
-            {
-              proxy_application = "valgrind";
-
-              /* use g_malloc() and g_free() instead of slices */
-              g_setenv ("G_SLICE", "always-malloc", TRUE);
-              g_setenv ("G_DEBUG", "gc-friendly", TRUE);
-            }
-          else
-            {
-              proxy_application = NULL;
-            }
-
-          if (proxy_application != NULL)
-            {
-              path = g_find_program_in_path (proxy_application);
-              if (G_LIKELY (path != NULL))
-                {
-                  /* TODO: only print those messages in the main application */
-                  g_printerr (PACKAGE_NAME "(debug): running plugins with %s; "
-                              "log files stored in %s\n", path, g_get_tmp_dir ());
-                  g_free (path);
-                }
-              else
-                {
-                  PANEL_UNSET_FLAG (panel_debug_flags, PANEL_DEBUG_GDB | PANEL_DEBUG_VALGRIND);
-
-                  g_printerr (PACKAGE_NAME "(debug): %s not found in PATH\n",
-                              proxy_application);
-                }
-            }
         }
 
       g_once_init_leave (&inited__volatile, 1);
@@ -151,6 +107,50 @@ panel_debug_print (PanelDebugFlag  domain,
 
 
 
+void
+panel_debug_notify_proxy (void)
+{
+  gchar       *path;
+  const gchar *proxy_application;
+
+  if (G_UNLIKELY (PANEL_HAS_FLAG (panel_debug_flags, PANEL_DEBUG_GDB)))
+    proxy_application = "gdb";
+  else if (G_UNLIKELY (PANEL_HAS_FLAG (panel_debug_flags, PANEL_DEBUG_VALGRIND)))
+    proxy_application = "valgrind";
+  else
+    return;
+
+  path = g_find_program_in_path (proxy_application);
+  if (G_LIKELY (path != NULL))
+    {
+      g_printerr (PACKAGE_NAME "(debug): running plugins with %s; "
+                  "log files stored in %s\n", path, g_get_tmp_dir ());
+      g_free (path);
+
+      if (PANEL_HAS_FLAG (panel_debug_flags, PANEL_DEBUG_GDB))
+        {
+          /* performs sanity checks on the released memory slices */
+          g_setenv ("G_SLICE", "debug-blocks", TRUE);
+        }
+      else if (PANEL_HAS_FLAG (panel_debug_flags, PANEL_DEBUG_VALGRIND))
+        {
+          /* use g_malloc() and g_free() instead of slices */
+          g_setenv ("G_SLICE", "always-malloc", TRUE);
+          g_setenv ("G_DEBUG", "gc-friendly", TRUE);
+        }
+    }
+  else
+    {
+      /* make sure external plugins are not started in one of the proxies */
+      PANEL_UNSET_FLAG (panel_debug_flags, PANEL_DEBUG_GDB | PANEL_DEBUG_VALGRIND);
+
+      g_printerr (PACKAGE_NAME "(debug): %s not found in PATH\n",
+                  proxy_application);
+    }
+}
+
+
+
 gboolean
 panel_debug_has_domain (PanelDebugFlag domain)
 {
diff --git a/common/panel-debug.h b/common/panel-debug.h
index 4d93079..1d1507f 100644
--- a/common/panel-debug.h
+++ b/common/panel-debug.h
@@ -39,14 +39,16 @@ typedef enum
 }
 PanelDebugFlag;
 
-gboolean panel_debug_has_domain (PanelDebugFlag  domain);
+void     panel_debug_notify_proxy (void);
 
-void     panel_debug            (PanelDebugFlag  domain,
-                                 const gchar    *message,
-                                 ...) G_GNUC_PRINTF (2, 3);
+gboolean panel_debug_has_domain   (PanelDebugFlag  domain);
 
-void     panel_debug_filtered   (PanelDebugFlag  domain,
-                                 const gchar    *message,
-                                 ...) G_GNUC_PRINTF (2, 3);
+void     panel_debug              (PanelDebugFlag  domain,
+                                   const gchar    *message,
+                                   ...) G_GNUC_PRINTF (2, 3);
+
+void     panel_debug_filtered     (PanelDebugFlag  domain,
+                                   const gchar    *message,
+                                   ...) G_GNUC_PRINTF (2, 3);
 
 #endif /* !__PANEL_DEBUG_H__ */
diff --git a/panel/main.c b/panel/main.c
index 446decc..a23cf0b 100644
--- a/panel/main.c
+++ b/panel/main.c
@@ -183,6 +183,9 @@ main (gint argc, gchar **argv)
                glib_major_version, glib_minor_version, glib_micro_version,
                GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
 
+  /* inform the user about usage of gdb/valgrind */
+  panel_debug_notify_proxy ();
+
   /* set translation domain */
   xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
 



More information about the Xfce4-commits mailing list