Suppose there is a PHP script on the line that suddenly goes wrong one day, does not process but the process does not exit. This may be an abnormal sleep or a dead loop code, but how do we position it, what we want to know at this time is what the script is doing right now. This is gdb+zbacktrace, it works.
First of all write a test script test.php, the inside write a sleep function, replaced by a dead loop can also.
<? PHP function Mecho ($iecho$i. Php_eol;} $i =; while ($i>0) {if($i%2==0) { Mecho ($i);} Sleep (100000); $i--;}
Zbacktrace download PHP source package Inside, the current my environment is a newly installed, the current PHP version is php7.2.9
Direct CLI Execution test.php
PHP test.php
Then find the current PHP process
Then debug with GDB
Gdb-p 56571
Debugging
This is the time to know that the test.php 11 line sleep function causes the process to sleep.
GDB debugging tips to find the code that the PHP execution process is currently executing