View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000842 | Xdebug | Uncategorized | public | 2012-05-25 03:57 | 2016-12-11 15:23 |
Reporter | dinu | Assigned To | derick | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | duplicate | ||
Product Version | 2.2.0 | ||||
Fixed in Version | 2.5.1 | ||||
Summary | 0000842: Can't debug conditional statements without a block | ||||
Description |
I myself preach the values of good coding practices. However, I find myself stuck with third-party code that I don't want to restyle, mainly because it comes through a CVS that is regularly updated so I'd rather keep the original shape of the code. | ||||
Steps To Reproduce | 1) Try to get debugger to step on the return statement if($random) 2) Step into callThis(), then step out; no possibility to step callThat() if(callThis()||callThat()){ | ||||
Tags | No tags attached. | ||||
Operating System | |||||
PHP Version | 5.3.3 | ||||
|
2) Just to eliminate one possibility: if callThis() returns true then callThat() is not called because the result of the logical OR expression is already known. That's an optimization done by PHP. |
|
I know, it's pretty standard in any language :) I'm talking about that if the 2 calls are followed. |
|
More details: cannot set a breakpoint on a conditional predicate without a block: try to set a breakpoint on doThis() or doThat() line if($cond) |
|
For the first case, breakpoints are tricky. Sadly PHP itself doesn't generate the correct line numbers internally. See for example the code:
Which in PHP turns into:
line # * op fetch ext return operands 22 0 > EXT_NOP as you can see, there is no line 24 or 26. One of the PHP folks is looking at fixing this, but this is currently not something I can address in Xdebug. Even more annoying, the case for "false" also hits line 25 due to PHP weirdness. I will now have a look at the second case. |
|
By your example, I should be able to set a breakpoint on 25 or 27. Which I am not; I try to ellaborate a litle on a test case:
TS1:
TS2:
TS3:
|
|
More discussion over TS3 where I think a definite improvement can be made: most debuggers I'm familiar with interpret debugger commands on conditional statements the following way:
|
|
Marking as "not fixable": All cases really have the same cause. It stops on line 15 because of this is where PHP places the if statement: 15 8 EXT_STMT This is something PHP should have put on line 14, but didn't. The step-into The second case in TS1 (not stopping on line 19) is because PHP TS2 is indeed because PHP simply generates no code on line 14: 11 6 EXT_STMT TS3 is because PHP doesn't generate an EXT_STMT before the dummy1 call, You fix all of this by just using braces. |
|
This turned out to be a duplicate of 1165, for which I now have cooked up a fix, which will make it into 2.5.1. |
Date Modified | Username | Field | Change |
---|---|---|---|
2012-05-25 03:57 | dinu | New Issue | |
2012-05-27 20:59 | rulatir | Note Added: 0002192 | |
2012-05-27 22:57 | dinu | Note Added: 0002193 | |
2012-05-28 12:00 | dinu | Note Added: 0002208 | |
2012-06-01 22:40 | derick | Note Added: 0002226 | |
2012-06-01 22:40 | derick | Note Edited: 0002226 | |
2012-06-01 22:41 | derick | Note Edited: 0002226 | |
2012-06-02 04:08 | dinu | Note Added: 0002227 | |
2012-06-02 04:25 | dinu | Note Added: 0002228 | |
2012-06-02 09:42 | derick | Note Edited: 0002227 | |
2012-06-27 21:11 | derick | Note Added: 0002299 | |
2012-06-27 21:11 | derick | Status | new => resolved |
2012-06-27 21:11 | derick | Resolution | open => not fixable |
2012-06-27 21:11 | derick | Assigned To | => derick |
2012-10-18 21:53 | derick | Relationship added | has duplicate 0000895 |
2014-08-14 11:01 | derick | Relationship added | has duplicate 0001069 |
2016-07-31 12:36 | derick | Category | Usage problems => Usage problems (Crashes) |
2016-07-31 12:38 | derick | Category | Usage problems (Crashes) => Usage problems (Wrong Results) |
2016-12-11 15:22 | derick | Status | resolved => assigned |
2016-12-11 15:23 | derick | Note Added: 0003992 | |
2016-12-11 15:23 | derick | Relationship added | duplicate of 0001165 |
2016-12-11 15:23 | derick | Status | assigned => resolved |
2016-12-11 15:23 | derick | Fixed in Version | => 2.5.1 |
2016-12-11 15:23 | derick | Resolution | not fixable => duplicate |
2020-03-12 16:35 | derick | Category | Usage problems (Wrong Results) => Variable Display |
2020-03-12 16:38 | derick | Category | Variable Display => Uncategorized |