Next: , Previous: , Up: General Introduction  

Appendix B Debugging

For bugs unrelated to persistence, see the gawk documentation, e.g., GAWK: Effective AWK Programming, available at

If pm-gawk doesn’t behave as you expect, first consider whether you’re using the heap file that you intend; using the wrong heap file is a common mistake. Other fertile sources of bugs for newcomers are the fact that a BEGIN block is executed every time pm-gawk runs, which isn’t always what you really want, and the fact that built-in AWK variables such as NR are always reset to zero every time the interpreter runs. See the discussion of initialization surrounding the min/max/mean script in Examples.

If you suspect a persistence-related bug in pm-gawk, you can set an environment variable that will cause its persistent heap module, pma, to emit more verbose error messages; for details see the main gawk documentation.

Programmers: You can re-compile gawk with assertions enabled, which will trigger extensive integrity checks within pma. Ensure that pma.c is compiled without the -DNDEBUG flag when make builds gawk. Run the resulting executable on small inputs, because the integrity checks can be very slow. If assertions fail, that likely indicates bugs somewhere in pm-gawk. Report such bugs to me (Terence Kelly) and also following the procedures in the main gawk documentation. Specify what version of gawk you’re using, and try to provide a small and simple script that reliably reproduces the bug.