欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php-debug-apd-调试器

程序员文章站 2024-02-12 10:18:10
...
http://www.phpq.net/doc/php/ref.apd.php
http://pecl.php.net/package/apd


简介

APD 是 Advanced PHP Debugger,即高级 PHP 调试器。是用来给 PHP 代码提供规划与纠错的能力,以及提供了显示整个堆栈追踪的能力。
APD 支持交互式纠错,但默认是将数据写入跟踪文件。它还提供了基于事件的日志,因此不同级别的信息(包括函数调用,参数传递,计时等)可以对个别的脚本打开或关闭。

APD 是一个 Zend 扩展库,修改了 PHP 内部处理函数调用的方式,因此有可能与其它 Zend 扩展库(例如 Zend Optimizer)不兼容。


安装

APD 目前作为一个 PECL 扩展,可以从 » http://pecl.php.net/package/apd 得到。确保安装了 CGI 版的 PHP 并且在当前目录下可以运行,以及可以运行 phpize 脚本。

运行以下命令以下载,编译并安装最新稳定版的 APD:

pear install apd

这将自动把 APD Zend 扩展安装到 PHP 扩展库目录中。不是一定要放到那里,可以将此模块存放到任何 PHP 可以读取的目录中,只要正确设定了相应的 zend_extension 参数即可。

Windows 用户可以从 » http://snaps.php.net/win32/PECL_STABLE/ 下载扩展库的 DLL 文件 php_apd.dll。

在 INI 文件中,加入下面几行:

zend_extension = /absolute/path/to/apd.so
apd.dumpdir = /absolute/path/to/trace/directory
apd.statement_tracing = 0

根据 PHP 版本,zend_extension 指令可以是以下之一:

zend_extension (non ZTS, non debug build)
zend_extension_ts ( ZTS, non debug build)
zend_extension_debug (non ZTS, debug build)
zend_extension_debug_ts ( ZTS, debug build)


方法

apd_breakpoint ? Stops the interpreter and waits on a CR from the socket
apd_callstack ? Returns the current call stack as an array
apd_clunk ? Throw a warning and a callstack
apd_continue ? Restarts the interpreter
apd_croak ? Throw an error, a callstack and then exit
apd_dump_function_table ? Outputs the current function table
apd_dump_persistent_resources ? Return all persistent resources as an array
apd_dump_regular_resources ? Return all current regular resources as an array
apd_echo ? Echo to the debugging socket
apd_get_active_symbols ? Get an array of the current variables names in the local scope
apd_set_pprof_trace ? Starts the session debugging
apd_set_session_trace ? Starts the session debugging
apd_set_session ? Changes or sets the current debugging level
apd_set_socket_session_trace ? Starts the remote session debugging
override_function ? Overrides built-in functions
rename_function ? Renames orig_name to new_name in the global function table