1

I'm trying to print PHP backtrace of the live running script using the following 2 simple steps:

  1. Run PHP script as:

    php -r "sleep(1000);"
    
  2. On another console, I've called directly zif_debug_backtrace() from lldb:

    echo 'call (void)zif_debug_backtrace()' | lldb -p $(pgrep -fn php)
    

Above worked, however the process stopped with the following warning:

Warning: sleep() expects at most 2 parameters, 1606408648 given in Command line code on line 1
Call Stack:
    0.0016     235152   1. {main}() Command line code:0
    0.0021     235248   2. sleep(1000) Command line code:1

Why the script stopped and how to prevent that? Is it possible to print PHP backtrace during live run without affecting the script?

Is it because I should specify some return address? If so, which one?

Btw. The same happening when calling zif_debug_print_backtrace() and when calling custom_backtrace() it is showing: Backtrace null function called. I'm using xdebug if that change anything.

Maybe I need to call a different function like zend_fetch_debug_backtrace (see: image dump symtab)? Or use the right arguments, if so, which one?

I'm interested either in lldb or gdb solutions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.