0

I am trying to configure Xdebug for cachegrind but I can't manage to enable the profiler feature in order to dump executed web pages.

I'm using the official guide (and a few more with similar settings) and it doesn't seem to work.

I've tried on both of my Linux machines (Ubuntu and Fedora). Xdebug is working fine for debugging and I can start valgrind --tool=cachegrind for an application so both should be installed properly.

I was activating and deactivating profiler_enable and profiler_enable_trigger options in php.ini and restarting the server, no luck. Changed the output directory as I thought that it might be related to permissions. Using the ?XDEBUG_PROFILER=1 flag in the URL as a parameter doesn't seem to help either.

Any other clues related to the configuration of cachegrind?

Mario Peshev
  • 1,063
  • 8
  • 16
  • Do no logs appear? If so, what does `phpinfo();` say about your xdebug settings? – Wrikken Mar 07 '13 at 00:08
  • [phpinfo log](http://pastebin.com/yXptLJ6U) - no error log clues and the settings should be fine imo – Mario Peshev Mar 07 '13 at 00:12
  • Can you post your xdebug.ini ? – hek2mgl Mar 07 '13 at 00:14
  • updated the pastebin with all xdebug values - http://pastebin.com/MD2gxfA2 – Mario Peshev Mar 07 '13 at 00:18
  • 1
    Hm, (1) It's `?XDEBUG_PROFILE=1`, not profileR, and (2) if that still doesn't work, does an unconditional start with `xdebug.profiler_enable=1` & then restart work? – Wrikken Mar 07 '13 at 00:20
  • right, typo for the param, sorry - tried to switch profiler_enable and profiler_enable_trigger a few times with a restart, but no luck. Will try to reinstall everything in the morning and will get back here if there is any progress. – Mario Peshev Mar 07 '13 at 00:24
  • All right - after reinstalling the valgrind things are finally okay. The first setup was compiling it from source, I removed that and installed through the package manager and it seems to work properly now. The first compiled version didn't detect the architecture properly which led to invalid connection with Xdebug. – Mario Peshev Mar 07 '13 at 11:09

1 Answers1

2

The following basic xdebug.ini should do the trick:

; check that the path is ok for you
zend_extension=/usr/lib/php5/20090626/xdebug.so
xdebug.profiler_enable=1
xdebug.profiler_output_name = cachegring.out.%s
xdebug.profiler_output_dir = /tmp

Note that it enables the profiler for every request what is a significant performance issue. However you should test if this works first. If you see that it works, disable it per default.


About valgrind.

Note that it is not possible what you are trying to do. The xdebug profiler isn't designed to work with / connect to valgrind. It just uses the same output format as valgrind. So, the format is the same as for example:

valgrind --tool=cachegrind --cachegrind-out-file=test.cachegrind ls -al

Usually you'll analyze the cachegrind files using a GUI program like kcachegrind on linux and wincachegrind on windows.

hek2mgl
  • 152,036
  • 28
  • 249
  • 266
  • thanks. The Xdebug path is fine, it's working smoothly - I've been using the debugging functionality from Xdebug for 2 years now, I just can't connect it to cachegrind for some reason - either permissions, or incorrect cachegrind path, or something else. – Mario Peshev Mar 07 '13 at 00:21
  • I'm not sure if is possible what you are trying to do. I usually analyze the cachegrind files using `kcachegrind`. Do you see cachegrind files in /tmp now? – hek2mgl Mar 07 '13 at 00:22
  • Commented in the thread above - turns out it was installation issue for the valgrind and the reinstall made it work. I'm upvoting all advises here as they all confirmed my approach and that's the reason I went back to redo the setup from scratch. Thanks! – Mario Peshev Mar 07 '13 at 11:11
  • @MarioPeshev Seems that I'm missing something. Am I wrong with the valgrind part of answer? – hek2mgl Mar 07 '13 at 11:51