apache2.xのモジュール作成時のgdb debug

1. apacheをdebugでコンパイル
CFLAGS="-O2 -g" ./configure --prefix=$HOME$APACHE$

2. httpd.confのListenを一般ユーザで起動可能に変更
Listen 80 -> Listen 8080などに

3. gdb起動
gdb httpd
(中略)
(gdb) b helloworld_handler   // breakpointを設定
Function "helloworld_handler" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y // moduleがloadされてないからシンボルは見えないが設定しておく
Breakpoint 1 (helloworld_handler) pending.
(gdb) run -X -d ~/apache // apacheのdirectoryを指定して起動
Starting program: /home/yuki/apache/bin/httpd -X -d ~/apache
[Thread debugging using libthread_db enabled]
[New Thread 0xb7d506b0 (LWP 28569)]
warning: Temporarily disabling breakpoints for unloaded shared library "/home/yuki/apache  /modules/mod_helloworld.so"
[Switching to Thread 0xb7d506b0 (LWP 28569)]


スレッド番号などは毎回異なるので留意すること。
Thread待ちになったら、ブラウザなどからlocalhost:8080...などにアクセスしてデバッグしていく

最終更新:2009年01月08日 19:31