5

I'm familiar with the debug_backtrace function in PHP, and really find it useful. However, I have a specific, very messy case where I need to be able to do the reverse - stick a function call in somewhere and have it give me a list of every function that's called after that point until the page is completely loaded.

We do have XDebug installed, and for most projects I use it. This is a really messy codebase, though, with a lot of ajax and php code that's actually created as strings and rendered (I did NOT write this code!) and none of us have ever been successful in getting a debugger to work.

EmmyS
  • 11,892
  • 48
  • 101
  • 156
  • You can use xdebug to generate a profile, and Webgrind or any appropriate gui to trace where the code goes. – AD7six Feb 13 '14 at 22:50
  • Thanks for the thought, but I can't install anything on our server, and it looks like Webgrind needs to be installed somewhere that can be accessed by the webserver. – EmmyS Feb 13 '14 at 22:55
  • Webgrind is just a php application, it takes an xdebug profile as input, and it doesnt need to be on the same maching generating the profile - and it's just one of many guis (one with no other install requirements for a php developer). – AD7six Feb 13 '14 at 22:57
  • Thanks for the clarification; I didn't have much time to look very closely at it yesterday. I will take a closer look. – EmmyS Feb 14 '14 at 15:43
  • @AD7six - I took an hour this morning and got it downloaded and installed. It's not exactly what I was looking for, but I think it'll get me what I need. Thanks. If you want to post an answer, I'll accept it. – EmmyS Feb 14 '14 at 16:32
  • Lately I only access SO via my phone - take a screenshot of how it helped (or not, though I don't see how having a list of called methods is not what you needed) and accept your own answer :) – AD7six Feb 16 '14 at 10:25

1 Answers1

1

PHP has a ticks feature, which can get called at the execution of each statement.

Using the ticks feature, my answer describes a class CStatemenTracer, which write a call trace alongside the execution of your application.

Might be a starting point.

Community
  • 1
  • 1
SteAp
  • 11,853
  • 10
  • 53
  • 88