http://www.jb51.net/article/76028.htm
http://rango.swoole.com/archives/325
http://phpor.net/blog/post/997
http://houjixin.blog.163.com/blog/static/35628410201311241916314/
<?php function test1(){
while(true){
sleep(1);
}
}
test1();
?>
cli方式執行php腳本,加入執行的進程號爲14973。咱們使用gdb命令來調試進程。
$sudo gdb -p 14973
(gdb) print (char *)executor_globals.active_op_array->filename
$1 = 0x9853a34 "/home/xinhailong/test/php/test.php"
(gdb) print (char *)executor_globals.active_op_array->function_name
$2 = 0x9854db8 "test1"
(gdb) print executor_globals->current_execute_data->opline->lineno
$3 = 4
很顯然,他正在執行第四行的sleep方法。
若是上面的方法你感受麻煩,那你可使用.gdbinit文件。這個文件在php源碼的根目錄下。使用方法以下:
$sudo gdb -p 14973
(gdb) source /home/xinhailong/.gdbinit
(gdb) zbacktrace
[0xa453f34] sleep(1) /home/xinhailong/test/php/test.php:4
[0xa453ed0] test1() /home/xinhailong/test/php/test.php:7
(gdb)
轉自:http://www.linuxeden.com/html/news/20160330/165480.htmlphp