diff --git a/HACKING b/HACKING index ccbea4bef5..52bae0a1ac 100644 --- a/HACKING +++ b/HACKING @@ -104,6 +104,50 @@ This file needs to be cleaned up in two ways: 2/ There are a bunch of suppressions which need to not be suppressions, but instead just not be generated by valgrind. +Using Callgrind with GnuCash +---------------------------- +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. + Look up exported and imported symbols ------------------------------------- diff --git a/libgnucash/doc/CMakeLists.txt b/libgnucash/doc/CMakeLists.txt index 92fd714ff0..f02acbcf33 100644 --- a/libgnucash/doc/CMakeLists.txt +++ b/libgnucash/doc/CMakeLists.txt @@ -1,5 +1,4 @@ set(doc_FILES - callgrind.txt constderv.html doxygen.cfg.in doxygen_main_page.c diff --git a/libgnucash/doc/callgrind.txt b/libgnucash/doc/callgrind.txt deleted file mode 100644 index 118b196ccd..0000000000 --- a/libgnucash/doc/callgrind.txt +++ /dev/null @@ -1,41 +0,0 @@ -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.