源码安装PHP时需要构建调试版本
./configure --prefix=/usr/local/php5 --enable-debug --enable-maintainer-zts --enable-cgi --enable-cli --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/etc
cp php.ini-development /etc/php.ini
配置PHP扩展时
./ext_skel --extname=mydebug
打开config.m4
去掉以下几行的 dnl
PHP_ARG_ENABLE(heiyeluren, whether to enable heiyeluren support,
[ --enable-heiyeluren Enable heiyeluren support])
并在末尾添添加
if test -z "$PHP_DEBUG"; then
AC_ARG_ENABLE(debug,
[ --enable-debug compile with debugging symbols],[
PHP_DEBUG=$enableval
],[ PHP_DEBUG=no
])
fi
然后执行以下构建命令
phpize
./configure --with-php-config=/usr/local/php5/bin/php-config --enable-debug
make
make install
由于调试时需要设置断点,可以用nm查看so文件的符号表
然后用gdb调试
gdb php
> break zif_confirm_mydebug_compiled
> run index.php
就可以让程序停到设定的函数