MantisBT

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001548XdebugUsage problems (Wrong Results)public2018-05-03 02:122018-05-08 10:07
Reporternathanielks 
Assigned Toderick 
PrioritynormalSeveritycrashReproducibilityalways
StatusresolvedResolutionunable to reproduce 
PlatformOSUbuntuOS Version16.04.3
Product Version2.6.0 
Target VersionFixed in Version 
Summary0001548: Evaluating expressions results in synax error
DescriptionI'm trying to use the Debug console in both Visual Studio Code and PHPStorm. Both IDEs' console fails to evaluate expressions. VSCode fails as follows:

```
echo 'test';
syntax error, unexpected 'echo' (T_ECHO), expecting ';'
```

I filed an issue with vscode-php-debug thinking it may be an issue there, but it appears it's working on VSCode's side: https://github.com/felixfbecker/vscode-php-debug/issues/267. [^] I was directed to file an issue here.

Here is the log generated by Xdebug: https://gist.github.com/nathanielks/fe2ff0422e538c64134b3bb36ca63616. [^]
Steps To Reproduce- Have Xdebug 2.6.0 installed (I've tested on macOS and Ubuntu, it results in the same issue)

- Have Xdebug enabled:
```
[xdebug]
zend_extension="xdebug.so"
xdebug.remote_enable=1
xdebug.remote_autostart=1
```

- A simple file will do:
```
<?php
phpinfo();
exit;
```
- Set a breakpoint on phpinfo()

- Start debugging session in VSCode/PHPStorm

- type "echo 'test';" in the debug console

- It should break.
Additional InformationI've tested this in a Vagrant machine as well as natively on my laptop (macOS). They both can't use the debug console, which I find odd. I would expect one of them to be broken, but not both. Stepping over, into, and out of functions works just fine, so it appears the connection between IDE and Xdebug is ok. I don't understand why the debug console would be broken, however.
TagsNo tags attached.
Operating SystemmacOS 10.13.4
PHP Version7.2.0-7.2.4
Attached Files

- Relationships

-  Notes
(0004645)
derick (administrator)
2018-05-03 10:51

The log that you linked to (https://gist.github.com/nathanielks/fe2ff0422e538c64134b3bb36ca63616#file-xdebug-log-L37 [^]) has:

ZWNobyAndGVzdCc=

which is:

$ bin/base64.sh ZWNobyAndGVzdCc=
echo 'test'

It doesn't have the trailing ;, which is necessary - even with an eval in PHP itself:

$ php
<?php
eval("echo 'test'");
^D
Parse error: syntax error, unexpected end of file, expecting ',' or ';' in Standard input code(2) : eval()'d code on line 1


$ php
<?php
eval("echo 'test';");
^D
test


You're either not adding the ; yourself, or your IDE strips it.
(0004647)
nathanielks (reporter)
2018-05-03 21:16
edited on: 2018-05-03 21:19

Hey Derick,

Thanks for the quick response! I tried both with and without a trailing semi-colon, and both had errors.

I did some reading and further testing based on people experiencing the issue and I've found this is due to user error (I think). VSCode updated today and I'm no longer seeing the syntax error, it just says "error evaluating code." It sounds like there may have been a bug in VSCode and not the debugging extension.

In my testing, I looked at the xdebug log to see what VSCode was sending vs what PHPStorm was sending and I found that PHPStorm automatically wraps function calls and other operations in an eval statement, where as the VSCode extension does not.

(0004648)
nathanielks (reporter)
2018-05-03 21:19

All that said, I don't think an issue exists. Thanks for all your hard work and I appreciate your time!
(0004650)
derick (administrator)
2018-05-08 10:07

OK. Good to know. I'll close this ticket then!

- Issue History
Date Modified Username Field Change
2018-05-03 02:12 nathanielks New Issue
2018-05-03 10:51 derick Note Added: 0004645
2018-05-03 10:51 derick Assigned To => derick
2018-05-03 10:51 derick Status new => feedback
2018-05-03 21:16 nathanielks Note Added: 0004647
2018-05-03 21:16 nathanielks Status feedback => assigned
2018-05-03 21:19 nathanielks Note Edited: 0004647 View Revisions
2018-05-03 21:19 nathanielks Note Added: 0004648
2018-05-08 10:07 derick Note Added: 0004650
2018-05-08 10:07 derick Status assigned => resolved
2018-05-08 10:07 derick Resolution open => unable to reproduce


Copyright © 2000 - 2018 MantisBT Team
Powered by Mantis Bugtracker