The Mystery of the Missing Breakpoints
Occasionally I see people mentioned that Xdebug does not stop at certain breakpoints. This tends to relate to multi-line if conditions, or if/else conditions without braces ({ and }). Take for example the following artificial code sample:
1 <?php
2 $a = true;
3 $b = true;
4 $c = true;
5 $d = false;
6
7 if (
8 $a
9 && $b
10 && ( $c || $d )
11 )
12 {
13 echo "It's true!";
14 }
If you set a breakpoint at either line 7, 11, or 12, you'll find that these are ignored. But why is that?
In order to investigate we employ vld, a tool that I wrote that can show PHP's internal bytecode (oparrays containing opcodes). They read very much like assembly code. For the above snippet, the vld dump looks as follows (after redacting useless information):
function name: (null)
number of ops: 19
compiled vars: !0 = $a, !1 = $b, !2 = $c, !3 = $d
line #* E I O op return operands
---------------------------------------------------
2 0 E > EXT_STMT
1 ASSIGN !0, <true>
3 2 EXT_STMT
3 ASSIGN !1, <true>
4 4 EXT_STMT
5 ASSIGN !2, <true>
5 6 EXT_STMT
7 ASSIGN !3, <false>
8 8 EXT_STMT
9 > JMPZ_EX ~8 !0, ->11
9 10 > BOOL ~8 !1
11 > > JMPZ_EX ~8 ~8, ->15
10 12 > > JMPNZ_EX ~9 !2, ->14
13 > BOOL ~9 !3
14 > BOOL ~8 ~9
15 > > JMPZ ~8, ->18
13 16 > EXT_STMT
17 ECHO 'It%27s+true%21'
15 18 > > RETURN 1
The first column is the line number that PHP associates with each opcode, and you can see that there is no opcode for lines 7, 11, and 12. Additionally, Xdebug can only break on the EXT_STMT opcode, which you can see is only present for lines 8 and 13 in the logic section of the script. If a breakpoint is set on a line without an EXT_STMT opcode, Xdebug will not be able to interrupt the script on that line.
Sometimes it can be confusing where PHP thinks there is a line of code, especially since OPcache starts optimising more and more things out. In our example, it could really only leave line 13 around, as the rest is static. It doesn't quite do that yet however.
It is certainly frustrating that Xdebug cannot always stop where you want it to, but IDEs do have a possibility to interrogate where Xdebug could stop through a private DBGp commandxcmd_get_executable_lines. This can only be done when the script, or rather, a specific function is already running.
The DBGp protocol has provisions for signalling to IDEs whether it has resolved a breakpoint when a function gets entered into. Xdebug does currently not implement this functionality yet, but a ticket for it is scheduled for implementation (likely for Xdebug 3.0).
Life Line
I got myself a sheet of Sun-safe filter material, and McGuyvered a pop-up filter for my lens.
The first attempt sort of worked, but I didn't get the filter 100% straight. Luckily I have more material.
But this is sort of my first attempt, and a few sunspots are clearly visible on the right of the image.
Warning: Never look at the Sun without protection!
Go with 2026.02
Improve error messages for `timelib_duration_create_from_iso8601strin…
Fix overflow in the nanosecond carry in `timelib_duration_div_static()`
Consistently use `stdint.h` types for `timelib_duration`
Created 2 recyclings
Created a home entrance and a main entrance
Go with 2026.01
Merged pull request #176
Fix #175: Update Makefile to get the latest version from iana.org site
Merged pull request #184
Added the 'timelib_duration_create_from_iso8601string' implementation
Document the 'static' variants, and correct the original functions' c…
Add overflow detection to `timelib_duration_mul_static()`
Simplify `timelib_duration_sub_static()` for differently-signed inputs
Fix `timelib_duration_add_static()` for opposite signs
Handle normalization of `timelib_duration`’s `negative` in `timelib_d…
Updated a restaurant
I walked 9.8km in 1h41m58s
Use `timelib_duration_null_abs_internal()` in `timelib_duration_mul_s…
Implement 'timelib_duration_sub' and friends
Rename second argument for 'timelib_duration_sub_abs_internal' and do…
Rename timelib_duration_*_internal files to include 'abs' as it opera…
Add definitions for 'static' allocated durations to public header file
Rename 'd' to 'd1' in tests


Shortlink
This article has a short URL available: https://drck.me/brk-ea9