gdb 调试php程序 ,debug 编译php

首先我们要安装debug版本的php

1 . 从github 下载php的源码,因为从github下载源码里面没有configure文件,所以需要执行以下命令

1
./buildconf

2.

1
2
3
4
5
 brew install bison  //如果安装过 bison 可以调过,php 用bison做语法分析

echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.zshrc

./configure --prefix=/usr/local/Cellar/php_debug --enable-debug

这个时候 可以用debug版本的php来 调试,非degbug版本的追踪不到gdb信息

eg:

1
2
3
4
5
6
7
8
9
10
11
12
gdb php  //执行完 会进入gdb,php就是刚才编译的debug版本

 
set args test.php  //在gdb 里面执行


b php_cli.c:660; //在php_cli.c文件660 行打断点


run  //运行

i locals //查看当前断点处的变量值

php72编译过程中遇到了一写错误:

make: *** No rule to make target `/data/php-src/ext/opcache/Optimizer/escape_analysis.c’, needed by `ext/opcache/Optimizer/escape_analysis.lo’.  Stop.   网上没有答案 于是 求助,鸟哥回答如下:

错2:

Undefined symbols for architecture x86_64:
“_libiconv”, referenced from:
_php_iconv_string in iconv.o
__php_iconv_strlen in iconv.o
__php_iconv_substr in iconv.o
__php_iconv_strpos in iconv.o
__php_iconv_mime_encode in iconv.o
__php_iconv_appendl in iconv.o
_php_iconv_stream_filter_append_bucket in iconv.o

“_libiconv_close”, referenced from:
_php_iconv_string in iconv.o
__php_iconv_strlen in iconv.o
__php_iconv_substr in iconv.o
__php_iconv_strpos in iconv.o
__php_iconv_mime_encode in iconv.o
__php_iconv_mime_decode in iconv.o
_php_iconv_stream_filter_dtor in iconv.o

“_libiconv_open”, referenced from:
_php_iconv_string in iconv.o
__php_iconv_strlen in iconv.o
__php_iconv_substr in iconv.o
__php_iconv_strpos in iconv.o
__php_iconv_mime_encode in iconv.o
__php_iconv_mime_decode in iconv.o
_php_iconv_stream_filter_ctor in iconv.o

ld: symbol(s) not found for architecture x86_64
这个错误,弄了一下午没查到原因,后来一想是不是头文件找不到,因为我这个mac电脑 看了下/usr/include 没有这个目录

于是执行

xcode-select –install

再make 就不报错了,就好了,就好了,就好了,想吐血~~~~~ mac系统升级后移除了头文件目录,需要命令行执行下这个安装

发表评论

电子邮件地址不会被公开。 必填项已用*标注