I'm using xhprof for profiling an application. What I need to know is which file each function comes from, because some of the functions are global and some have duplicate names (it's legacy code, don't judge! ;) From what I could see xhprof doesn't return this data in its output, does anyone know otherwise?
I was hoping I won't have to modify the source code of xhprof to return this data... :-)
Thanks for your help!
Just wanted to say how I solved this in case other people find it useful.
I had to modify the xhprof source in the end, but it was a small change.
In xhprof.c, find a function called *hp_get_function_name and add the following to the list of variables right at the beginning after "int len;" :
Then right at the end of that function, swap the line that says "return ret;" for
This will prepend the file path followed by a pipe ( | ) to each function name, for example /path/to/foo.php|foo==>bar (without this modification xhprof would output just foo==>bar).
It's been a while since I've done C programming so there might be a better way of doing this, but it did the job for me.
It's easy to then parse this output in your implementation of iXHProfRuns - you just need to explode the string by | to get the file path and function names separately.
Hope this helps!