Catacomb Debugging Howto
This is a brief explanation about how to debug the Catacomb WebDAV server module for apache. Catacomb is a module for Apache and repository interface for mod_dav http://www.webdav.org/mod_dav. This document is mainly for developers or someone who encounters an error and needs to contact the developers with detailed support informations.
Debugging using "printf()"
The most simple way to debug is using the printf() function to display the status of variables at the apache logfile. In catacomb it is also possible to use the DBGx() functions instead of printf(), where “x” stands for the amount of arguments.
But there are reasons why this may not be the best way of doing things:
- In some cases you really need a lot of printf’s. Your code looks like a mess and in often called, or recursive functions you will get maybe thousands of lines of information. Finding the error in all these lines is work as well!
- With a debugger you can debug a program that allready crashes.
- With a debugger you can hold a program at runtime
- With a debugger you even can chance the value of a variable at runtime
You see, a debugger has many advantages, but this isn't to say that printf() has no use in debugging catacomb. In fact, there are cases in which printf() could be very helpful, but in most cases a debugger will help you hunting a bug down faster and easier.
Debugging using GDB
One debugger you could use to debug catacomb is GDB. The GNU Debugger (gdb) is the most popular open source debugger in use and is a command line debugger.
Steps to Debug Catacomb with GDB
Stop apache: apachectl stop
Run httpd with gdb: cd /usr/local/apache2/bin; gdb httpd
Run apache in gdb: gdb> run –X
- Connect the apache server using a WebDAV client (like cadaver)
- If there is seg fault gdb will report something
Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 1024 (LWP 11626)] 0x00000000 in ?? () (gdb) bt #0 0x00000000 in ?? () #1 0x0f6b9690 in _nss_db_getspnam_r () from /lib/libnss_db.so.2 #2 0x0f6b9794 in _nss_db_getspnam_r () from /lib/libnss_db.so.2 #3 0x0f6b8afc in _nss_db_endservent () from /lib/libnss_db.so.2 #4 0x0f6b8eb0 in _nss_db_getservbyname_r () from /lib/libnss_db.so.2 #5 0x0fb4ddb4 in getservbyname_r () from /lib/libc.so.6 #6 0x0fb4dbfc in getservbyname () from /lib/libc.so.6 #7 0x0f8e5438 in simple_command () from /usr/lib/libmysqlclient.so.10 #8 0x0f8e7638 in mysql_init () from /usr/lib/libmysqlclient.so.10 #9 0x0f94111c in dbms_opendb (d=0xf8e5438) at dbms.c:135 #10 0x0f93cebc in dav_repos_child_init (p=0x10157038, s=0x7ffff790) at mod_dav_repos.c:273 #11 0x10065cf4 in ap_run_child_init (pchild=0x10157038, s=0x10108968) at config.c:190 #12 0x10063f28 in child_main (child_num_arg=269906936) at prefork.c:582 #13 0x100642f8 in make_child (s=0x10108968, slot=0) at prefork.c:736 #14 0x10064450 in startup_children (number_to_start=5) at prefork.c:808 #15 0x10064924 in ap_mpm_run (_pconf=0x5, plog=0xf6c9a24, s=0x10108968) at prefork.c:1024 #16 0x1006bb94 in main (argc=4, argv=0x7ffff9c4) at main.c:645 #17 0x0fa7cc50 in __libc_start_main () from /lib/libc.so.6 (gdb)
Using Eclipse to Debug Catacomb
A more comfortable way to debug catacomb is using eclipse as a graphical front-end to the gdb debugger. Is you using eclipse as developing IDE anyway, you don’t even have to leave eclipse to start the apache and get into a graphical debugging view!
Steps to Debug Catacomb with Eclipse
To be continued...