View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0001727 | Xdebug | Step Debugging | public | 2019-12-09 09:23 | 2020-01-26 21:53 |
| Reporter | janw.me | Assigned To | |||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | closed | Resolution | fixed | ||
| Product Version | 2.8.1 | ||||
| Target Version | 2.9.1 | Fixed in Version | 2.9.1 | ||
| Summary | 0001727: Debugger stops more often than expected due to resolving breakpoints | ||||
| Description | Xdebug breaks on the function definition before it stops inside the function with a breakpoint. It started happing last week, PHPstorm released an update, but a provision of the vagrant might also have updated the xdebug version, I don't know. | ||||
| Additional Information | I run Ubuntu and using https://github.com/Varying-Vagrant-Vagrants/VVV for the dev enviroment. | ||||
| Tags | No tags attached. | ||||
| Operating System | Ubuntu + https://github.com/Varying-Vagrant-Vagrants/VVV | ||||
| PHP Version | 7.3.10-7.3.14 | ||||
|
|
I've added a comment at the JetBrains tracker, but I'm copying it in here, to have it all in one spot too: Hi, I had a look, and what @LazyOne writes is pretty much spot on, except for the point where you call it an "issue". This is a deliberate change to make breakpoints "stick" in case you inadvertently put them on a line where PHP doesn't have code generated for. The case is lined out in an article that I wrote that about a year ago, and which was first implemented in Xdebug 2.8 (on request from JetBrains, FWIW). I'll try to explain what happens. If you set Line breakpoints are set with filename and line values, with the intention that Xdebug stops when code on that line gets executed. In some cases (as is explain in my article), PHP doesn't generate internal code on the lines that you expect. Xdebug, with the Xdebug does this whenever a new function scope gets entered (which includes entering an included/required file). For this walk through, we look at PHP 7.3. With 7.4 this issue shows up less frequently, because it has optimised some more lines of (internal) code away. Let's take this as file contents:
With breakpoints set on line
filename: /home/derick/dev/php/derickr-xdebug/tests/debugger/bug01727.inc function name: (null) number of ops: 8 compiled vars: none line #* E I O op fetch ext return operands 3 0 E > EXT_STMT As there is no executable line 4 or 9, the resolving mechanism starts at the given line, and scans forwards for a maximum of 5 lines. Which means that
function name: called_function number of ops: 4 compiled vars: none line #* E I O op fetch ext return operands 8 0 E > EXT_NOP And hence, it stops as a third time on line The scanning of 5 lines forwards was picked as a compromise between not missing lines of code to be executed, and also to make sure that it wouldn't read "outside of the function". The latter seems to have happened here, because your functions are really short, and neither of them have a usually customary docblock either. I believe this is an outlier, as so much code in for example this Symfony file shows: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DomCrawler/Crawler.php#L205 — as docblocks are usually at least 5 lines large, the situation that you ran into here is almost never a problem, although of course, an occasional false positive can occur. Now the question is, does it warrant reducing the max scan lines from |
|
|
This is now fixed in the xdebug_2_9 branch in GIT. It would be lovely if you could try this out before I put it in a release! |
|
|
I confirm that this fix works, at least given the original report. Using the code from the report in https://github.com/drud/ddev/issues/1996: Ubuntu 18.04, php-dev (7.2)
The xdebug version 3.0.0-dev of the master build did confuse me :) Thanks for all the effort on this @derick ! And thanks for the years of effort maintaining a fundamental resource. |
|
|
@derick, |