您的位置:首页 > 编程语言 > PHP开发

php源码分析 (第一章)

2011-11-13 23:09 441 查看
环境

lsb_release -a

LSB Version: :core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-ia32:printing-4.0-noarch

Distributor ID: CentOS

Description: CentOS release 5.6 (Final)

Release: 5.6

Codename: Final

php: 5.2

gdb: GNU gdb (GDB) Red Hat Enterprise Linux (7.0.1-37.el5_7.1)

下载php源码编译环境

svn co http://svn.php.net/repository/php/php-src/branches/PHP_5_2 php-src-5.2

./buildconf

./configure --disable-all

make

开始gdb调试

gdb

(gdb) file sapi/cli/php

(gdb)run test.php #这里的test.php是随便编写的一个php文件

(gdb) list

612 /* }}} */

613

614 /* {{{ main

615 */

616 #ifdef PHP_CLI_WIN32_NO_CONSOLE

617 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)

618 #else

619 int main(int argc, char *argv[])

620 #endif

621 {

(gdb) b 617

Breakpoint 1 at 0x81c18f7: file /root/xiaoq/php-src-5.2/sapi/cli/php_cli.c, line 617.

(gdb) r

Starting program: /root/xiaoq/php-src-5.2/sapi/cli/php test.php

[Thread debugging using libthread_db enabled]

Breakpoint 1, main (argc=2, argv=0xbfffea84) at /root/xiaoq/php-src-5.2/sapi/cli/php_cli.c:621

621 {

(gdb) n

628 int orig_optind=php_optind;

(gdb)

622 volatile int exit_status = SUCCESS;

不会gdb的稍微学下,我也下的手册刚看的,可以开始php源码之旅了,下章分析下php的大体执行流程和关键的源码位置,我也是初学者,不对之处多多指教!!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: