Debugging PHP with GDB and php-debuginfo

Andrey Repin anrdaemon@yandex.ru
Wed Jul 21 08:06:11 GMT 2021


Greetings, Jim Hyslop!

> I've installed the php-debuginfo extension for gdb, but I can't figure
> out how to set a breakpoint with it. Is there a manual for 
> php-debuginfo? All I can find is the package information.

> I'm trying to debug why a unit test is passing (it should fail). I'm 
> using the CakePHP framework (www.cakephp.org). From the command line, I 
> normally just execute `vendor/bin/phpunit`.

You're confusing debugging PHP code (i.e. website) with debudding PHP itself.
php-debuginfo is for the latter.

> With gdb, I execute `gdb $(which php)`, then at the command line in GDB 
> I type ` b ./tests/TestCase/Controller/UsersControllerTest.php:80`

> GDB responds with:
> No source file named 
> ./tests/TestCase/Controller/UsersControllerTest.php.
> Make breakpoint pending on future shared library load? (y or [n])

Entirely predictable. PHP is written in C, not PHP.

> The file name is valid. I've tried using the full path instead of the 
> relative path.

> When I run the tests with `r vendor/bin/phpunit` the unit tests all 
> execute, but GDB doesn't stop at the breakpoint.

> Do I need to modify php.ini to use gdb? Any pointers?

You need to install xdebug. And for that, you need to install native PHP, as
there's no PECL modules built for Cygwin.
Then use any suitable IDE (VS Code, PHPStorm, etc.) to step through the code.
Read phpunit instructions about allowing it running under debugger.


-- 
With best regards,
Andrey Repin
Wednesday, July 21, 2021 11:03:04

Sorry for my terrible english...



More information about the Cygwin mailing list