GDB debugging tips to find the code that the PHP execution process is currently executing

Source: Internet
Author: User
Tags php script sleep function

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.