View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001644 | Xdebug | Step Debugging | public | 2019-03-04 17:13 | 2019-03-05 13:27 |
Reporter | dv-ds | Assigned To | derick | ||
Priority | normal | Severity | major | Reproducibility | always |
Status | resolved | Resolution | no change required | ||
Product Version | 2.7.0RC2 | ||||
Summary | 0001644: Cannot evaluate local variable in function | ||||
Description | It appears that at least under certain circumstances, it is not possible to evaluate a variable local to a function. | ||||
Steps To Reproduce | <?php function foobar() { foobar(); // 1. Attempt to evaluate $a by hovering over it (same line as breakpoint), this yields no result. It is also not listed as a local. | ||||
Additional Information | Annotated Xdebug log attached. Setup:
I also found an issue that may or may not be related, where evaluating a function argument is only possible when using the console. Would you like a separate bug for this? | ||||
Tags | No tags attached. | ||||
Attached Files | xdebug-log.txt (10,600 bytes)
// Some information replaced with placeholders like "foo.php" and "..." /* Start and let the breakpoint hit */ [13856] Log opened at 2019-03-04 16:47:22 [13856] I: Connecting to configured address/port: localhost:9000. [13856] I: Connected to client. :-) [13856] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///foo.php" language="PHP" xdebug:language_version="7.3.1" protocol_version="1.0" appid="13856"><engine version="2.7.0RC2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2019 by Derick Rethans]]></copyright></init> [13856] [13856] <- feature_set -i 1 -n max_children -v 256 [13856] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="max_children" success="1"></response> [13856] [13856] <- breakpoint_list -i 2 [13856] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="2"></response> [13856] [13856] <- breakpoint_set -i 3 -t line -f file:///foo.php -n 5 [13856] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="3" id="138560004"></response> [13856] [13856] <- breakpoint_list -i 4 [13856] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="4"><breakpoint type="line" filename="file:///foo.php" lineno="5" state="enabled" hit_count="0" hit_value="0" id="138560004"></breakpoint></response> [13856] [13856] <- breakpoint_list -i 5 [13856] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="5"><breakpoint type="line" filename="file:///foo.php" lineno="5" state="enabled" hit_count="0" hit_value="0" id="138560004"></breakpoint></response> [13856] [13856] <- breakpoint_set -i 6 -t exception -x * [13856] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="6" id="138560005"></response> [13856] [13856] <- run -i 7 [13856] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="7" status="break" reason="ok"><xdebug:message filename="file:///foo.php" lineno="5"></xdebug:message></response> [13856] [13856] <- stack_get -i 8 [13856] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="8"><stack where="foobar" level="0" type="file" filename="file:///foo.php" lineno="5"></stack><stack where="{main}" level="1" type="file" filename="file:///foo.php" lineno="8"></stack></response> [13856] [13856] <- context_names -i 9 -d 0 [13856] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_names" transaction_id="9"><context name="Locals" id="0"></context><context name="Superglobals" id="1"></context><context name="User defined constants" id="2"></context></response> [13856] [13856] <- context_get -i 10 -d 0 -c 0 [13856] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="10" context="0"></response> [13856] /* Hover over $a (at the same line as the breakpoint) */ [13856] <- context_get -i 11 -d 0 -c 1 [13856] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="11" context="1"><property name="$_COOKIE" fullname="$_COOKIE" type="array" children="0" numchildren="0" page="0" pagesize="256"></property><property name="$_ENV" fullname="$_ENV" type="array" children="0" numchildren="0" page="0" pagesize="256"></property><property name="$_FILES" fullname="$_FILES" type="array" children="0" numchildren="0" page="0" pagesize="256"></property><property name="$_GET" fullname="$_GET" type="array" children="0" numchildren="0" page="0" pagesize="256"></property><property name="$_POST" fullname="$_POST" type="array" children="0" numchildren="0" page="0" pagesize="256"></property><property name="$_REQUEST" fullname="$_REQUEST" type="array" children="0" numchildren="0" page="0" pagesize="256"></property><property name="$_SERVER" fullname="$_SERVER" type="array" children="1" numchildren="35" page="0" pagesize="256"><property name="SCRIPT_URL" fullname="$_SERVER["SCRIPT_URL"]" type="string" size="1" encoding="base64"><![CDATA[...]]></property><property name="SCRIPT_URI" fullname="$_SERVER["SCRIPT_URI"]" type="string" size="17" encoding="base64"><![CDATA[...]]></property><property name="APPLICATION_ENV" fullname="$_SERVER["APPLICATION_ENV"]" type="string" size="5" encoding="base64"><![CDATA[...]]></property><property name="HTTP_HOST" fullname="$_SERVER["HTTP_HOST"]" type="string" size="9" encoding="base64"><![CDATA[...]]></property><property name="HTTP_CONNECTION" fullname="$_SERVER["HTTP_CONNECTION"]" type="string" size="10" encoding="base64"><![CDATA[...]]></property><property name="HTTP_CACHE_CONTROL" fullname="$_SERVER["HTTP_CACHE_CONTROL"]" type="string" size="9" encoding="base64"><![CDATA[...]]></property><property name="HTTP_UPGRADE_INSECURE_REQUESTS" fullname="$_SERVER["HTTP_UPGRADE_INSECURE_REQUESTS"]" type="string" size="1" encoding="base64"><![CDATA[...]]></property><property name="HTTP_USER_AGENT" fullname="$_SERVER["HTTP_USER_AGENT"]" type="string" size="121" encoding="base64"><![CDATA[...]]></property><property name="HTTP_DNT" fullname="$_SERVER["HTTP_DNT"]" type="string" size="1" encoding="base64"><![CDATA[...]]></property><property name="HTTP_ACCEPT" fullname="$_SERVER["HTTP_ACCEPT"]" type="string" size="85" encoding="base64"><![CDATA[...]]></property><property name="HTTP_ACCEPT_ENCODING" fullname="$_SERVER["HTTP_ACCEPT_ENCODING"]" type="string" size="17" encoding="base64"><![CDATA[...]]></property><property name="HTTP_ACCEPT_LANGUAGE" fullname="$_SERVER["HTTP_ACCEPT_LANGUAGE"]" type="string" size="35" encoding="base64"><![CDATA[...]]></property><property name="PATH" fullname="$_SERVER["PATH"]" type="string" size="29" encoding="base64"><![CDATA[...]]></property><property name="SERVER_SIGNATURE" fullname="$_SERVER["SERVER_SIGNATURE"]" type="string" size="0" encoding="base64"><![CDATA[]]></property><property name="SERVER_SOFTWARE" fullname="$_SERVER["SERVER_SOFTWARE"]" type="string" size="30" encoding="base64"><![CDATA[...]]></property><property name="SERVER_NAME" fullname="$_SERVER["SERVER_NAME"]" type="string" size="9" encoding="base64"><![CDATA[...]]></property><property name="SERVER_ADDR" fullname="$_SERVER["SERVER_ADDR"]" type="string" size="9" encoding="base64"><![CDATA[...]]></property><property name="SERVER_PORT" fullname="$_SERVER["SERVER_PORT"]" type="string" size="2" encoding="base64"><![CDATA[...]]></property><property name="REMOTE_ADDR" fullname="$_SERVER["REMOTE_ADDR"]" type="string" size="9" encoding="base64"><![CDATA[...]]></property><property name="DOCUMENT_ROOT" fullname="$_SERVER["DOCUMENT_ROOT"]" type="string" size="35" encoding="base64"><![CDATA[...]]></property><property name="REQUEST_SCHEME" fullname="$_SERVER["REQUEST_SCHEME"]" type="string" size="4" encoding="base64"><![CDATA[...]]></property><property name="CONTEXT_PREFIX" fullname="$_SERVER["CONTEXT_PREFIX"]" type="string" size="0" encoding="base64"><![CDATA[]]></property><property name="CONTEXT_DOCUMENT_ROOT" fullname="$_SERVER["CONTEXT_DOCUMENT_ROOT"]" type="string" size="35" encoding="base64"><![CDATA[...]]></property><property name="SERVER_ADMIN" fullname="$_SERVER["SERVER_ADMIN"]" type="string" size="15" encoding="base64"><![CDATA[...]]></property><property name="SCRIPT_FILENAME" fullname="$_SERVER["SCRIPT_FILENAME"]" type="string" size="44" encoding="base64"><![CDATA[...]]></property><property name="REMOTE_PORT" fullname="$_SERVER["REMOTE_PORT"]" type="string" size="5" encoding="base64"><![CDATA[...]]></property><property name="GATEWAY_INTERFACE" fullname="$_SERVER["GATEWAY_INTERFACE"]" type="string" size="7" encoding="base64"><![CDATA[...]]></property><property name="SERVER_PROTOCOL" fullname="$_SERVER["SERVER_PROTOCOL"]" type="string" size="8" encoding="base64"><![CDATA[...]]></property><property name="REQUEST_METHOD" fullname="$_SERVER["REQUEST_METHOD"]" type="string" size="3" encoding="base64"><![CDATA[...]]></property><property name="QUERY_STRING" fullname="$_SERVER["QUERY_STRING"]" type="string" size="0" encoding="base64"><![CDATA[]]></property><property name="REQUEST_URI" fullname="$_SERVER["REQUEST_URI"]" type="string" size="1" encoding="base64"><![CDATA[...]]></property><property name="SCRIPT_NAME" fullname="$_SERVER["SCRIPT_NAME"]" type="string" size="10" encoding="base64"><![CDATA[...]]></property><property name="PHP_SELF" fullname="$_SERVER["PHP_SELF"]" type="string" size="10" encoding="base64"><![CDATA[...]]></property><property name="REQUEST_TIME_FLOAT" fullname="$_SERVER["REQUEST_TIME_FLOAT"]" type="float"><![CDATA[...]]></property><property name="REQUEST_TIME" fullname="$_SERVER["REQUEST_TIME"]" type="int"><![CDATA[...]]></property></property></response> [13856] [13856] <- context_get -i 12 -d 0 -c 2 [13856] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="12" context="2"></response> [13856] /* Attempt to evaluate $a in the console */ [13856] <- eval -i 13 -- JGE= [13856] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="13"><property type="null"></property></response> [13856] /* Continue */ [13856] <- run -i 14 [13856] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="14" status="stopping" reason="ok"></response> [13856] [13856] <- stop -i 15 [13856] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stop" transaction_id="15" status="stopped" reason="ok"></response> [13856] [13856] Log closed at 2019-03-04 16:48:03 [13856] | ||||
Operating System | macOS | ||||
PHP Version | 7.3.0-7.3.1 | ||||
|
Is opcache loaded and enabled? It's very possible that opcache simply optimised the variable away. |
|
Disabling opcache helps in this case, thanks, then I consider it a PHP bug for now. For the other case I mentioned, it does not help however. I'll create a separate bug for that tomorrow. It happens at least when using each() - possibly due to the deprecation warning somehow. |
|
Created 1645. As for this issue: If you think this a PHP issue and that it might be solved in 7.3.2, please close this issue as I doubt I'll be able to test that theory anytime soon. I'm reluctant to upgrade to 7.3.2 just yet unless something breaks badly for me, as I've had problems with pretty much every PHP upgrade I've done using Homebrew. I can live with disabling the opcache for now. |
|
Hi, This is not a bug in PHP, but a feature. Opcache tries to make your code run faster, and to do so it optimises your PHP code. In this case, it optimises out the variable. You can see this when you compare the internal opcodes being generated without opcache loaded, against it being loaded: Without Opcache
derick@singlemalt:~$ php -n -dextension=vld.so -dvld.active=1 /tmp/1644.php … filename: /tmp/1644.php function name: foobar number of ops: 3 compiled vars: !0 = $a line #* E I O op fetch ext return operands 4 0 E > ASSIGN !0, 42 With opcache
|
Date Modified | Username | Field | Change |
---|---|---|---|
2019-03-04 17:13 | dv-ds | New Issue | |
2019-03-04 17:13 | dv-ds | File Added: xdebug-log.txt | |
2019-03-04 17:27 | derick | Assigned To | => derick |
2019-03-04 17:27 | derick | Status | new => feedback |
2019-03-04 17:27 | derick | Note Added: 0004932 | |
2019-03-04 17:36 | dv-ds | Note Added: 0004933 | |
2019-03-04 17:36 | dv-ds | Status | feedback => assigned |
2019-03-05 13:05 | dv-ds | Note Added: 0004934 | |
2019-03-05 13:26 | derick | Status | assigned => resolved |
2019-03-05 13:26 | derick | Resolution | open => no change required |
2019-03-05 13:27 | derick | Note Added: 0004935 | |
2020-03-12 16:33 | derick | Category | Remote Debugging => Step Debugging |