gwomacks / php-debug

Atom Text Editor package for PHP debugging
MIT License
119 stars 31 forks source link

Variables and stacktrace are not shown #189

Closed KristobalJunta closed 6 years ago

KristobalJunta commented 7 years ago

I recently observed, that php-debug for atom stopped showing variables and stacktrace, though working. It successfully connects to xdebug server, and breakpoints are working. But I can't see any useful output. I tested xdebug with another client - and it worked fine, showing everything I needed. An error appears in the developer console in Atom at the moment, when the actual trace should be displayed. Here it is:

dbgp-instance.coffee:66 Error: Invalid attribute name
Line: 1
Column: 306672
Char: "
    at error (/home/eugen/.atom/packages/php-debug/node_modules/sax/lib/sax.js:667:10)
    at strictFail (/home/eugen/.atom/packages/php-debug/node_modules/sax/lib/sax.js:693:7)
    at Object.write (/home/eugen/.atom/packages/php-debug/node_modules/sax/lib/sax.js:1413:13)
    at Parser.exports.Parser.Parser.parseString (/home/eugen/.atom/packages/php-debug/node_modules/xml2js/lib/xml2js.js:508:31)
    at Parser.parseString (/home/eugen/.atom/packages/php-debug/node_modules/xml2js/lib/xml2js.js:7:59)
    at exports.parseString (/home/eugen/.atom/packages/php-debug/node_modules/xml2js/lib/xml2js.js:540:19)
    at DbgpInstance.module.exports.DbgpInstance.parse (/home/eugen/.atom/packages/php-debug/lib/engines/dbgp/dbgp-instance.coffee:64:15)
    at DbgpInstance.parse (/home/eugen/.atom/packages/php-debug/lib/engines/dbgp/dbgp-instance.coffee:1:1)
    at DbgpInstance.module.exports.DbgpInstance.stuff (/home/eugen/.atom/packages/php-debug/lib/engines/dbgp/dbgp-instance.coffee:89:26)
    at Socket.<anonymous> (/home/eugen/.atom/packages/php-debug/lib/engines/dbgp/dbgp-instance.coffee:1:1)
    at emitOne (events.js:90:13)
    at Socket.emit (events.js:182:7)
    at readableAddChunk (_stream_readable.js:153:18)
    at Socket.Readable.push (_stream_readable.js:111:10)
    at TCP.onread (net.js:531:20)
(anonymous function) @ dbgp-instance.coffee:66
(anonymous function) @ /home/eugen/.atom/packages/php-debug/node_modules/xml2js/lib/xml2js.js:493
emitOne @ events.js:90
emit @ events.js:182
(anonymous function) @ /home/eugen/.atom/packages/php-debug/node_modules/xml2js/lib/xml2js.js:311
emit @ /home/eugen/.atom/packages/php-debug/node_modules/sax/lib/sax.js:640
error @ /home/eugen/.atom/packages/php-debug/node_modules/sax/lib/sax.js:669
strictFail @ /home/eugen/.atom/packages/php-debug/node_modules/sax/lib/sax.js:693
write @ /home/eugen/.atom/packages/php-debug/node_modules/sax/lib/sax.js:1413
exports.Parser.Parser.parseString @ /home/eugen/.atom/packages/php-debug/node_modules/xml2js/lib/xml2js.js:508
(anonymous function) @ /home/eugen/.atom/packages/php-debug/node_modules/xml2js/lib/xml2js.js:7
exports.parseString @ /home/eugen/.atom/packages/php-debug/node_modules/xml2js/lib/xml2js.js:540
module.exports.DbgpInstance.parse @ dbgp-instance.coffee:64
(anonymous function) @ dbgp-instance.coffee:1
module.exports.DbgpInstance.stuff @ dbgp-instance.coffee:89
(anonymous function) @ dbgp-instance.coffee:1
emitOne @ events.js:90
emit @ events.js:182
readableAddChunk @ _stream_readable.js:153
Readable.push @ _stream_readable.js:111
onread @ net.js:531

Also, here is my xdebug config:

zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_connect_back=1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true

Everything else in xdebug is set by default.

QwertyZW commented 7 years ago

What's the xdebug version installed on your server? Can you try commenting out the "zend_extension=xdebug.so" from your config? you can try logging the message variable.

zmorris commented 7 years ago

This has been happening for me as well, over perhaps the last month. I never changed any settings, the info just stopped appearing. Here is my php info within vagrant:

$ php -v
PHP 5.6.15-1+deb.sury.org~trusty+1 (cli) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
    with Xdebug v2.3.2, Copyright (c) 2002-2015, by Derick Rethans
    with blackfire v1.6.0, https://blackfire.io, by Blackfireio Inc.

And my Mac's info:

Mac OS X 10.11.6 Atom 1.11.2 php-debug 0.2.3

