View Issue Details

IDProjectCategoryView StatusLast Update
0001609XdebugStep Debuggingpublic2019-01-17 11:58
Reporterebreisman Assigned Toderick  
PriorityhighSeverityfeatureReproducibilityalways
Status resolvedResolutionno change required 
PlatformAppleOSMacOsOS Version10.13.6
Product Version2.7.0beta1 
Summary0001609: Unable to view local variables when debugging in Phpstorm using xdebug
Description

A simple local variable assignment such as $a = 1 does not display the value of $a in the debug view. However, if $a is assigned from a call to a method such as $a = $this->myMethod(), then the value is displayed.

TagsNo tags attached.
Attached Files
xdebug.log (114,445 bytes)
Operating System
PHP Version7.3.0

Activities

derick

2019-01-16 14:52

administrator   ~0004806

Do you have OPcache turned on?

If so, it might just have optimised it out. Can you provide a short reproducible script, and a remote log (as is described at https://xdebug.org/support.php#remote) to go with it please?

ebreisman

2019-01-16 20:09

reporter   ~0004810

Short script. Both variables $a and $b did not show while stepping through the code. I still have to check whether OPcache is turned on:

public function test()
{
$a = 1;
$b = $a + 1;
return $b;
}

ebreisman

2019-01-16 20:21

reporter   ~0004811

Just checked: OPcache is turned on.

derick

2019-01-17 11:58

administrator   ~0004816

This is not a bug, but a feature in OPcache, which disables and optimises PHP code.

With OPcache enabled, the following PHP opcodes are created:

<pre>
compiled vars: none
line #* E I O op fetch ext return operands

2 0 E > EXT_NOP
4 1 EXT_STMT
5 2 EXT_STMT
6 3 EXT_STMT
4 > RETURN 2
</pre>

As you can see, it only really does a "return 2;", and has no variables. The EXT_STMT opcodes are the ones that Xdebug can break on.

With OPcache disabled, the ADD and ASSIGN statements, as well as the $a and $b variables are still there:

<pre>
compiled vars: !0 = $a, !1 = $b
line #* E I O op fetch ext return operands

2 0 E > EXT_NOP
4 1 EXT_STMT
2 ASSIGN !0, 1
5 3 EXT_STMT
4 ADD 0000003:0000003 !0, 1
5 ASSIGN !1, 0000003:0000003
6 6 EXT_STMT
7 > RETURN !1
7 8 EXT_STMT
9
> RETURN null
</pre>

Issue History

Date Modified Username Field Change
2019-01-15 17:21 ebreisman New Issue
2019-01-16 14:52 derick Note Added: 0004806
2019-01-16 14:52 derick Assigned To => derick
2019-01-16 14:52 derick Status new => feedback
2019-01-16 20:08 ebreisman File Added: xdebug.log
2019-01-16 20:09 ebreisman Note Added: 0004810
2019-01-16 20:09 ebreisman Status feedback => assigned
2019-01-16 20:21 ebreisman Note Added: 0004811
2019-01-17 11:58 derick Note Added: 0004816
2019-01-17 11:58 derick Status assigned => resolved
2019-01-17 11:58 derick Resolution open => no change required
2020-03-12 16:33 derick Category Remote Debugging => Step Debugging