Move valgrind and callgrind information to our wiki

This commit is contained in:
Geert Janssens 2024-05-23 15:43:38 +02:00
parent e8e179fd8f
commit 6f128d2947

70
HACKING
View File

@ -81,72 +81,10 @@ crashes. I haven't investigated whether this is because I should first have
linked gnucash with -lefence or because a real problem in GnuCash code.
Using Valgrind with GnuCash
---------------------------
-- run ${prefix}/bin/gnucash-valgrind
However, I did not find valgrind to be useful. It reported a bunch of
guile bugs, some g_hash_table bugs, and then the program exited prematurely
for no apparent reason. :-(
For the moment, gnucash-valgrind uses the suppressions in
src/debug/valgrind/valgrind-*.supp
For valgrind-gnucash.supp, this comment was made (but is perhaps outdated
by now ?):
This file needs to be cleaned up in two ways:
1/ There are a bunch of duplicate suppressions in the file.
* The suppressions in place were auto-generated by valgrind itself
[--gen-suppressions=yes], and it makes no effort to output the
suppression only once.
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 <valgrind/callgrind.h>
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.
Using Valgrind/Callgrind with GnuCash
-------------------------------------
This section has been moved to
https://wiki.gnucash.org/wiki/Coder_Tools
Look up exported and imported symbols