Code Monkey home page Code Monkey logo

xdebugtracetree's Introduction

XDebugTraceTree

This simple script adds trees to XDebug traces.

Example input (taken from here):

TRACE START [2012-09-25 11:19:54]
    0.0005     645152  +645152   -> {main}() /var/www/test.php:0
    0.0007     649296    +4144     -> require(/var/www/config.inc) /var/www/test.php:4
    0.0007     649504     +208       -> define('HOST', '10.1.1.1') /var/www/config.inc:3
    0.0008     649536      +32       -> define('NAME', 'db') /var/www/config.inc:4
    0.0008     649568      +32       -> define('USER', 'u0') /var/www/config.inc:5
    0.0008     649600      +32       -> define('PASS', 'ps') /var/www/config.inc:6
    0.0012     695728   +46128     -> require(/var/www/class/db.php) /var/www/test.php:5
    0.0013     694736     -992     -> show_num($i = 1) /var/www/test.php:8
    0.0013     694736       +0       -> show_odd($i = 1) /var/www/test.php:21
    0.0013     694864     +128     -> show_num($i = 2) /var/www/test.php:8
    0.0013     694864       +0       -> show_even($i = 2) /var/www/test.php:21
    0.0014     694960      +96         -> sleep(1) /var/www/test.php:30
    1.0033     694864      -96     -> show_num($i = 3) /var/www/test.php:8
    1.0034     694864       +0       -> show_odd($i = 3) /var/www/test.php:21
    1.0034     694864       +0     -> show_num($i = 4) /var/www/test.php:8
    1.0034     694864       +0       -> show_even($i = 4) /var/www/test.php:21
    1.0035     694960      +96         -> sleep(1) /var/www/test.php:30
    2.0047     694864      -96     -> show_num($i = 5) /var/www/test.php:8
    2.0048     694864       +0       -> show_odd($i = 5) /var/www/test.php:21
    2.0048     695224     +360     -> alloc_array($size = 1024) /var/www/test.php:13
    2.0057     843024  +147800     -> DB::Get($type = 'mysql', $host = '10.1.1.1', $user = 'u0', $pass = 'ps', $db = 'db') /var/www/test.php:15
    2.0057     843664     +640       -> absDB->__construct($host = '10.1.1.1', $user = 'u0', $pass = 'ps', $db = 'db') /var/www/class/db.php:10
    2.0058     843664       +0         -> DB->__construct($host = '10.1.1.1', $user = 'u0', $pass = 'ps', $db = 'db') /var/www/class/db.php:36
    2.0058     844000     +336           -> DB->build() /var/www/class/db.php:19
    2.0058     844016      +16     -> absDB->connect() /var/www/test.php:16
    2.0058     844368     +352       -> mysqli_connect('10.1.1.1', 'u0', 'ps', 'db') /var/www/class/db.php:47
   11.0164       8432
TRACE END   [2012-09-25 11:20:05]

Output:

TRACE START [2012-09-25 11:19:54]
    0.0005     645152  +645152   └> {main}() /var/www/test.php:0
    0.0007     649296    +4144     └> require(/var/www/config.inc) /var/www/test.php:4
    0.0007     649504     +208     │ └> define('HOST', '10.1.1.1') /var/www/config.inc:3
    0.0008     649536      +32     │ └> define('NAME', 'db') /var/www/config.inc:4
    0.0008     649568      +32     │ └> define('USER', 'u0') /var/www/config.inc:5
    0.0008     649600      +32     │ └> define('PASS', 'ps') /var/www/config.inc:6
    0.0012     695728   +46128     └> require(/var/www/class/db.php) /var/www/test.php:5
    0.0013     694736     -992     └> show_num($i = 1) /var/www/test.php:8
    0.0013     694736       +0     │ └> show_odd($i = 1) /var/www/test.php:21
    0.0013     694864     +128     └> show_num($i = 2) /var/www/test.php:8
    0.0013     694864       +0     │ └> show_even($i = 2) /var/www/test.php:21
    0.0014     694960      +96     │   └> sleep(1) /var/www/test.php:30
    1.0033     694864      -96     └> show_num($i = 3) /var/www/test.php:8
    1.0034     694864       +0     │ └> show_odd($i = 3) /var/www/test.php:21
    1.0034     694864       +0     └> show_num($i = 4) /var/www/test.php:8
    1.0034     694864       +0     │ └> show_even($i = 4) /var/www/test.php:21
    1.0035     694960      +96     │   └> sleep(1) /var/www/test.php:30
    2.0047     694864      -96     └> show_num($i = 5) /var/www/test.php:8
    2.0048     694864       +0     │ └> show_odd($i = 5) /var/www/test.php:21
    2.0048     695224     +360     └> alloc_array($size = 1024) /var/www/test.php:13
    2.0057     843024  +147800     └> DB::Get($type = 'mysql', $host = '10.1.1.1', $user = 'u0', $pass = 'ps', $db = 'db') /var/www/test.php:15
    2.0057     843664     +640     │ └> absDB->__construct($host = '10.1.1.1', $user = 'u0', $pass = 'ps', $db = 'db') /var/www/class/db.php:10
    2.0058     843664       +0     │   └> DB->__construct($host = '10.1.1.1', $user = 'u0', $pass = 'ps', $db = 'db') /var/www/class/db.php:36
    2.0058     844000     +336     │     └> DB->build() /var/www/class/db.php:19
    2.0058     844016      +16     └> absDB->connect() /var/www/test.php:16
    2.0058     844368     +352       └> mysqli_connect('10.1.1.1', 'u0', 'ps', 'db') /var/www/class/db.php:47
   11.0164       8432
TRACE END   [2012-09-25 11:20:05]

It doesn't support xdebug trace format other than trace_format=0 and collect_return=0.

Usage

xdebugtracetree trace_file.xt

or

xdebugtracetree trace_file.xt | less

or

xdebugtracetree trace_file.xt > output.txt

Install

You can install running ./install.sh and then use xdebugtracetree global command or just invoke xdebugtracetree.py script directly without installing.

xdebugtracetree's People

Contributors

rekcufniarb avatar

Stargazers

 avatar

Watchers

 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.