public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Debugging PHP with GDB and php-debuginfo
@ 2021-07-20 22:54 Jim Hyslop
  2021-07-21  1:24 ` Russell VT
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jim Hyslop @ 2021-07-20 22:54 UTC (permalink / raw)
  To: cygwin

Hi, all

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`.

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])

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?

-- 
Jim Hyslop

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Debugging PHP with GDB and php-debuginfo
  2021-07-20 22:54 Debugging PHP with GDB and php-debuginfo Jim Hyslop
@ 2021-07-21  1:24 ` Russell VT
  2021-07-21  5:26 ` bzs
  2021-07-21  8:06 ` Andrey Repin
  2 siblings, 0 replies; 4+ messages in thread
From: Russell VT @ 2021-07-21  1:24 UTC (permalink / raw)
  To: Jim Hyslop; +Cc: cygwin

There's the "Magic Method" in PHP for __debuginfo()
<https://www.php.net/manual/en/language.oop5.magic.php#object.debuginfo>.

Also see PHP RFC: __debugInfo() <https://wiki.php.net/rfc/debug-info>.

You may have better luck asking the PHP devs how to best use this with GDB,
or the GDB folks how to use the extension.

Hope that helps!

Russell VT


On Tue, Jul 20, 2021 at 3:55 PM Jim Hyslop <jhyslop@dreampossible.ca> wrote:

> Hi, all
>
> 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`.
>
> 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])
>
> 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?
>
> --
> Jim Hyslop
>
> --
> Problem reports:      https://cygwin.com/problems.html
> FAQ:                  https://cygwin.com/faq/
> Documentation:        https://cygwin.com/docs.html
> Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
>


-- 
Russell M. Van Tassell <russellvt@gmail.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Debugging PHP with GDB and php-debuginfo
  2021-07-20 22:54 Debugging PHP with GDB and php-debuginfo Jim Hyslop
  2021-07-21  1:24 ` Russell VT
@ 2021-07-21  5:26 ` bzs
  2021-07-21  8:06 ` Andrey Repin
  2 siblings, 0 replies; 4+ messages in thread
From: bzs @ 2021-07-21  5:26 UTC (permalink / raw)
  To: Jim Hyslop; +Cc: cygwin


As much as I love GDB dearly and rely on it regularly you might want
to have a look at netbeans.apache.org which is also free and a more
general fancy UI IDE. If it's a web site you're developing for example
it will let you fire up a browser, put breakpoints in the php code,
and examine variables etc.

It's a little more complicated to set up than just using GDB but not
too bad (hint: install the Chrome browser ZDebug/XDebug/whateveritis
extension they recommend, and/or Firefox, or netbeans has a built-in
browser tho you probably want to know how your code works with chrome
and/or ff not their browser other than initial devpt.)

P.S. I generally edit my code with emacs. Netbeans notices a file has
changed and reloads -- it's magic (aka inotify(7)) tho use one (IDE
editing) or the other (emacs/vi/joe/jove/pico/externaleditor.)

The latest releases of netbeans (12.x) have gotten very good but once
in a while you just have to exit and restart it ("a communication
failure has occurred...") but no big deal just restart it, it
remembers your breakpoints etc., just to save you five minutes of
WTF?!

-- 
        -Barry Shein

Software Tool & Die    | bzs@TheWorld.com             | http://www.TheWorld.com
Purveyors to the Trade | Voice: +1 617-STD-WRLD       | 800-THE-WRLD
The World: Since 1989  | A Public Information Utility | *oo*

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Debugging PHP with GDB and php-debuginfo
  2021-07-20 22:54 Debugging PHP with GDB and php-debuginfo Jim Hyslop
  2021-07-21  1:24 ` Russell VT
  2021-07-21  5:26 ` bzs
@ 2021-07-21  8:06 ` Andrey Repin
  2 siblings, 0 replies; 4+ messages in thread
From: Andrey Repin @ 2021-07-21  8:06 UTC (permalink / raw)
  To: Jim Hyslop, cygwin

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...


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-21  8:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-20 22:54 Debugging PHP with GDB and php-debuginfo Jim Hyslop
2021-07-21  1:24 ` Russell VT
2021-07-21  5:26 ` bzs
2021-07-21  8:06 ` Andrey Repin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).