View Issue Details

IDProjectCategoryView StatusLast Update
0002243XdebugStep Debuggingpublic2024-02-08 17:47
Reportertm8544 Assigned Toderick  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionnot fixable 
Product Version3.3.1 
Summary0002243: Adding variables with special characters in var name to watch
Description

<?php

$Sää = "something";
$TemperatureIn°C = 100;
echo "Set breakpoint on this line and add those two variables above to watch";


With the code above, watched variables become $S and $TemperatureIn
They can be edited with Edit Expression (F2) to reflect correct variable names and after that they show correct variable values.
Variables with special characters in variable name work are ok with PHP, they should also be ok with XDebug.

Windows 11 X64
VsCode: January 2024 (version 1.86)
php_xdebug-3.3.1-8.3-vs16-nts-x86_64.dll
PHP 8.3.2 (not 8.3-dev as stated below in PHP Version, there was no option for 8.3.2)

Steps To Reproduce

Open attached file in VsCode, add breakpoint to line 7, start debugging, add $Sää and $TemperatureIn°C to watch.

TagsNo tags attached.
Attached Files
watch_test.php (146 bytes)   
<?php

$Sää = "something";

$Temperature_In_°C = "100";

echo "Set breakpoint on this line and add those two variables above to watch";
watch_test.php (146 bytes)   
Operating SystemWindows 11 x64
PHP Version8.3-dev

Activities

derick

2024-02-06 18:49

administrator   ~0006831

Could you provide a debugging log as well? It is explained at https://xdebug.org/reporting-bugs#step-debugger on how to make one.

tm8544

2024-02-07 04:48

reporter   ~0006832

debug.log contains following actions: setting breakpoint, adding two variables to watch, editing expressions

xdebug.log (9,198 bytes)   
[11700] Log opened at 2024-02-07 04:43:06.928264
[11700] [Step Debug] INFO: Connecting to configured address/port: localhost:12859.
[11700] [Step Debug] INFO: Connected to debugging client: localhost:12859 (through xdebug.client_host/xdebug.client_port).
[11700] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///C:/TEMP/watch_test.php" language="PHP" xdebug:language_version="8.3.2" protocol_version="1.0" appid="11700"><engine version="3.3.1"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2023 by Derick Rethans]]></copyright></init>

