Set Breakpoint won't work when program is running

I wrote a simple program like this :
****************************************************************

1 <?php

3 while(true)
4 {
5     $stop = "here";
6     sleep(1);
7 }


****************************************************************
I tried to start this program first, and then setted breakpoint to line 5.
But the breakpoint won't be reached.

Update my working environment:
-------------------------------------------------------------------------
PhpStorm Version: 6.0.2
Xdebug Version: 2.2.1
PHP version: 5.3.3
OS: CentOS 6.2
-------------------------------------------------------------------------

Thanks for the kindly help

10 comments

Sorry that should I provide more further information?
Thanks for any suggestion and any help :)

0

What have you done in PhpStorm as well as on remote side to set it up for such remote debug?

Here is a blog post that described all the steps required, in case you have not seen it yet: http://blog.jetbrains.com/webide/2012/03/new-in-4-0-easier-debugging-of-remote-php-command-line-scripts/

0

Thanks for the reply.
Please let me clarify my problem again, I properbly miss the point.

Actually I can debug on the simple program if I set the breakpoint before execute the program.
But the breakpoint won't be reached anymore if I set the brakpoint after program be executed.

0

In this case I will not be able to help you much -- I'm not a dev and do not do any of such remote CLI debug myself (don't even have an environment to test).

My only suggestion:

  1. Collect xdebug logs on remote side: http://xdebug.org/docs/all_settings#remote_log
  2. Collect debugging logs from phpStorm side: http://devnet.jetbrains.com/docs/DOC-1202
  3. See if you will find anything useful in those logs that may tell you about possible reasons for such behaviour
  4. If nothing -- feel free to submit new ticket to the Issue Tracker with as much info as possible (at very least devs will tell you if it is a IDE issue or xdebug one)
0

Thank you again, I jsut tried another test.

Debug this simple program on local machine.
It still only work if breakpoints be setted before program start.

Thanks for the remind, I tried to find anything useful on the debug logs.
And I found xdebug's log won't be logged an event like 'breakpoint_set ......' if the program is running.
But the event 'breakpoint_set ......'  would be logged if the program is breaked into debug mode.

0

Well ... it does work fine here on my Windows 7 x64 SP1; PHP 5.4.15; Xdebug 2.2.2; PhpStorm 6.0.2 build 129.487

Can you please show a screenshot of the IDE when you attemp to set 2nd breakpoint at line #5 (after you already in debug session).

This is how it looks here:
screen01.png

0

Sure, if I set breakpoint first:

breakpointok.jpg

If I start program first:

breakpointfail.jpg

0

Let me describe more specific about the step :)

1.  No breakpoints be setted brefore run the program
Screen Capture.png

2. Click rerun button to run/debug the program
1.png
3. No matter which line be setted a breakpoint, it won't be stopped into debug mode.
2.png

0

Thank you for detailed screenshots -- it clarifies a lot.

AFAIK current behaviour is not a bug and is expected.

  • As you can see from your screenshots (last post) none of the breakpoints have "tick" in it (means -- it is not registered).
  • Breakpoint cannot be registered during actual script execution. I mean -- it can be registered if script is "on hold"/being debugged right now, when xdebug awaits response from debug client (PhpStorm in our case) with instructions on what to do next.
  • When script just runs (e.g. infinite loop in your case), there is no communication with xdebug during this time. Xdebug is the one who initiates communication. AFAIK communication only occurs when:
    • PHP starts executing new script and xdebug sees debug instructions (cookie, get/post param .. or configured to initiate debug session automatically on each script execution)
    • xdebug hits breakpoint and awaits further instructions from client (when script execution is "on hold")
    • xdebug catches unhandled exception (JustInTime debug, not supported by PhpStorm ATM)


I do not know what you are debugging (considering your example) .. but maybe conditional breakpoint will be useful for you here (will only break if some condition is met). Obviously, it has to be set in advance.

0

Thank you so much for the clearly explanation.
It would really be great if breakpoints can be registered when script runs!
However, thanks again for the kindly help :)

0

Please sign in to leave a comment.