@@ -12,6 +12,61 @@ kernel among the developers.
1212
1313<Chapter Label =" Chap-Lib" >
1414<Heading >Maintaining the &GAP; kernel and library</Heading >
15+
16+ <Section Label =" Sect-debugging" >
17+ <Heading >Debugging the GAP Kernel</Heading >
18+
19+ The GAP kernel supports a variety of options which enabled when running <C >configure</C >,
20+ to help writing and debugging GAP kernel code.
21+ <P />
22+
23+ The first option, <C >--enable-debug</C >, is well supported can can be used
24+ whenever the GAP kernel, or kernel modules, are being developed (although
25+ developers should still check their code works without it).
26+ <P />
27+ <C >--enable-debug</C > enables assertions throughout the kernel. These
28+ assertions are implemented using the <C >GAP_ASSERT</C > macro. These
29+ assertions are disabled when GAP is compiled without <C >--enable-debug</C >.
30+ When <C >--enable-debug</C > is enabled, <C >KernelDebug</C > will be shown in
31+ the Configuration line when GAP is started.
32+ <P />
33+
34+ The next two options are more experimental, and are not designed to be constantly
35+ enabled. They are particularly designed to track down bugs relating to memory
36+ corruption relating to GASMAN (GAP's memory manager). They cannot both be enabled
37+ at the same time.
38+ <P />
39+ <C >--enable-memory-checking</C > makes GAP check for C pointers to the content of Bags
40+ being used after a new Bag has been created or a Bag is resized. GASMAN
41+ moves Bags during garbage collection, which can happen whenever a new Bag is created
42+ or a Bag is resized. However, as it is very unlikely that any single allocation
43+ will cause a garbage collection, these bugs trigger very rarely. Also the problems
44+ caused by these bugs are, if the C pointer is written to, a random other Bag,
45+ somewhere in GAP, is changed.
46+ <P />
47+
48+ After configuring, the memory checking must still be turned on. This can be done
49+ either by passing <C >--</C > to GAP's command line, or calling <C >GASMAN_MEM_CHECK(1)</C >.
50+ Note that enabling these tests makes GAP VERY, VERY slow. It can (depending on the
51+ machine and operating system) take GAP over a day to start, and load all standard
52+ packages. The recommending way to use this option is to start GAP, and then load
53+ small test files to try to isolate the problem. <C >MemCheck</C > will be shown in
54+ the Configuration line when GAP is started.
55+ <P />
56+
57+ Known bugs: GAP will crash if IO_fork is called while memory checking is enabled.
58+ <P />
59+
60+ <C >--enable-valgrind</C > makes changes to GASMAN so it is compatible with the
61+ valgrind memory checking program. Without this, valgrind will report many
62+ incorrect warnings relating to GASMAN, and no useful warnings.
63+ <P />
64+
65+ At present, this <C >--enable-valgrind</C > only checks for invalid writes to the
66+ last bag which was created. Also, this option does not do anything unless GAP
67+ is run through Valgrind (for example by running <C >valgrind ./gap</C >.
68+ </Section >
69+
1570<Index >modules</Index >
1671
1772Modules, PROPOSALs, ...
0 commit comments