KristobalJunta commented 7 years ago

PHP verison is 7.0.12, xdebug version is 4.7, Atom version is 1.10.2, extension version is 2.0.3

zmorris commented 7 years ago

I tried the newest Laravel Homestead 7 box in Vagrant and it's still not showing variables in the debugger:

# steps used to install Xdebug:
vagrant ssh
sudo apt-get update    # only updates packages list, not installed packages
sudo apt-get install php-xdebug
# edit one or both of the following (fpm applies to web browser; cli applies to command line interface, console or terminal):
sudo nano /etc/php/7.0/fpm/conf.d/20-xdebug.ini
sudo nano /etc/php/7.0/cli/conf.d/20-xdebug.ini
###
zend_extension = xdebug.so
xdebug.remote_port = 9000
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1    # not safe for production servers because it autodetects the user's IP address and sends descriptions of the code being debugged
xdebug.max_nesting_level = 250
###
# restart php and nginx
sudo service php7.0-fpm restart && sudo service nginx reload
$ php -v
PHP 7.0.8-2+deb.sury.org~xenial+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.8-2+deb.sury.org~xenial+1, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.4.1, Copyright (c) 2002-2016, by Derick Rethans
    with blackfire v1.10.6, https://blackfire.io, by Blackfireio Inc.

Atom 1.12.2

$ apm list --installed --bare
angularjs@0.3.5
atom-autocomplete-php@0.20.2
atom-beautify@0.29.13
atom-ctags@5.0.0
autocomplete-php@0.3.7
autohide-tree-view@0.25.1
blame@0.10.0
color-picker@2.2.3
docblockr@0.8.7
editorconfig@2.0.5
emmet@2.4.3
file-icons@1.7.25
git-plus@5.25.1
goto@1.7.1
language-api-blueprint@1.0.2
minimap@4.25.6
minimap-codeglance@0.4.5
minimap-find-and-replace@4.5.1
minimap-git-diff@4.3.1
minimap-pigments@0.2.1
navigate@0.1.17
navigate-indent@0.1.0
open-recent@5.0.0
php-cs-fixer@2.5.9
php-debug@0.2.3
pigments@0.37.0
raml@0.2.0
symbol-gen@1.3.1
symbols-tree-view@0.13.2
terminal-plus@0.14.5
tree-view-git-branch@0.1.2

If it's working for everyone else, then this must be a package or caching issue. Not sure how to attack a problem like this. I need something like git bisect for apm.

zmorris commented 7 years ago

Just a note that php-debug 0.2.4 still doesn't work under my configuration and Atom 1.12.6. I disabled all community packages with apm disable <package-name> except php-debug and still no luck.

zmorris commented 7 years ago

SOLVED

The problem is due to case sensitivity.

Mac OS X 10.11.6 (15G1212) 1.13.0 x64 php-debug 0.2.4

1) Setting a breakpoint in app/Http/routes.php and reloading works but stack is not shown 2) Setting a breakpoint in Public/index.php works but.. 3) ..debugger opens in public/index.php (which is not found by Atom when I right click in the file and choose "Reveal in Tree View"). Variable stack now works 4) Variable stack still shown when continuing to old breakpoint in app/Http/routes.php but variable stack is stale (showing $test as 2 instead of $test as 1)

screen shot 2017-01-15 at 3 58 46 pm screen shot 2017-01-15 at 3 58 59 pm screen shot 2017-01-15 at 3 59 11 pm screen shot 2017-01-15 at 3 59 17 pm

The issue seems to be that php-debug isn't recognizing paths like Public/index.php but is recognizing paths like public/index.php. These paths are the same on both my local Mac OS X and remote Vagrant Debian Jessie so I don't know why it's not recognizing them. I also don't know why it can map Public to public but not Http to http.

This problem has cost me countless hours of frustration, but I'm not pointing any fingers, I'm just glad it's over. My personal preference is that case-insensitivity is a very good thing in the daily workflow of humans but that developers almost never check if the filesystem is case-sensitive as they do their string comparisons. Hope this helps you get this fixed.

jnettik commented 7 years ago

Is there a solution for this yet that accounts for case insensitivity? Spent a lot of time hunting this down as well, and changing some folder names isn't always possible.

yaaax commented 7 years ago

I experience the same issue. Please let us know when a fix is available. Thanks

cchamplin commented 6 years ago

Should be fixed in v0.3.0. Please reopen if not.

mattkatt commented 6 years ago

Currently still experiencing this bug with a fresh install of Atom 1.26.1 and php-debug 0.3.4. php-debug will work for about half a dozen runs, then will stop working for a while. Removing and reinstalling fixes the issue for a time, as does restarting my entire machine (but not closing Atom and restarting my VM)

NB: Working on a windows machine, and path names definitely have uppercase letters in them