How to debug Apache module

I recently wrote an Apache module. It was interesting to work with the memory pool paradigm, but I obviously am not doing anything right. I have a segfault and I can not find it. My current debugging loop includes ap_rprintfs and a make script that rebuilds and restarts Apache.

What tools are available to work in this type of environment?

+3
source share
2 answers

You must use the GNU Debugger (gdb). Launch Apache with the command gdb bin/httpdand r -Xinside gdb. When segfault happens, you can see where this happened with the command bt.

+5
source

, mod_deflate Apache, ddd ( gdb) . :


, Apache 2.2.16. , , - (mod_deflate.c), zlib, . zlib deblate , .

  • Apache. , Apache . Apache.

$EXTRA_CFLAGS = "- g" . /configure --prefix =/ap --with-included-apr --enable-mods-shared = all

$make

$make install

: EXTRA_CFLAGS = "- g" . --prefix =/ap /ap. --with-included-apr APR APR-util ( , ). --enable-mods-shared = all , . , Apache.

  1. Apache /ap/config/httpd.conf.

, LoadModule deflate_module/mod_deflate.so( - ). AddOutputFilterByType DEFLATE text/html text/plain text/xml ( - ).

  1. zlib ( ).

$CFLAGS = "- g" . /configure --prefix = bin

Makefile -03, .

$make test

$make install

: zlib . EXTRA_CFLAGS = -g . --prefix =/ap bin.

  1. mod_deflate.

$/ap/bin/apxs -I/mydir/zlib/bin/include/-L/mydir/zlib/bin/lib/-c mod_deflate.c -lahaz -g

$cp.libs/mod_deflate.so

$/ap/modules/mod_deflate.so

$/ap/bin/apachectl -k stop

$/ap/bin/apachectl -k start

: -g .

$ddd/ap/bin/httpd

(gdb) r -X

ctrl-c, gdb

- > mod_deflate.c, aha363_zlib.c

gdb (.. (gdb) b aha363_zlib.c)

: Apache - Apache pg 328 ".. -X, Apache, forking children, ... [Apache] . , . , - . Ctrl-c, .

, , Apache .

+1

Source: https://habr.com/ru/post/1726600/


All Articles