<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://www.jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://www.jackxiang.com/post//</link>
<title><![CDATA[phpdbg 作为一个交互式集成的调试器SAPI，安装扩展到PHP5.6.0里。]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Php/Js/Shell/Go]]></category>
<pubDate>Sat, 04 Oct 2014 02:01:35 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	背景：以前调试PHP如CPU100%发生在哪儿，用GDB，现在PHP自己带了一个PHPGDB，方便调试。<br/><textarea name="code" class="php" rows="15" cols="100">
&lt;?php
function test1()&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while(true)&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sleep(1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&#125;
test1();
?&gt;
</textarea><br/><br/>root@119.10.6.23:/data/codesdev/phpServer# php test.php<br/>root@119.10.6.23:/data/software/lnmp1.1-full/php-5.6.0# ps aux&#124;grep test.php<br/>root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4071&nbsp;&nbsp;1.3&nbsp;&nbsp;1.5 350356 92040 pts/1&nbsp;&nbsp;&nbsp;&nbsp;S+&nbsp;&nbsp; 11:37&nbsp;&nbsp; 0:00 php test.php<br/>cli方式执行php脚本，加入执行的进程号为4071。我们使用gdb命令来调试进程。<br/>root@119.10.6.23:/data/software/lnmp1.1-full/php-5.6.0# gdb -p 4071<br/><br/>(gdb) print (char *)executor_globals.active_op_array-&gt;filename<br/>$1 = 0x2ad61b4c8c48 &quot;/data/codesdev/phpServer/test.php&quot;<br/>(gdb) print (char *)executor_globals.active_op_array-&gt;function_name<br/>$2 = 0x2ad61b4c8d50 &quot;test1&quot;<br/>(gdb)&nbsp;&nbsp;print executor_globals-&gt;current_execute_data-&gt;opline-&gt;lineno<br/>$3 = 4<br/>(gdb)&nbsp;&nbsp;print executor_globals-&gt;current_execute_data-&gt;opline-&gt;lineno<br/>$4 = 4<br/>很显然，他正在执行第四行的sleep方法。<br/>如果上面的方法你感觉麻烦，那你可以使用.gdbinit文件。这个文件在php源码的根目录下。使用方法如下：<br/><textarea name="code" class="php" rows="15" cols="100">
gdb -p 4071
(gdb) source /data/software/lnmp1.1-full/php-5.6.0/.gdbinit
(gdb) zbacktrace
[0x2ad60fff41b8] sleep(1) /data/codesdev/phpServer/test.php:4 
[0x2ad60fff40e8] test1() /data/codesdev/phpServer/test.php:7 
</textarea><br/><br/>题外话：<br/>​从php5.6开始，php中集成了一个phpdbg的工具。可以像gdb调试c语言程序一样，调试php程序。感兴趣的话，可以打开下面的连接看看。<br/>https://wiki.php.net/rfc/phpdbg<br/>http://phpdbg.com/docs<br/>来自：http://www.searchtb.com/2014/04/当cpu飙升时，找出php中可能有问题的代码行.html<br/>————————————————————————————————————————————————————————————<br/>phpdbg 作为一个交互式集成的调试器SAPI：<br/>http://phpdbg.com/<br/>Download：<br/>https://codeload.github.com/krakjoe/phpdbg/legacy.zip/v0.4.0<br/>Unzip：<br/>root@119.10.6.23:/data/software/lnmp1.1-full/php-5.6.0/ext/krakjoe-phpdbg-cee9645#<br/><br/>http://phpdbg.com/docs<br/>Installation<br/>To install phpdbg, you must compile the source against your PHP installation sources, and enable the SAPI with the configure command.<br/><br/>cd /usr/src/php-src/sapi<br/>git clone https://github.com/krakjoe/phpdbg<br/>cd ../<br/>./buildconf --force<br/>./config.nice<br/>make -j8<br/>make install-phpdbg<br/><br/>phpdbg&nbsp;&nbsp;Felipe Pena, Joe Watkins, Bob Weinand<br/>Command Line Options<br/>The following switches are implemented (just like cli SAPI):<br/><br/>-n ignore php ini<br/>-c search for php ini in path<br/>-z load zend extension<br/>-d define php ini entry<br/>The following switches change the default behaviour of phpdbg:<br/><br/>-v disables quietness<br/>-s enabled stepping<br/>-e sets execution context<br/>-b boring - disables use of colour on the console<br/>-I ignore .phpdbginit (default init file)<br/>-i override .phpgdbinit location (implies -I)<br/>-O set oplog output file<br/>-q do not print banner on startup<br/>-r jump straight to run<br/>-E enable step through eval()<br/>Note: passing -rr will cause phpdbg to quit after execution, rather than returning to the console
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] phpdbg 作为一个交互式集成的调试器SAPI，安装扩展到PHP5.6.0里。]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>