Coder Social home page Coder Social logo

ifa6 / phptrace Goto Github PK

View Code? Open in Web Editor NEW

This project forked from qihoo360/phptrace

0.0 3.0 0.0 1.21 MB

A tracing and troubleshooting tool for PHP scripts.

License: GNU General Public License v2.0

Makefile 1.97% C 84.09% Shell 3.09% Ruby 0.41% PHP 0.81% C++ 9.63%

phptrace's Introduction

phptrace

Introduction 中文

Phptrace is a tracing and troubleshooting tool for PHP scripts. The information of php execute context and php function calls are fetched from PHP Runtime. It is very useful to locate blocking problems, heavy-load problems and tricky bugs both in the online environment and the development environment.

Introduction and Usage

Building

  • Extracting the tarball
tar -zxf phptrace-<version>.tar.gz
cd phptrace-<version>
  • Compile the PHP extension
cd phpext
phpize
./configure --with-php-config=/path/to/php-config
make
  • Compile the command tool
cd cmdtool
make

Installing

  • Install the php extension (phptrace.so) to the PHP extension directory.
make install
  • Edit php.ini and restart the php process if needed.
extension=phptrace.so
phptrace.enabled=1
  • Use the phptrace tool directly under the cmdtool directory.
cd cmdtool
./phptrace  [options]

Examples

  • Trace php function calls.
$ ./phptrace -p 2459                # phptrace -p <PID>
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
  • Print the stack of function call.
$ ./phptrace -p 3130 -s             # phptrace -p <PID> -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 

Comparation

PhpTrace

  • It can print call stack of executing php process, which is similar to pstack.
  • It can trace php function callls, which is similar to strace.
  • It cannot get performance summary of php scripts, which will be supported in the future.
  • It can not debug php scripts.

Phpdbg

  • It is used to debug php program, which is similar to gdb.
  • It cannot print call stack of executing php process.
  • It cannot trace php function calls.

Xhprof

  • It is used to get performance summary, which is similar to gprof.
  • It cannot print call stack of executing php process.
  • It cannot trace php function calls.

Xdebug

  • It can print call stack only if some error occurs.
  • It would hook many opcode handlers even you did not set the auto_trace flag in php.ini; it traces all the processes at the same time just without output. This is a big overhea d in production envirenment.
  • It can not be enabled to trace without modifying the ini or the php script.

Contact

phptrace's People

Contributors

flabby avatar chancey avatar shafreeck avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.