I. 高级 PHP 调试器

介绍

如何在你的代码里使用 PHP-APD

在你的 PHP 代码中加入如下代码行:

apd_set_session_trace(9);

现在运行你的代码。

堆存输出将被写到:

<apd.dumpdir>/apd_dump_<pid>

输出看起来将如下所示:

16:37:51(george@wasabi)[~/src/apd]> cat /tmp/apd_dump_31994 

APD - Advanced PHP Debugger Trace File
---------------------------------------------------------------------------
Process Pid (31994)
Trace Begun at Fri Aug 10 16:37:45 2001
---------------------------------------------------------------------------
(  0.000000): apd_set_session_trace called at somewhere
(  0.001482): apd_set_session_trace() returned.  Elapsed (997475865.364909)
(  0.001563): getcwd() /opt/apache/htdocs/a.php:4
(  0.001628): getcwd() returned.  Elapsed (0.000065)
(  0.001819): require() /opt/apache/htdocs/a.php:6
              ++ argv[0] $(??) = /tmp/a.php
(  0.002231):   getcwd() /tmp/a.php:3
(  0.002290):   getcwd() returned.  Elapsed (0.000059)
(  0.002375):   include_once() /tmp/a.php:4
                ++ argv[0] $(??) = /tmp/aa.php
(  0.003276):   include_once() returned.  Elapsed (0.000901)
(  0.003334): require() returned.  Elapsed (0.001515)
(  0.003381): require_once() /opt/apache/htdocs/a.php:7
              ++ argv[0] $(??) = /tmp/aa.php
(  0.003515): require_once() returned.  Elapsed (0.000134)
(  0.003564): include() /opt/apache/htdocs/a.php:8
              ++ argv[0] $(??) = /tmp/b.php
(  0.003792): include() returned.  Elapsed (0.000228)
(  0.018341): RSHUTDOWN called - end of trace
---------------------------------------------------------------------------
Process Pid (31994)
Trace Ended at Fri Aug 10 16:37:45 2001
---------------------------------------------------------------------------

内容列表
apd_callstack -- 以数组形式返回当前调用堆栈
apd_clunk -- 返回一条警告和一个调用
apd_croak -- 返回一个错误、一个调用然后退出
apd_dump_regular_resources -- 以数组形式返回所有的常规资源
apd_dump_persistent_resources -- 以数组形式返回所有的持久资源
apd_dump_function_table -- 输出当前函数表
override_function -- 跨越内建函数
rename_function -- 在全局函数表里将 orig_name 重命名为 new_name
apd_set_session_trace -- 开始会话调试
apd_set_socket_session_trace -- 启动远程会话调试
apd_set_session -- 改变或设置当前调试级别
apd_breakpoint -- 终止解释器等待从端口返回一个 CR
apd_continue -- 重启解释器
apd_echo -- 回应到调试端口
apd_get_active_symbols -- 在局部范围获得当前所有变量名的数组