I'm playing around with LLDB (debugger) and I did the following experiment.
Run PHP script as:
php -r "sleep(1000);"
or:
php -r "function r(){sleep(1000);}r();"
On another console, I've called directly
zif_debug_backtrace()
fromlldb
: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
I'm not quite sure why the script had to stop and what I need to do to achieve transparency (without affecting the script)?
P.S. 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 only interested in lldb
/gdb
solutions in order to print the backtrace.
Similar approach works in Ruby, e.g.:
- Run:
ruby -e 'sleep 1000'
. - In another terminal:
echo 'call (void)rb_backtrace()' | lldb -p $(pgrep -nf ruby)
.