diff --git a/ChangeLog b/ChangeLog index 2d40ace88c..a09a39b976 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-06-09 David Hampton + + * src/doc/valgrind.txt: + * src/doc/Makefile.am: + * src/gnome-utils/ui/gnc-main-window-ui.xml: + * src/gnome-utils/gnc-main-window.c: + * configure.in: Move the valgrind reference code from a compiled + file to a documentation file. The start/stop valgrind command + didn't work as well as I'd hoped. Fixes #344353. + 2006-06-07 David Hampton * src/business/business-gnome/business-gnome.scm: Restore the diff --git a/configure.in b/configure.in index 22e81494d4..2c6ffb2c2f 100644 --- a/configure.in +++ b/configure.in @@ -985,10 +985,6 @@ AC_SUBST(enable_latex_docs) BB_ENABLE_DOXYGEN -# check for callgrind -# ---------------------------------------------------------------------------- -AC_CHECK_HEADERS(valgrind/callgrind.h) - ### -------------------------------------------------------------------------- ### Libraries LIBS="$LIBS -lm" diff --git a/src/doc/Makefile.am b/src/doc/Makefile.am index 90a0b50004..f4072b4e60 100644 --- a/src/doc/Makefile.am +++ b/src/doc/Makefile.am @@ -26,6 +26,7 @@ EXTRA_DIST = \ netlogin.txt \ guid.txt \ qif.txt \ + valgrind.txt \ generic-druid-framework.txt \ user-prefs-howto.txt diff --git a/src/doc/valgrind.txt b/src/doc/valgrind.txt new file mode 100644 index 0000000000..118b196ccd --- /dev/null +++ b/src/doc/valgrind.txt @@ -0,0 +1,41 @@ +In order to debug with callgrind, you need to add a couple of code +fragments around the section of code you are profiling. This is +easiest if you can find the function that invokes the routine(s) you +want to profile, add the following code around the function call of +interest. + +Add the following to the start of the file: + + #include + +Add the following to the start of the calling function: + + static GTimeVal start, end; + +Add the following just before the function of interest: + + g_print("Start timing.\n"); + g_get_current_time(&start); + CALLGRIND_START_INSTRUMENTATION(); + CALLGRIND_TOGGLE_COLLECT(); + +Add the following just after the function of interest: + + CALLGRIND_TOGGLE_COLLECT(); + CALLGRIND_STOP_INSTRUMENTATION(); + g_get_current_time(&end); + if (start.tv_usec > end.tv_usec) { + end.tv_usec += 1000000; + end.tv_sec -= 1; + } + g_print("Callgrind enabled for %d.%6d seconds.\n", + (int)(end.tv_sec - start.tv_sec), + (int)(end.tv_usec - start.tv_usec)); + +You will need to recompile, and then run the 'gnucash-valgrind' +wrapper script instead of the normal 'gnucash' script. + +NOTE: Version 3.2 of valgrind has changed the above macros to no +longer take an argument. In order to compile with this version of +valgrind you will need to remove the trailing parentheses and +semicolon. diff --git a/src/gnome-utils/gnc-main-window.c b/src/gnome-utils/gnc-main-window.c index 3ab4d58484..2d46ffdc38 100644 --- a/src/gnome-utils/gnc-main-window.c +++ b/src/gnome-utils/gnc-main-window.c @@ -41,9 +41,6 @@ #include "gkeyfile.h" #endif #include "gtk-compat.h" -#ifdef HAVE_VALGRIND_CALLGRIND_H -#include -#endif #include "gnc-plugin.h" #include "gnc-plugin-manager.h" @@ -127,7 +124,6 @@ static void gnc_main_window_cmd_view_refresh (GtkAction *action, GncMainWindow * static void gnc_main_window_cmd_view_toolbar (GtkAction *action, GncMainWindow *window); static void gnc_main_window_cmd_view_summary (GtkAction *action, GncMainWindow *window); static void gnc_main_window_cmd_view_statusbar (GtkAction *action, GncMainWindow *window); -static void gnc_main_window_cmd_extensions_callgrind (GtkAction *action, GncMainWindow *window); static void gnc_main_window_cmd_actions_reset_warnings (GtkAction *action, GncMainWindow *window); static void gnc_main_window_cmd_actions_rename_page (GtkAction *action, GncMainWindow *window); static void gnc_main_window_cmd_window_new (GtkAction *action, GncMainWindow *window); @@ -314,9 +310,6 @@ static GtkToggleActionEntry toggle_actions [] = { "ViewStatusbarAction", NULL, N_("Stat_us Bar"), NULL, N_("Show/hide the status bar on this window"), G_CALLBACK (gnc_main_window_cmd_view_statusbar), TRUE }, - { "ExtensionsCallgrindAction", NULL, "Use Callgrind", NULL, - "Enable/disable the Valgrind/Callgrind profiling tool.", - G_CALLBACK (gnc_main_window_cmd_extensions_callgrind), FALSE }, }; /** The number of toggle actions provided by the main window. */ static guint n_toggle_actions = G_N_ELEMENTS (toggle_actions); @@ -375,9 +368,6 @@ static const gchar *initially_insensitive_actions[] = { static const gchar *always_hidden_actions[] = { "ViewSortByAction", "ViewFilterByAction", -#ifndef HAVE_VALGRIND_CALLGRIND_H - "ExtensionsCallgrindAction", -#endif NULL }; @@ -3078,32 +3068,6 @@ gnc_main_window_cmd_view_statusbar (GtkAction *action, GncMainWindow *window) } } -static void -gnc_main_window_cmd_extensions_callgrind (GtkAction *action, GncMainWindow *window) -{ -#ifdef HAVE_VALGRIND_CALLGRIND_H - static GTimeVal start, end; - - if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action))) { - g_print("Start timing.\n"); - g_get_current_time(&start); - CALLGRIND_START_INSTRUMENTATION(); - CALLGRIND_TOGGLE_COLLECT(); - } else { - CALLGRIND_TOGGLE_COLLECT(); - CALLGRIND_STOP_INSTRUMENTATION(); - g_get_current_time(&end); - if (start.tv_usec > end.tv_usec) { - end.tv_usec += 1000000; - end.tv_sec -= 1; - } - g_print("Callgrind enabled for %d.%6d seconds.\n", - (int)(end.tv_sec - start.tv_sec), - (int)(end.tv_usec - start.tv_usec)); - } -#endif -} - static void gnc_main_window_cmd_window_new (GtkAction *action, GncMainWindow *window) { diff --git a/src/gnome-utils/ui/gnc-main-window-ui.xml b/src/gnome-utils/ui/gnc-main-window-ui.xml index 293810fd84..5e4b315013 100644 --- a/src/gnome-utils/ui/gnc-main-window-ui.xml +++ b/src/gnome-utils/ui/gnc-main-window-ui.xml @@ -107,7 +107,6 @@ -