Skip to content
forked from Qihoo360/phptrace

php程序跟踪和分析工具,从PHP Runtime中获取程序的上下文及函数调用情况,适用于线上快速分析定位阻塞、负载高等疑难杂症

License

Notifications You must be signed in to change notification settings

gnever/phptrace

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

phptrace

php程序跟踪和分析工具,从PHP Runtime中获取程序的上下文及函数调用情况,适用于线上快速分析定位阻塞、负载高等疑难杂症

phptrace介绍及使用

Building

编译cmdtool

tar -zxf phptrace-<version>.tar.gz
cd phptrace-<version>
cd cmdtool
make

编译PHP扩展

cd phpext
phpize
./configure --with-php-config=/path/to/php-config
make

Installing

cmdtool编译后, 可直接使用其目录下的phptrace命令。

PHP扩展需要安装到PHP相关目录:

make install

编辑php.ini,启用扩展

extension=phptrace.so
phptrace.enabled=1

Usage

$ phptrace -p <PID>     #trace PHP函数调用
$ phptrace -p <PID> -s  #打印PHP调用栈

Examples

打印调用栈

$ ./phptrace -p 3130 -s
phptrace 0.1 demo, published by infra webcore team
process id = 3130
script_filename = /home/xxx/opt/nginx/webapp/block.php
[0x7f27b9a99dc8]  sleep /home/xxx/opt/nginx/webapp/block.php:6
[0x7f27b9a99d08]  say /home/xxx/opt/nginx/webapp/block.php:3
[0x7f27b9a99c50]  run /home/xxx/opt/nginx/webapp/block.php:10

trace PHP函数调用

$ ./phptrace -p 2459
1417506346.727223 run(<Null>)
1417506346.727232     say($msg = "hello world")
1417506346.727241         sleep($seconds = "1")
1417506347.727341         sleep =>      0       1.000100 
1417506347.727354     say =>    hello world     1.000122 
1417506347.727358 run =>        nil     1.000135 

About

php程序跟踪和分析工具,从PHP Runtime中获取程序的上下文及函数调用情况,适用于线上快速分析定位阻塞、负载高等疑难杂症

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 82.9%
  • Shell 8.8%
  • Python 4.9%
  • C 3.1%
  • Makefile 0.3%
  • PHP 0.0%