[11700] [Step Debug] <- feature_set -i 1 -n resolved_breakpoints -v 1
[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="resolved_breakpoints" success="1"></response>

[11700] [Step Debug] <- feature_set -i 2 -n notify_ok -v 1
[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="notify_ok" success="1"></response>

[11700] [Step Debug] <- feature_set -i 3 -n extended_properties -v 1
[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="3" feature="extended_properties" success="1"></response>

[11700] [Step Debug] <- feature_set -i 4 -n breakpoint_include_return_value -v 1
[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="4" feature="breakpoint_include_return_value" success="1"></response>

[11700] [Step Debug] <- feature_set -i 5 -n max_children -v 100
[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="5" feature="max_children" success="1"></response>

[11700] [Step Debug] <- breakpoint_set -i 6 -t line -f file:///c:/TEMP/watch_test.php -n 7
[11700] [Step Debug] -> <notify xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" name="breakpoint_resolved"><breakpoint type="line" resolved="resolved" filename="file:///C:/TEMP/watch_test.php" lineno="7" state="enabled" hit_count="0" hit_value="0" id="117000001"></breakpoint></notify>

[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="6" id="117000001" resolved="resolved"></response>

[11700] [Step Debug] <- breakpoint_get -i 7 -d 117000001
[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_get" transaction_id="7"><breakpoint type="line" resolved="resolved" filename="file:///C:/TEMP/watch_test.php" lineno="7" state="enabled" hit_count="0" hit_value="0" id="117000001"></breakpoint></response>

[11700] [Step Debug] <- run -i 8
[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="8" status="break" reason="ok"><xdebug:message filename="file:///C:/TEMP/watch_test.php" lineno="7"></xdebug:message></response>

[11700] [Step Debug] <- stack_get -i 9
[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="9"><stack where="{main}" level="0" type="file" filename="file:///C:/TEMP/watch_test.php" lineno="7"></stack></response>

[11700] [Step Debug] <- context_names -i 10 -d 0
[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_names" transaction_id="10"><context name="Locals" id="0"></context><context name="Superglobals" id="1"></context><context name="User defined constants" id="2"></context></response>

[11700] [Step Debug] <- context_get -i 11 -d 0 -c 0
[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="11" context="0"><property type="string" size="9"><name encoding="base64"><![CDATA[JFPDpMOk]]></name><fullname encoding="base64"><![CDATA[JFPDpMOk]]></fullname><value encoding="base64"><![CDATA[c29tZXRoaW5n]]></value></property><property type="string" size="3"><name encoding="base64"><![CDATA[JFRlbXBlcmF0dXJlX0luX8KwQw==]]></name><fullname encoding="base64"><![CDATA[JFRlbXBlcmF0dXJlX0luX8KwQw==]]></fullname><value encoding="base64"><![CDATA[MTAw]]></value></property></response>

[11700] [Step Debug] <- eval -i 12 -- JFM=
[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="12"><property type="null"></property></response>

[11700] [Step Debug] <- eval -i 13 -- JFM=
[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="13"><property type="null"></property></response>

[11700] [Step Debug] <- eval -i 14 -- JFRlbXBlcmF0dXJlX0luXw==
[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="14"><property type="null"></property></response>

[11700] [Step Debug] <- eval -i 15 -- JFM=
[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="15"><property type="null"></property></response>

[11700] [Step Debug] <- eval -i 16 -- JFRlbXBlcmF0dXJlX0luX8KwQw==
[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="16"><property type="string" size="3" encoding="base64"><![CDATA[MTAw]]></property></response>

[11700] [Step Debug] <- context_names -i 17 -d 0
[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_names" transaction_id="17"><context name="Locals" id="0"></context><context name="Superglobals" id="1"></context><context name="User defined constants" id="2"></context></response>

[11700] [Step Debug] <- context_get -i 18 -d 0 -c 0
[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="18" context="0"><property type="string" size="9"><name encoding="base64"><![CDATA[JFPDpMOk]]></name><fullname encoding="base64"><![CDATA[JFPDpMOk]]></fullname><value encoding="base64"><![CDATA[c29tZXRoaW5n]]></value></property><property type="string" size="3"><name encoding="base64"><![CDATA[JFRlbXBlcmF0dXJlX0luX8KwQw==]]></name><fullname encoding="base64"><![CDATA[JFRlbXBlcmF0dXJlX0luX8KwQw==]]></fullname><value encoding="base64"><![CDATA[MTAw]]></value></property></response>

[11700] [Step Debug] <- eval -i 19 -- JFPDpMOk
[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="19"><property type="string" size="9" encoding="base64"><![CDATA[c29tZXRoaW5n]]></property></response>

[11700] [Step Debug] <- eval -i 20 -- JFRlbXBlcmF0dXJlX0luX8KwQw==
[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="20"><property type="string" size="3" encoding="base64"><![CDATA[MTAw]]></property></response>

[11700] [Step Debug] <- context_names -i 21 -d 0
[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_names" transaction_id="21"><context name="Locals" id="0"></context><context name="Superglobals" id="1"></context><context name="User defined constants" id="2"></context></response>

[11700] [Step Debug] <- context_get -i 22 -d 0 -c 0
[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="22" context="0"><property type="string" size="9"><name encoding="base64"><![CDATA[JFPDpMOk]]></name><fullname encoding="base64"><![CDATA[JFPDpMOk]]></fullname><value encoding="base64"><![CDATA[c29tZXRoaW5n]]></value></property><property type="string" size="3"><name encoding="base64"><![CDATA[JFRlbXBlcmF0dXJlX0luX8KwQw==]]></name><fullname encoding="base64"><![CDATA[JFRlbXBlcmF0dXJlX0luX8KwQw==]]></fullname><value encoding="base64"><![CDATA[MTAw]]></value></property></response>

[11700] [Step Debug] <- stop -i 23
[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stop" transaction_id="23" status="stopped" reason="ok"></response>

[11700] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stop" transaction_id="23" status="stopping" reason="ok"></response>

[11700] Log closed at 2024-02-07 04:43:49.868329

xdebug.log (9,198 bytes)   

derick

2024-02-07 09:46

administrator   ~0006833

I can't reproduce this: https://derickrethans.nl/files/dump/2024-02-07_09-40-54.gif

Your log also shows the right watches for these two variables, but also the "wrong" ones.

If I just right click on the variable, and do "Add to watch" it indeed cuts of the weird characters. But that's not an Xdebug issue — perhaps something in either VS Code, or the plugin: http://derickrethans.nl/files/dump/2024-02-07_09-45-34.gif

Zobo

2024-02-07 12:26

reporter   ~0006834

This indeed is a problem of VS Code. However the good news is that VSCode, when clicking the "Add to Watch", tries to delegate the decision to language extensions via the EvaluatableExpressionProvider (https://code.visualstudio.com/api/references/vscode-api#EvaluatableExpressionProvider).
So depending on what PHP language extension you have installed this might work better.
If you don't have any, VSCode probably falls back it it's word logic... I'm guessing here.

My https://marketplace.visualstudio.com/items?itemName=zobo.php-intellisense does support this and here is an example of the messages exchanged:

[Trace - 12:06:30 PM] Sending request 'textDocument/xevaluatableExpression - (305)'.
Params: {
    "textDocument": {
        "uri": "file:///app/index.php"
    },
    "position": {
        "line": 40,
        "character": 3
    }
}

[Trace - 12:06:30 PM] Received response 'textDocument/xevaluatableExpression - (305)' in 54ms.
Result: {
    "expression": "$Temperature_In_°C",
    "range": {
        "start": {
            "line": 40,
            "character": 0
        },
        "end": {
            "line": 40,
            "character": 19
        }
    }
}

I recently helped publish https://marketplace.visualstudio.com/items?itemName=phpactor.vscode-phpactor but that one is still missing this feature - I hope to get it in there soon.
There are other - commercial - PHP language server extensions, but I am not sure if they implement this feature.

tm8544

2024-02-07 14:33

reporter   ~0006836

@derick, you couldn't reproduce it because you selected the variable before adding to watch.
Try just clicking on the variable and then adding to watch to see the problem.

Normally, adding to watch does not require selecting a simple variable name. On certain cases, eg for part of an array like $a[1][2] you need to select it, if you want to add that single item of array $a, not all of $a.

derick

2024-02-08 14:26

administrator   ~0006838

My second video/GIF did show I could reproduce this. But it's not on Xdebug's side, so I can't do anything about it.

tm8544

2024-02-08 17:47

reporter   ~0006844

Ok, I have created an issue to https://github.com/microsoft/vscode/issues

Issue History

Date Modified Username Field Change
2024-02-06 06:20 tm8544 New Issue
2024-02-06 06:20 tm8544 File Added: watch_test.php
2024-02-06 18:49 derick Assigned To => derick
2024-02-06 18:49 derick Status new => feedback
2024-02-06 18:49 derick Note Added: 0006831
2024-02-07 04:48 tm8544 Note Added: 0006832
2024-02-07 04:48 tm8544 File Added: xdebug.log
2024-02-07 04:48 tm8544 Status feedback => assigned
2024-02-07 09:46 derick Status assigned => resolved
2024-02-07 09:46 derick Resolution open => not fixable
2024-02-07 09:46 derick Note Added: 0006833
2024-02-07 12:26 Zobo Note Added: 0006834
2024-02-07 14:33 tm8544 Note Added: 0006836
2024-02-08 14:26 derick Note Added: 0006838
2024-02-08 17:47 tm8544 Note Added: 0006844