Browse Source

Only inform user about gdb/valgrind in main.

upstream/xfce4-panel-4.10.1
Nick Schermer 12 years ago
parent
commit
b6d6a0d341
  1. 88
      common/panel-debug.c
  2. 16
      common/panel-debug.h
  3. 3
      panel/main.c

88
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)
{

16
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__ */

3
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");

Loading…
Cancel
Save