xdebug trace file parser


When I am trying to optimize my PHP code, one of my prefered tools is xdebug. It provides me with excellent error messages, outputs code tracing files & insight into memory usage.

By using kcachegrind or webgrind – wincachegrind crashes *all* the time – to parse the cachegrind files created by xdebug, you get a good idea of what your code is doing most of the time. It’ll show you which functions are called, by who, which arguments are passed and tons more. Check it out.

Now, there was one small thing I couldn’t find anywhere. A program to parse the trace files that xdebug generates. True, xdebug already provides the option to output this information into HTML, but it’s not really what I was looking for. I want to get quick information in the blink of an eye! That’s why I have created my own trace file parser, based on PHP of course.

What is it?

This xdebug trace parser will show you, for each function:

  • How much memory was used on entry & exit
  • How much time it costed to execute the function
  • The exact line the function was called from plus insight into the code by clicking a link
  • Whether the function is native PHP or not


It also has a basic “alerting” feature, which will allow you to set triggers on memory usage & execution time. You can specifiy that if the memory or time jump is greater than a certain value, to show this in the output.


It should be obvious that you’ll need to install and configure xdebug for your PHP installation. See http://www.xdebug.org for more information on this.

Your xdebug config should look a bit like this, don’t forget to update your paths 😉

;; Only Zend OR (!) XDebug
xdebug.trace_output_name= %t.trace
xdebug.profiler_output_name = %s.%t.profile


Now, give it a try and downlod the xdebug trace file parser here!


Once you’ve downloaded the trace file parser, extract it to a directory inside your website root and surf to the URL. If everything works out you should be able to select trace files onceyou have ran an other PHP script on your server. This trace file parser will *not* show it’s own traces because that would make things even more complicated!

Comments & suggestions! :)

16 thoughts on “xdebug trace file parser

  1. NetWorker

    cool script, it’s helpful specially the configurable alerting feature.

    thanks for your efforst

  2. Simon Michael

    Hi, yes thanks for this and could you share the images so they can be added to the github version ?

  3. Pingback: xdebug «

  4. Pingback: 一个奔向攻城狮的程序猿

  5. Pingback: » 【转】PHP调试利器XDebug的安装与使用

  6. Pingback: PHP调试利器XDebug的安装与使用 – 老高的自留地

  7. Pingback: PHP调试利器XDebug的安装与使用 « 神经质的盛宴

  8. Pingback: PHP调试利器XDebug的安装与使用 « IT必应

  9. Pingback: PHP调试利器XDebug的安装与使用_SEO/PHP技术交流分享博客By黑、白SPACE

  10. Pingback: PHP调试利器XDebug的安装与使用 - 子傲代码设计

  11. Pingback: 月是故乡明 » xdebug配置

Leave a Reply

Your email address will not be published. Required fields are marked *