Browse Source

Prepare for filtered debugging.

upstream/xfce4-panel-4.10.1
Nick Schermer 12 years ago
parent
commit
df0deff57e
  1. 74
      common/panel-debug.c
  2. 31
      common/panel-debug.h
  3. 10
      panel/main.c
  4. 4
      panel/panel-application.c
  5. 2
      panel/panel-base-window.c
  6. 2
      panel/panel-plugin-external-wrapper.c
  7. 20
      panel/panel-plugin-external.c
  8. 18
      panel/panel-window.c
  9. 6
      plugins/applicationsmenu/applicationsmenu.c
  10. 2
      plugins/tasklist/tasklist-widget.c

74
common/panel-debug.c

@ -1,5 +1,5 @@
/*
* Copyright (C) 2010 Nick Schermer <nick@xfce.org>
* Copyright (C) 2010-2011 Nick Schermer <nick@xfce.org>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
@ -37,28 +37,31 @@ PanelDebugFlag panel_debug_flags = 0;
/* additional debug levels */
static const GDebugKey panel_debug_keys[] =
{
{ "main", PANEL_DEBUG_MAIN },
{ "positioning", PANEL_DEBUG_POSITIONING },
{ "display-layout", PANEL_DEBUG_DISPLAY_LAYOUT },
{ "struts", PANEL_DEBUG_STRUTS },
{ "application", PANEL_DEBUG_APPLICATION },
{ "external", PANEL_DEBUG_EXTERNAL },
{ "external46", PANEL_DEBUG_EXTERNAL46 },
{ "tasklist", PANEL_DEBUG_TASKLIST },
{ "base-window", PANEL_DEBUG_BASE_WINDOW },
{ "applicationmenu", PANEL_DEBUG_APPLICATIONMENU },
{ "gdb", PANEL_DEBUG_GDB },
{ "valgrind", PANEL_DEBUG_VALGRIND }
};
void
panel_debug (const gchar *domain,
const gchar *message,
...)
static PanelDebugFlag
panel_debug_init (void)
{
static volatile gsize level__volatile = 0;
const gchar *value;
gchar *string, *path;
va_list args;
const gchar *proxy_application;
panel_return_if_fail (domain != NULL);
panel_return_if_fail (message != NULL);
static volatile gsize inited__volatile = 0;
const gchar *value;
gchar *path;
const gchar *proxy_application;
/* initialize the debugging domains */
if (g_once_init_enter (&level__volatile))
if (g_once_init_enter (&inited__volatile))
{
value = g_getenv ("PANEL_DEBUG");
if (value != NULL && *value != '\0')
@ -66,7 +69,7 @@ panel_debug (const gchar *domain,
panel_debug_flags = g_parse_debug_string (value, panel_debug_keys,
G_N_ELEMENTS (panel_debug_keys));
/* always enable debug logging */
/* always enable (unfiltered) debugging messages */
PANEL_SET_FLAG (panel_debug_flags, PANEL_DEBUG_YES);
if (PANEL_HAS_FLAG (panel_debug_flags, PANEL_DEBUG_GDB))
@ -75,6 +78,9 @@ panel_debug (const gchar *domain,
/* 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))
{
@ -109,17 +115,47 @@ panel_debug (const gchar *domain,
}
}
g_once_init_leave (&level__volatile, 1);
g_once_init_leave (&inited__volatile, 1);
}
return panel_debug_flags;
}
void
panel_debug (PanelDebugFlag domain,
const gchar *message,
...)
{
gchar *string;
va_list args;
const gchar *domain_name = NULL;
guint i;
panel_return_if_fail (domain > 0);
panel_return_if_fail (message != NULL);
/* leave when debug is disabled */
if (panel_debug_flags == 0)
if (panel_debug_init () == 0)
return;
/* lookup domain name */
for (i = 0; i < G_N_ELEMENTS (panel_debug_keys); i++)
{
if (panel_debug_keys[i].value == domain)
{
domain_name = panel_debug_keys[i].key;
break;
}
}
panel_assert (domain_name != NULL);
va_start (args, message);
string = g_strdup_vprintf (message, args);
va_end (args);
g_printerr (PACKAGE_NAME "(%s): %s\n", domain, string);
g_printerr (PACKAGE_NAME "(%s): %s\n", domain_name, string);
g_free (string);
}

31
common/panel-debug.h

@ -19,31 +19,30 @@
#ifndef __PANEL_DEBUG_H__
#define __PANEL_DEBUG_H__
#define PANEL_DEBUG_DOMAIN_MAIN "main"
#define PANEL_DEBUG_DOMAIN_POSITIONING "positioning"
#define PANEL_DEBUG_DOMAIN_DISPLAY_LAYOUT "display-layout"
#define PANEL_DEBUG_DOMAIN_STRUTS "struts"
#define PANEL_DEBUG_DOMAIN_APPLICATION "application"
#define PANEL_DEBUG_DOMAIN_EXTERNAL "external"
#define PANEL_DEBUG_DOMAIN_EXTERNAL46 "external46"
#define PANEL_DEBUG_DOMAIN_TASKLIST "tasklist"
#define PANEL_DEBUG_DOMAIN_BASE_WINDOW "base-window"
#define PANEL_DEBUG_DOMAIN_APPLICATIONMENU "applicationmenu"
#define PANEL_DEBUG_BOOL(bool) ((bool) ? "true" : "false")
typedef enum
{
PANEL_DEBUG_YES = 1 << 0, /* always enabled if PANEL_DEBUG is not %NULL */
PANEL_DEBUG_GDB = 1 << 1, /* run plugin in gdb */
PANEL_DEBUG_VALGRIND = 1 << 2 /* run plugin in valgrind */
PANEL_DEBUG_YES = 1 << 0, /* always enabled if PANEL_DEBUG is not %NULL */
PANEL_DEBUG_MAIN = 1 << 1,
PANEL_DEBUG_POSITIONING = 1 << 2,
PANEL_DEBUG_DISPLAY_LAYOUT = 1 << 3,
PANEL_DEBUG_STRUTS = 1 << 4,
PANEL_DEBUG_APPLICATION = 1 << 5,
PANEL_DEBUG_EXTERNAL = 1 << 6,
PANEL_DEBUG_EXTERNAL46 = 1 << 7,
PANEL_DEBUG_TASKLIST = 1 << 8,
PANEL_DEBUG_BASE_WINDOW = 1 << 9,
PANEL_DEBUG_APPLICATIONMENU = 1 << 10,
PANEL_DEBUG_GDB = 1 << 11, /* run plugin in gdb */
PANEL_DEBUG_VALGRIND = 1 << 12 /* run plugin in valgrind */
}
PanelDebugFlag;
extern PanelDebugFlag panel_debug_flags;
void panel_debug (const gchar *domain,
const gchar *message,
void panel_debug (PanelDebugFlag domain,
const gchar *message,
...) G_GNUC_PRINTF (2, 3);
#endif /* !__PANEL_DEBUG_H__ */

10
panel/main.c

@ -121,7 +121,7 @@ panel_callback_handler (const gchar *name,
static void
panel_signal_handler (gint signum)
{
panel_debug (PANEL_DEBUG_DOMAIN_MAIN,
panel_debug (PANEL_DEBUG_MAIN,
"received signal %s <%d>, %s panel",
g_strsignal (signum), signum,
signum == SIGUSR1 ? "restarting" : "quiting");
@ -137,7 +137,7 @@ panel_sm_client_quit (XfceSMClient *sm_client)
panel_return_if_fail (XFCE_IS_SM_CLIENT (sm_client));
panel_return_if_fail (!panel_dbus_service_get_restart ());
panel_debug (PANEL_DEBUG_DOMAIN_MAIN,
panel_debug (PANEL_DEBUG_MAIN,
"terminate panel for session manager");
gtk_main_quit ();
@ -152,7 +152,7 @@ panel_sm_client_save_state (XfceSMClient *sm_client,
panel_return_if_fail (XFCE_IS_SM_CLIENT (sm_client));
panel_return_if_fail (PANEL_IS_APPLICATION (application));
panel_debug (PANEL_DEBUG_DOMAIN_MAIN,
panel_debug (PANEL_DEBUG_MAIN,
"save configuration for session manager");
panel_application_save (application, TRUE);
@ -175,7 +175,7 @@ main (gint argc, gchar **argv)
const gchar *error_msg;
XfceSMClient *sm_client;
panel_debug (PANEL_DEBUG_DOMAIN_MAIN,
panel_debug (PANEL_DEBUG_MAIN,
"version %s on gtk+ %d.%d.%d (%d.%d.%d), glib %d.%d.%d (%d.%d.%d)",
LIBXFCE4PANEL_VERSION,
gtk_major_version, gtk_minor_version, gtk_micro_version,
@ -363,7 +363,7 @@ dbus_return:
"automatically started the next time you login."),
_("No running instance of %s was found"), G_LOG_DOMAIN))
{
panel_debug (PANEL_DEBUG_DOMAIN_MAIN, "user confirmed to start the panel");
panel_debug (PANEL_DEBUG_MAIN, "user confirmed to start the panel");
goto launch_panel;
}
else

4
panel/panel-application.c

@ -244,7 +244,7 @@ panel_application_finalize (GObject *object)
g_object_unref (G_OBJECT (application->factory));
/* this is a good reference if all the objects are released */
panel_debug (PANEL_DEBUG_DOMAIN_APPLICATION, "finalized");
panel_debug (PANEL_DEBUG_APPLICATION, "finalized");
(*G_OBJECT_CLASS (panel_application_parent_class)->finalize) (object);
}
@ -1112,7 +1112,7 @@ panel_application_save (PanelApplication *application,
if (panel_window_get_locked (li->data))
continue;
panel_debug (PANEL_DEBUG_DOMAIN_APPLICATION,
panel_debug (PANEL_DEBUG_APPLICATION,
"saving /panels/panel-%u, save-plugins=%s",
i, PANEL_DEBUG_BOOL (save_plugin_providers));

2
panel/panel-base-window.c

@ -670,7 +670,7 @@ panel_base_window_composited_changed (GtkWidget *widget)
panel_return_if_fail (GDK_IS_COLORMAP (colormap));
colormap_changed = gtk_widget_get_colormap (widget) != colormap;
panel_debug (PANEL_DEBUG_DOMAIN_BASE_WINDOW,
panel_debug (PANEL_DEBUG_BASE_WINDOW,
"set new colormap; composited=%s, rgba=%s, visible=%s",
PANEL_DEBUG_BOOL (gtk_widget_is_composited (widget)),
PANEL_DEBUG_BOOL (colormap_rgba),

2
panel/panel-plugin-external-wrapper.c

@ -185,7 +185,7 @@ panel_plugin_external_wrapper_constructor (GType type,
panel_return_val_if_fail (PANEL_PLUGIN_EXTERNAL (object)->unique_id != -1, NULL);
path = g_strdup_printf (PANEL_DBUS_WRAPPER_PATH, PANEL_PLUGIN_EXTERNAL (object)->unique_id);
dbus_g_connection_register_g_object (connection, path, object);
panel_debug (PANEL_DEBUG_DOMAIN_EXTERNAL, "register dbus path %s", path);
panel_debug (PANEL_DEBUG_EXTERNAL, "register dbus path %s", path);
g_free (path);
dbus_g_connection_unref (connection);

20
panel/panel-plugin-external.c

@ -358,7 +358,7 @@ panel_plugin_external_unrealize (GtkWidget *widget)
kill (external->priv->pid, SIGTERM);
}
panel_debug (PANEL_DEBUG_DOMAIN_EXTERNAL,
panel_debug (PANEL_DEBUG_EXTERNAL,
"%s-%d: plugin unrealized; quiting child",
panel_module_get_name (external->module),
external->unique_id);
@ -375,7 +375,7 @@ panel_plugin_external_plug_added (GtkSocket *socket)
external->priv->embedded = TRUE;
panel_debug (PANEL_DEBUG_DOMAIN_EXTERNAL,
panel_debug (PANEL_DEBUG_EXTERNAL,
"%s-%d: child is embedded; %d properties in queue",
panel_module_get_name (external->module),
external->unique_id,
@ -394,7 +394,7 @@ panel_plugin_external_plug_removed (GtkSocket *socket)
external->priv->embedded = FALSE;
panel_debug (PANEL_DEBUG_DOMAIN_EXTERNAL,
panel_debug (PANEL_DEBUG_EXTERNAL,
"%s-%d: child is unembedded",
panel_module_get_name (external->module),
external->unique_id);
@ -510,6 +510,8 @@ panel_plugin_external_child_spawn (PanelPluginExternal *external)
cmd_line = NULL;
program = NULL;
/* note that if the program was not found in PATH, we already
* warned for it in panel_debug_init, so no need to do that again */
if (PANEL_HAS_FLAG (panel_debug_flags, PANEL_DEBUG_GDB))
{
program = g_find_program_in_path ("gdb");
@ -560,7 +562,7 @@ panel_plugin_external_child_spawn (PanelPluginExternal *external)
}
else
{
panel_debug (PANEL_DEBUG_DOMAIN_EXTERNAL,
panel_debug (PANEL_DEBUG_EXTERNAL,
"%s-%d: Failed to run the plugin in %s: %s",
panel_module_get_name (external->module),
external->unique_id, program,
@ -580,7 +582,7 @@ panel_plugin_external_child_spawn (PanelPluginExternal *external)
G_SPAWN_DO_NOT_REAP_CHILD, NULL,
NULL, &pid, &error);
panel_debug (PANEL_DEBUG_DOMAIN_EXTERNAL,
panel_debug (PANEL_DEBUG_EXTERNAL,
"%s-%d: child spawned; pid=%d, argc=%d",
panel_module_get_name (external->module),
external->unique_id, pid, g_strv_length (argv));
@ -619,7 +621,7 @@ panel_plugin_external_child_respawn (gpointer user_data)
/* delay startup if the old child is still embedded */
if (external->priv->embedded)
{
panel_debug (PANEL_DEBUG_DOMAIN_EXTERNAL,
panel_debug (PANEL_DEBUG_EXTERNAL,
"%s-%d: still a child embedded, respawn delayed",
panel_module_get_name (external->module), external->unique_id);
@ -661,7 +663,7 @@ panel_plugin_external_child_watch (GPid pid,
external->priv->pid = 0;
panel_debug (PANEL_DEBUG_DOMAIN_EXTERNAL,
panel_debug (PANEL_DEBUG_EXTERNAL,
"%s-%d: child exited with status %d",
panel_module_get_name (external->module),
external->unique_id, status);
@ -716,7 +718,7 @@ panel_plugin_external_child_watch (GPid pid,
&& external->priv->spawn_timeout_id == 0
&& (auto_restart || panel_plugin_external_child_ask_restart (external)))
{
panel_debug (PANEL_DEBUG_DOMAIN_EXTERNAL,
panel_debug (PANEL_DEBUG_EXTERNAL,
"%s-%d: scheduled a respawn of the child",
panel_module_get_name (external->module), external->unique_id);
@ -1038,7 +1040,7 @@ panel_plugin_external_restart (PanelPluginExternal *external)
if (external->priv->pid != 0)
{
panel_debug (PANEL_DEBUG_DOMAIN_EXTERNAL,
panel_debug (PANEL_DEBUG_EXTERNAL,
"%s-%d: child asked to restart; pid=%d",
panel_module_get_name (external->module),
external->unique_id, external->priv->pid);

18
panel/panel-window.c

@ -1520,11 +1520,11 @@ panel_window_screen_struts_set (PanelWindow *window)
else if (struts[STRUT_BOTTOM] != 0)
n = STRUT_BOTTOM;
else
panel_debug (PANEL_DEBUG_DOMAIN_STRUTS, "unset");
panel_debug (PANEL_DEBUG_STRUTS, "unset");
if (n != -1)
{
panel_debug (PANEL_DEBUG_DOMAIN_STRUTS,
panel_debug (PANEL_DEBUG_STRUTS,
"%s=%ld, start_%s=%ld, end_%s=%ld",
strut_border[n], struts[n],
strut_xy[n], struts[4 + n * 2],
@ -1728,7 +1728,7 @@ panel_window_display_layout_debug (GtkWidget *widget)
g_string_append (str, ", ");
}
panel_debug (PANEL_DEBUG_DOMAIN_DISPLAY_LAYOUT,
panel_debug (PANEL_DEBUG_DISPLAY_LAYOUT,
"display %s: %s",
gdk_display_get_name (display), str->str);
@ -1774,7 +1774,7 @@ panel_window_screen_layout_changed (GdkScreen *screen,
n_monitors = gdk_screen_get_n_monitors (screen);
panel_return_if_fail (n_monitors > 0);
panel_debug (PANEL_DEBUG_DOMAIN_POSITIONING,
panel_debug (PANEL_DEBUG_POSITIONING,
"monitors=%d, output-name=%s, span-monitors=%s, base=%d,%d",
n_monitors, window->output_name,
PANEL_DEBUG_BOOL (window->span_monitors),
@ -1802,7 +1802,7 @@ panel_window_screen_layout_changed (GdkScreen *screen,
display = gdk_screen_get_display (screen);
if (gdk_display_get_n_screens (display) - 1 < screen_num)
{
panel_debug (PANEL_DEBUG_DOMAIN_POSITIONING,
panel_debug (PANEL_DEBUG_POSITIONING,
"screen-%d not found, hiding panel", screen_num);
/* out of range, hide the window */
@ -1812,7 +1812,7 @@ panel_window_screen_layout_changed (GdkScreen *screen,
}
else
{
panel_debug (PANEL_DEBUG_DOMAIN_POSITIONING,
panel_debug (PANEL_DEBUG_POSITIONING,
"moving panel from screen %d to %d",
gdk_screen_get_number (screen),
screen_num);
@ -1889,7 +1889,7 @@ panel_window_screen_layout_changed (GdkScreen *screen,
if (G_UNLIKELY (monitor_num == -1))
{
panel_debug (PANEL_DEBUG_DOMAIN_POSITIONING,
panel_debug (PANEL_DEBUG_POSITIONING,
"output/monitor %s not found, hiding window",
window->output_name);
@ -1943,13 +1943,13 @@ panel_window_screen_layout_changed (GdkScreen *screen,
}
}
panel_debug (PANEL_DEBUG_DOMAIN_POSITIONING,
panel_debug (PANEL_DEBUG_POSITIONING,
"struts edge: %d", window->struts_edge);
}
/* set the new working area of the panel */
window->area = a;
panel_debug (PANEL_DEBUG_DOMAIN_POSITIONING,
panel_debug (PANEL_DEBUG_POSITIONING,
"working-area: x=%d, y=%d, w=%d, h=%d",
a.x, a.y, a.width, a.height);

6
plugins/applicationsmenu/applicationsmenu.c

@ -211,7 +211,7 @@ applications_menu_plugin_init (ApplicationsMenuPlugin *plugin)
plugin->show_button_title = TRUE;
plugin->custom_menu = FALSE;
panel_debug (PANEL_DEBUG_DOMAIN_APPLICATIONMENU,
panel_debug (PANEL_DEBUG_APPLICATIONMENU,
"XDG_MENU_PREFIX is set to \"%s\"",
g_getenv ("XDG_MENU_PREFIX"));
@ -816,7 +816,7 @@ applications_menu_plugin_menu_reload (ApplicationsMenuPlugin *plugin)
if (plugin->menu != NULL)
{
panel_debug (PANEL_DEBUG_DOMAIN_APPLICATIONMENU,
panel_debug (PANEL_DEBUG_APPLICATIONMENU,
"destroy menu for reload");
/* if the menu is opened, do not destroy it under the users'
@ -1024,7 +1024,7 @@ applications_menu_plugin_menu (GtkWidget *button,
filename = g_file_get_parse_name (file);
g_object_unref (G_OBJECT (file));
panel_debug (PANEL_DEBUG_DOMAIN_APPLICATIONMENU,
panel_debug (PANEL_DEBUG_APPLICATIONMENU,
"loading from %s", filename);
g_free (filename);
}

2
plugins/tasklist/tasklist-widget.c

@ -899,7 +899,7 @@ xfce_tasklist_size_layout (XfceTasklist *tasklist,
* overflow menu */
if (n_buttons > n_buttons_target)
{
panel_debug (PANEL_DEBUG_DOMAIN_TASKLIST,
panel_debug (PANEL_DEBUG_TASKLIST,
"Putting %d windows in overflow menu",
n_buttons - n_buttons_target);

Loading…
Cancel
Save